0
I am creating a project in college, in which I need to register a user. In my controller I receive a User and need to convert to a type of user, being them student, teacher, coordinator or external user. I am using modelMapper to try to make this conversion but am having some problems.
Here’s an example of what I have
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
@Type(value = Aluno.class, name = "aluno"),
@Type(value = Professor.class, name = "professor"),
@Type(value = UsuarioExterno.class, name = "usuarioExterno"),
@Type(value = Coordenador.class, name = "coordenador")
})
@Entity
public abstract class Usuario {
private Long id;
private String nome;
private String email;
...
public class Aluno extends Usuario {
private String ra;
}
public class Professor extends Usuario {
private String ra;
}
public class Coordenador extends Usuario {
private String ra;
}
and this here is my User
public class UsuarioDto {
private Long id;
private String nome;
private String email;
}
Request
{
"type": "aluno",
"nome": "bruno",
"email": "[email protected]",
"ra": "0012345"
}
In the request I need to enter the type of the user("type"). I took a look at the documentation of the modelMapper but I could not understand their example with inheritance.