From 1460a71f88e1a970ff14f043d8e72cdea778b4de Mon Sep 17 00:00:00 2001 From: Ramon Trekovanicz Date: Mon, 1 Jul 2024 16:33:59 +0200 Subject: [PATCH 1/3] chore: add UserService and Implementation for register --- .../backend/services/UserService.java | 10 ++++++++++ .../backend/services/UserServiceImpl.java | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java create mode 100644 backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java diff --git a/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java b/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java new file mode 100644 index 00000000..77500038 --- /dev/null +++ b/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java @@ -0,0 +1,10 @@ +package com.greenfoxacademy.backend.services; + +import com.greenfoxacademy.backend.models.User; +import org.springframework.stereotype.Service; + +@Service +public interface UserService { + public void register(User newUser); + +} diff --git a/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java b/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java new file mode 100644 index 00000000..ef797aa8 --- /dev/null +++ b/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java @@ -0,0 +1,16 @@ +package com.greenfoxacademy.backend.services; + +import com.greenfoxacademy.backend.models.User; +import com.greenfoxacademy.backend.repositories.UserRepository; +import org.springframework.stereotype.Service; + +@Service +public class UserServiceImpl implements UserService { + UserRepository userRepository; + + + @Override + public void register(User newUser) { + userRepository.save(newUser); + } +} From da90dbec2b340e8f2b54639fcc9f94916d456a27 Mon Sep 17 00:00:00 2001 From: Ramon Trekovanicz Date: Mon, 1 Jul 2024 16:49:40 +0200 Subject: [PATCH 2/3] fix: empty lines remove, userService now use private final repository --- .../greenfoxacademy/backend/repositories/UserRepository.java | 1 - .../com/greenfoxacademy/backend/services/UserService.java | 2 +- .../greenfoxacademy/backend/services/UserServiceImpl.java | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/com/greenfoxacademy/backend/repositories/UserRepository.java b/backend/src/main/java/com/greenfoxacademy/backend/repositories/UserRepository.java index 84f40ace..dd62617a 100644 --- a/backend/src/main/java/com/greenfoxacademy/backend/repositories/UserRepository.java +++ b/backend/src/main/java/com/greenfoxacademy/backend/repositories/UserRepository.java @@ -7,5 +7,4 @@ * Repository to manage {@link User} entities. */ public interface UserRepository extends JpaRepository { - } diff --git a/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java b/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java index 77500038..02c6fd1f 100644 --- a/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java +++ b/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java @@ -5,6 +5,6 @@ @Service public interface UserService { - public void register(User newUser); + void register(User newUser); } diff --git a/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java b/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java index ef797aa8..a8aa88f8 100644 --- a/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java +++ b/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java @@ -2,12 +2,13 @@ import com.greenfoxacademy.backend.models.User; import com.greenfoxacademy.backend.repositories.UserRepository; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @Service +@RequiredArgsConstructor public class UserServiceImpl implements UserService { - UserRepository userRepository; - + private final UserRepository userRepository; @Override public void register(User newUser) { From 5450ff10ccdae617872e3e2dd7692f6727651b14 Mon Sep 17 00:00:00 2001 From: Ramon Trekovanicz Date: Mon, 1 Jul 2024 18:22:17 +0200 Subject: [PATCH 3/3] fix: indentations fix, javadoc add --- .../greenfoxacademy/backend/BackendApplication.java | 4 ++-- .../backend/controller/HealthCheckController.java | 4 ++-- .../backend/services/UserService.java | 5 ++++- .../backend/services/UserServiceImpl.java | 13 ++++++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/com/greenfoxacademy/backend/BackendApplication.java b/backend/src/main/java/com/greenfoxacademy/backend/BackendApplication.java index 35876729..5832a603 100644 --- a/backend/src/main/java/com/greenfoxacademy/backend/BackendApplication.java +++ b/backend/src/main/java/com/greenfoxacademy/backend/BackendApplication.java @@ -5,9 +5,9 @@ @SpringBootApplication public class BackendApplication { - + public static void main(String[] args) { SpringApplication.run(BackendApplication.class, args); } - + } diff --git a/backend/src/main/java/com/greenfoxacademy/backend/controller/HealthCheckController.java b/backend/src/main/java/com/greenfoxacademy/backend/controller/HealthCheckController.java index 4703f7e3..10c7d183 100644 --- a/backend/src/main/java/com/greenfoxacademy/backend/controller/HealthCheckController.java +++ b/backend/src/main/java/com/greenfoxacademy/backend/controller/HealthCheckController.java @@ -11,9 +11,9 @@ */ @Controller public class HealthCheckController { - @GetMapping ("/health-check") + @GetMapping("/health-check") public ResponseEntity healthCheck() { return new ResponseEntity<>("OK", HttpStatus.OK); } - + } diff --git a/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java b/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java index 02c6fd1f..a5ecd6c0 100644 --- a/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java +++ b/backend/src/main/java/com/greenfoxacademy/backend/services/UserService.java @@ -3,8 +3,11 @@ import com.greenfoxacademy.backend.models.User; import org.springframework.stereotype.Service; +/** + * Service to manage {@link User} related actions. + */ @Service public interface UserService { - void register(User newUser); + void register(User newUser); } diff --git a/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java b/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java index a8aa88f8..a360f47f 100644 --- a/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java +++ b/backend/src/main/java/com/greenfoxacademy/backend/services/UserServiceImpl.java @@ -5,13 +5,16 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +/** + * Service implementation to manage {@link UserService}. + */ @Service @RequiredArgsConstructor public class UserServiceImpl implements UserService { - private final UserRepository userRepository; + private final UserRepository userRepository; - @Override - public void register(User newUser) { - userRepository.save(newUser); - } + @Override + public void register(User newUser) { + userRepository.save(newUser); + } }