forked from fabiotakaki/labes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsuario.java
More file actions
107 lines (82 loc) · 2.36 KB
/
Usuario.java
File metadata and controls
107 lines (82 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.mycompany.model;
/**
*
* @author nicol, sidious
*/
//import com.sun.istack.internal.NotNull;
import com.mycompany.persistences.UsuarioPersistence;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
@Entity
@Table(name = "Usuario")
public class Usuario implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
@NotNull
private Integer id;
@Column(name = "userName", nullable = false, unique = true)
private String nomeUsuario;
@Column(name = "senha", nullable = false, unique = false)
private String senha;
@Column(name = "nome", nullable = true, unique = false)
private String nome;
@Column(name = "email", nullable = true, unique = false)
private String email;
public Usuario(String nomeUsuario, String senha) {
this.nomeUsuario = nomeUsuario;
this.senha = senha;
}
public Usuario() {
}
public String getNomeUsuario() {
return nomeUsuario;
}
public void setNomeUsuario(String nomeUsuario) {
this.nomeUsuario = nomeUsuario;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public Integer getId() {
return id;
}
public void setId(Integer id){
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public boolean saveOnDatabase() {
return UsuarioPersistence.save(this);
}
public static Usuario login(String email, String senha) {
return UsuarioPersistence.login(email, senha);
}
public static Usuario buscaUsuario(Integer idUsuario){
return UsuarioPersistence.getUsuario(idUsuario);
}
public static Usuario buscaUsuarioEmail(String email){
return UsuarioPersistence.getUsuarioEmail(email);
}
}