Commit 03e4ffdd by Rubén Ramírez

feat: [Mapper]: Creadas las funciones para pasar de dto a entidad y viceversa de recurso.

parent 31ab678e
package com.ujaen.tfg.mangaffinity.rest.DTO; package com.ujaen.tfg.mangaffinity.rest.DTO;
import com.ujaen.tfg.mangaffinity.entidades.Recurso;
import com.ujaen.tfg.mangaffinity.entidades.Usuario; import com.ujaen.tfg.mangaffinity.entidades.Usuario;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -13,4 +14,14 @@ public class Mapper { ...@@ -13,4 +14,14 @@ public class Mapper {
public Usuario entity(DTOUsuario dtoUsuario) { public Usuario entity(DTOUsuario dtoUsuario) {
return new Usuario(dtoUsuario.getEmail(), dtoUsuario.getNombreUsuario(), dtoUsuario.getContrasenia()); return new Usuario(dtoUsuario.getEmail(), dtoUsuario.getNombreUsuario(), dtoUsuario.getContrasenia());
} }
public DTORecurso dto(Recurso recurso) {
return new DTORecurso(recurso.getId(), recurso.getTitulo(), recurso.getDescripcion(), recurso.getFechaPublicacion(), recurso.getAutor()
);
}
public Recurso entity(DTORecurso dtoRecurso) {
return new Recurso(dtoRecurso.getTitulo(), dtoRecurso.getDescripcion(), dtoRecurso.getFechaPublicacion(), dtoRecurso.getAutor()
);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment