feat: 实现查看团队成员名单接口

This commit is contained in:
BenjaminNH 2025-07-21 11:19:39 +08:00
parent 13d18bd3ab
commit a94ab466d2
3 changed files with 20 additions and 0 deletions

View File

@ -68,4 +68,10 @@ public class UserController {
userService.deleteById(userId);
return ResponseResult.success();
}
@PreAuthorize("hasRole('ADMIN')")
@GetMapping("/user-team/{teamId}")
public ResponseResult<List<String>> getTeamUsers(@PathVariable Long teamId) {
return ResponseResult.success(userService.getTeamUsers(teamId));
}
}

View File

@ -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<String> getTeamUsers(Long teamId);
}

View File

@ -136,4 +136,14 @@ public class UserServiceImpl implements UserService {
userMapper.insert(user);
userRoleMapper.insert(new UserRole(user.getId(), dto.getRoleId()));
}
@Override
public List<String> getTeamUsers(Long teamId) {
return userMapper.selectList(new LambdaQueryWrapper<User>()
.eq(User::getTeamId, teamId)
.orderByAsc(User::getName))
.stream()
.map(User::getName)
.toList();
}
}