Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mappers, entities fix solved #3

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/main/java/edu/eci/cvds/beans/BasePageBean.java

This file was deleted.

4 changes: 0 additions & 4 deletions src/main/java/edu/eci/cvds/beans/LoginBean.java

This file was deleted.

5 changes: 5 additions & 0 deletions src/main/java/edu/eci/cvds/entities/Estado.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package edu.eci.cvds.entities;

public enum Estado {
ACTIVO, INACTIVO
}
5 changes: 5 additions & 0 deletions src/main/java/edu/eci/cvds/entities/Rol.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package edu.eci.cvds.entities;

public enum Rol {
ADMINISTRADOR, PERSONAL_PMO, PROPONENTE, PUBLICO
}
23 changes: 18 additions & 5 deletions src/main/java/edu/eci/cvds/entities/Usuario.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ public class Usuario{
private String nombre;
private String correo;
private String contraseña;
private String rol;
private Rol rol;
private Estado estado;

private Usuario(String nombre, String correo, String contraseña, String rol){
public Usuario(){}

public Usuario(String nombre, String correo, String contraseña, Rol rol, Estado estado){
this.nombre = nombre;
this.correo = correo;
this.contraseña = contraseña;
this.rol = rol;
this.estado = estado;
}

public void setNombre(String nombre) {
Expand All @@ -25,7 +29,7 @@ public void setCorreo(String correo) {
this.contraseña = contraseña;
}

public void setRol(String rol) {
public void setRol(Rol rol) {
this.rol = rol;
}

Expand All @@ -41,17 +45,26 @@ public String getCorreo() {
return contraseña;
}

public String getRol() {
public Rol getRol() {
return rol;
}

public Estado getEstado() {
return estado;
}

public void setEstado(Estado estado) {
this.estado = estado;
}

@Override
public String toString() {
return "Usuario{" +
"nombre='" + nombre + '\'' +
", correo='" + correo + '\'' +
", contraseña='" + contraseña + '\'' +
", rol='" + rol + '\'' +
", rol='" + rol.name() + '\'' +
", estado='" + estado.name() + '\'' +
'}';
}
}
8 changes: 4 additions & 4 deletions src/main/resources/mappers/UsuarioMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#{usuario.correo},
#{usuario.contraseña},
#{usuario.nombre},
#{usuario.rol},
#{usuario.estado}
#{usuario.rol, typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler},
#{usuario.estado, typeHandler=org.apache.ibatis.type.EnumOrdinalTypeHandler}
)
</insert>

Expand All @@ -31,8 +31,8 @@
<id property='correo' column='correo' />
<result property='contraseña' column='contraseña' />
<result property='nombre' column='nombre' />
<result property='rol' column='rol' />
<result property="estado" column="estado" />
<result property='rol' column='rol' typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler" />
<result property="estado" column="estado" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler" />


</resultMap>
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/mybatis-config-h2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<typeAlias type='edu.eci.cvds.entities.Usuario' alias='Usuario'/>
</typeAliases>

<typeHandlers>
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
javaType="java.math.RoundingMode"/>
</typeHandlers>


<environments default="test">
<environment id="test">
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/mybatis-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<typeAlias type="edu.eci.cvds.entities.Usuario" alias="Usuario"/>
</typeAliases>

<typeHandlers>
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
javaType="java.math.RoundingMode"/>
</typeHandlers>

<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/LoginTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class LoginTest {


}