From a94ab466d2a5aa6371a81ffff174ddb623d023b0 Mon Sep 17 00:00:00 2001 From: BenjaminNH <1249376374@qq.com> Date: Mon, 21 Jul 2025 11:19:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=9B=A2=E9=98=9F=E6=88=90=E5=91=98=E5=90=8D=E5=8D=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equipreservebackend/controller/UserController.java | 6 ++++++ .../equipreservebackend/service/UserService.java | 4 ++++ .../service/impl/UserServiceImpl.java | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/main/java/github/benjamin/equipreservebackend/controller/UserController.java b/src/main/java/github/benjamin/equipreservebackend/controller/UserController.java index 36d8d53..4a6e42b 100644 --- a/src/main/java/github/benjamin/equipreservebackend/controller/UserController.java +++ b/src/main/java/github/benjamin/equipreservebackend/controller/UserController.java @@ -68,4 +68,10 @@ public class UserController { userService.deleteById(userId); return ResponseResult.success(); } + + @PreAuthorize("hasRole('ADMIN')") + @GetMapping("/user-team/{teamId}") + public ResponseResult> getTeamUsers(@PathVariable Long teamId) { + return ResponseResult.success(userService.getTeamUsers(teamId)); + } } diff --git a/src/main/java/github/benjamin/equipreservebackend/service/UserService.java b/src/main/java/github/benjamin/equipreservebackend/service/UserService.java index 0699bdd..f79e186 100644 --- a/src/main/java/github/benjamin/equipreservebackend/service/UserService.java +++ b/src/main/java/github/benjamin/equipreservebackend/service/UserService.java @@ -6,6 +6,8 @@ import github.benjamin.equipreservebackend.entity.User; import github.benjamin.equipreservebackend.security.SecurityUser; import github.benjamin.equipreservebackend.vo.UserVO; +import java.util.List; + public interface UserService { User login(String username, String password); @@ -21,4 +23,6 @@ public interface UserService { void deleteById(Long userId); void addUser(UserDTO dto); + + List getTeamUsers(Long teamId); } diff --git a/src/main/java/github/benjamin/equipreservebackend/service/impl/UserServiceImpl.java b/src/main/java/github/benjamin/equipreservebackend/service/impl/UserServiceImpl.java index 4c9130a..50b8983 100644 --- a/src/main/java/github/benjamin/equipreservebackend/service/impl/UserServiceImpl.java +++ b/src/main/java/github/benjamin/equipreservebackend/service/impl/UserServiceImpl.java @@ -136,4 +136,14 @@ public class UserServiceImpl implements UserService { userMapper.insert(user); userRoleMapper.insert(new UserRole(user.getId(), dto.getRoleId())); } + + @Override + public List getTeamUsers(Long teamId) { + return userMapper.selectList(new LambdaQueryWrapper() + .eq(User::getTeamId, teamId) + .orderByAsc(User::getName)) + .stream() + .map(User::getName) + .toList(); + } }