use of com.bigcrowd.noticeBoard.dto.PersonAllDTO in project Notice-Board by FulvioFPimentel.
the class PersonController method savePerson.
@PostMapping(value = "/create")
public ResponseEntity<PersonAllDTO> savePerson(@RequestBody PersonSaveDTO dto) {
PersonAllDTO entity = personService.savePerson(dto);
URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(entity.getId()).toUri();
return ResponseEntity.created(uri).body(entity);
}
use of com.bigcrowd.noticeBoard.dto.PersonAllDTO in project Notice-Board by FulvioFPimentel.
the class PersonService method savePerson.
@Transactional
public PersonAllDTO savePerson(PersonSaveDTO dto) {
Person person = new Person();
person.setName(dto.getName());
person.setCellPhone(dto.getCellPhone());
person.setPassword(passwordEncoder.encode(dto.getPassword()));
Role role = roleRepository.getById(3L);
person.getRoles().add(role);
person = personRepository.saveAndFlush(person);
return new PersonAllDTO(person, person.getRoles());
}
Aggregations