From 6576c1a814e145175397aeaae35d3af7beb70682 Mon Sep 17 00:00:00 2001 From: Matej Hrica <492778@mail.muni.cz> Date: Sun, 26 Mar 2023 22:01:17 +0200 Subject: [PATCH] Add getAllUsers() which is GET /api/users --- authorization/openapi.yaml | 15 +++++++++++++++ .../authorization/server/rest/UserController.java | 7 +++++++ .../authorization/server/service/UserService.java | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/authorization/openapi.yaml b/authorization/openapi.yaml index 1046532..e9a842c 100644 --- a/authorization/openapi.yaml +++ b/authorization/openapi.yaml @@ -18,6 +18,21 @@ servers: default: "${server.port}" paths: /api/users/: + get: + tags: + - User + summary: List all system users + description: Get an array of all system users + operationId: getAllUsers + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/UserDto' put: tags: - User diff --git a/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/rest/UserController.java b/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/rest/UserController.java index 3249438..e3921a3 100644 --- a/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/rest/UserController.java +++ b/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/rest/UserController.java @@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @RestController public class UserController implements UserApiDelegate { @@ -45,4 +47,9 @@ public class UserController implements UserApiDelegate { public ResponseEntity<LoginResponse> login(LoginDto loginDto) { return ResponseEntity.ok(userService.login(loginDto)); } + + @Override + public ResponseEntity<List<UserDto>> getAllUsers() { + return ResponseEntity.ok(userService.getAllUsers()); + } } diff --git a/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/service/UserService.java b/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/service/UserService.java index b93ce27..9e606c3 100644 --- a/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/service/UserService.java +++ b/authorization/src/main/java/cz/muni/fi/pa165/authorization/server/service/UserService.java @@ -7,6 +7,8 @@ import cz.muni.fi.pa165.authorization.server.model.UserDto; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class UserService { @@ -39,4 +41,8 @@ public class UserService { public LoginResponse login(LoginDto loginDto) { return new LoginResponse().token("token-for-" + loginDto.getLogin()); } + + public List<UserDto> getAllUsers() { + return List.of(getUserById(1L)); + } } -- GitLab