-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUsuarioService.java
More file actions
27 lines (22 loc) · 846 Bytes
/
Copy pathUsuarioService.java
File metadata and controls
27 lines (22 loc) · 846 Bytes
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
package application.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import application.model.Usuario;
import application.record.GenericResponse;
import application.record.UsuarioDTO;
import application.repository.UsuarioRepository;
@Service
public class UsuarioService {
@Autowired
private UsuarioRepository usuarioRepo;
@Autowired
private PasswordEncoder passwordEncoder;
public GenericResponse insert(UsuarioDTO dto) {
Usuario usuario = new Usuario();
usuario.setNomeDeUsuario(dto.nomeDeUsuario());
usuario.setSenha(passwordEncoder.encode(dto.senha()));
usuarioRepo.save(usuario);
return new GenericResponse("Usuario Adicionado");
}
}