diff --git a/src/main/java/com/cubetiqs/demo/DemoApplication.java b/src/main/java/com/cubetiqs/demo/DemoApplication.java index a2e9757..dd46cca 100644 --- a/src/main/java/com/cubetiqs/demo/DemoApplication.java +++ b/src/main/java/com/cubetiqs/demo/DemoApplication.java @@ -12,7 +12,7 @@ import java.io.File; public class DemoApplication implements CommandLineRunner { public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); + SpringApplication.run(DemoApplication.class, args); } diff --git a/src/main/java/com/cubetiqs/demo/rest/UserController.java b/src/main/java/com/cubetiqs/demo/rest/UserController.java index c136892..9714860 100644 --- a/src/main/java/com/cubetiqs/demo/rest/UserController.java +++ b/src/main/java/com/cubetiqs/demo/rest/UserController.java @@ -2,6 +2,7 @@ package com.cubetiqs.demo.rest; import com.cubetiqs.demo.domain.UserEntity; import com.cubetiqs.demo.repository.UserRepository; +import com.cubetiqs.demo.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -9,21 +10,24 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Optional; @RestController @RequestMapping(path = {"/users"}) public class UserController { private final UserRepository userRepository; + private final UserService userService; @Autowired - public UserController(UserRepository userRepository) { + public UserController(UserRepository userRepository, UserService userService) { this.userRepository = userRepository; + this.userService = userService; } @GetMapping - public Page getAllUsers(Pageable pageable) { - return userRepository.findAll(pageable); + public List getAllUsers(Pageable pageable) { + return userService.findAllUsers(); } @GetMapping("/{id}") diff --git a/src/main/java/com/cubetiqs/demo/service/UserService.java b/src/main/java/com/cubetiqs/demo/service/UserService.java new file mode 100644 index 0000000..fed87c3 --- /dev/null +++ b/src/main/java/com/cubetiqs/demo/service/UserService.java @@ -0,0 +1,11 @@ +package com.cubetiqs.demo.service; + +import com.cubetiqs.demo.domain.UserEntity; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface UserService { + List findAllUsers(); +} diff --git a/src/main/java/com/cubetiqs/demo/service/UserServiceImpl.java b/src/main/java/com/cubetiqs/demo/service/UserServiceImpl.java new file mode 100644 index 0000000..6c63bd5 --- /dev/null +++ b/src/main/java/com/cubetiqs/demo/service/UserServiceImpl.java @@ -0,0 +1,23 @@ +package com.cubetiqs.demo.service; + +import com.cubetiqs.demo.domain.UserEntity; +import com.cubetiqs.demo.repository.UserRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class UserServiceImpl implements UserService { + private final UserRepository userRepository; + + @Autowired + public UserServiceImpl(UserRepository userRepository) { + this.userRepository = userRepository; + } + + @Override + public List findAllUsers() { + return userRepository.findAll(); + } +} diff --git a/src/main/resources/application-mysql.yml b/src/main/resources/application-mysql.yml index c8c8207..7d4a29e 100644 --- a/src/main/resources/application-mysql.yml +++ b/src/main/resources/application-mysql.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8081 spring: jpa: diff --git a/src/main/resources/application-postgres.yml b/src/main/resources/application-postgres.yml index ec3ea4e..545b8f6 100644 --- a/src/main/resources/application-postgres.yml +++ b/src/main/resources/application-postgres.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8081 spring: jpa: