lab2 fixed services

This commit is contained in:
Zakharov_Rostislav 2024-03-20 19:24:23 +04:00
parent f25171e835
commit 5b19352e87
2 changed files with 5 additions and 0 deletions

View File

@ -48,6 +48,7 @@ public class BookService {
public BookEntity update(Long id, BookEntity entity) {
final BookEntity existsEntity = get(id);
existsEntity.setName(entity.getName());
existsEntity.setType(entity.getType());
existsEntity.setAuthor(entity.getAuthor());
return repository.update(existsEntity);

View File

@ -27,12 +27,16 @@ public class UserService {
}
public UserEntity create(UserEntity entity) {
if (entity.getRole().equals("admin")) {
entity.setRole("user");
}
return repository.create(entity);
}
public UserEntity update(Long id, UserEntity entity) {
final UserEntity existsEntity = get(id);
existsEntity.setName(entity.getName());
existsEntity.setPassword(entity.getPassword());
return repository.update(existsEntity);
}