From 5b19352e87d48c80670ccf9296e545a3ae042481 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Wed, 20 Mar 2024 19:24:23 +0400 Subject: [PATCH] lab2 fixed services --- .../main/java/com/ip/library/books/service/BookService.java | 1 + .../main/java/com/ip/library/users/service/UserService.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/SpringApp/library/src/main/java/com/ip/library/books/service/BookService.java b/SpringApp/library/src/main/java/com/ip/library/books/service/BookService.java index 629fc37..6828d25 100644 --- a/SpringApp/library/src/main/java/com/ip/library/books/service/BookService.java +++ b/SpringApp/library/src/main/java/com/ip/library/books/service/BookService.java @@ -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); diff --git a/SpringApp/library/src/main/java/com/ip/library/users/service/UserService.java b/SpringApp/library/src/main/java/com/ip/library/users/service/UserService.java index 8fc727f..fa61848 100644 --- a/SpringApp/library/src/main/java/com/ip/library/users/service/UserService.java +++ b/SpringApp/library/src/main/java/com/ip/library/users/service/UserService.java @@ -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); }