From 3d3a247c4ded91e82b1d1b39655777d16db3cb93 Mon Sep 17 00:00:00 2001 From: zionhann Date: Thu, 14 Sep 2023 02:08:51 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Fix:=20=EA=B7=B8=EB=A3=B9=20=ED=8C=80?= =?UTF-8?q?=EC=9B=90=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=ED=95=99=EB=B2=88=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EA=B0=80=EB=A6=AC=EA=B8=B0=20(#134)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/edu/handong/csee/histudy/dto/UserDto.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/handong/csee/histudy/dto/UserDto.java b/src/main/java/edu/handong/csee/histudy/dto/UserDto.java index 3996c7d..1211b78 100644 --- a/src/main/java/edu/handong/csee/histudy/dto/UserDto.java +++ b/src/main/java/edu/handong/csee/histudy/dto/UserDto.java @@ -183,7 +183,7 @@ public static class UserMe { public UserMe(User user) { this.id = user.getId(); - this.sid = user.getSid(); + this.sid = user.getSidWithMasking(); this.name = user.getName(); this.email = user.getEmail(); } From eca3f0019d1822d2bb0aa383d451d71bf0639995 Mon Sep 17 00:00:00 2001 From: zionhann Date: Thu, 14 Sep 2023 02:09:25 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Fix:=20=EA=B7=B8=EB=A3=B9=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20=EB=B6=80=EC=97=AC=EC=8B=9C=20=EB=A0=88=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EA=B0=9C=EC=88=98=EA=B0=80=20=EC=95=84=EB=8B=8C=20?= =?UTF-8?q?=EC=B5=9C=EB=8C=93=EA=B0=92=EC=9D=84=20=EA=B8=B0=EC=A4=80?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#134)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handong/csee/histudy/repository/StudyGroupRepository.java | 3 +++ .../java/edu/handong/csee/histudy/service/TeamService.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/handong/csee/histudy/repository/StudyGroupRepository.java b/src/main/java/edu/handong/csee/histudy/repository/StudyGroupRepository.java index c75cf81..d6ea459 100644 --- a/src/main/java/edu/handong/csee/histudy/repository/StudyGroupRepository.java +++ b/src/main/java/edu/handong/csee/histudy/repository/StudyGroupRepository.java @@ -15,4 +15,7 @@ public interface StudyGroupRepository extends JpaRepository { @Modifying @Query("delete from StudyGroup s where s.tag = -1") void deleteEmptyGroup(); + + @Query("select max(s.tag) from StudyGroup s") + Optional countMaxTag(); } \ No newline at end of file diff --git a/src/main/java/edu/handong/csee/histudy/service/TeamService.java b/src/main/java/edu/handong/csee/histudy/service/TeamService.java index f54913d..497bfc2 100644 --- a/src/main/java/edu/handong/csee/histudy/service/TeamService.java +++ b/src/main/java/edu/handong/csee/histudy/service/TeamService.java @@ -74,7 +74,7 @@ public TeamRankDto getAllTeams() { public TeamDto.MatchResults matchTeam() { // Get users who are not in a team List users = userRepository.findUnassignedApplicants(); - int latestGroupTag = (int) studyGroupRepository.count(); + int latestGroupTag = studyGroupRepository.countMaxTag().orElse(0); AtomicInteger tag = new AtomicInteger(latestGroupTag + 1); // First matching From b385f02bf1a9b6908450afa9c22608f007acf355 Mon Sep 17 00:00:00 2001 From: zionhann Date: Thu, 14 Sep 2023 02:24:20 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Fix:=20=EB=82=B4=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=95=84=EC=9D=98=20=ED=95=99=EB=B2=88=EB=8F=84=20=EB=A7=88?= =?UTF-8?q?=EC=8A=A4=ED=82=B9=20=EB=90=98=EB=8A=94=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#134)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../histudy/controller/TeamController.java | 2 +- .../edu/handong/csee/histudy/dto/UserDto.java | 24 ++++++++++++++++++- .../csee/histudy/service/TeamService.java | 18 +++++++------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/handong/csee/histudy/controller/TeamController.java b/src/main/java/edu/handong/csee/histudy/controller/TeamController.java index c9b866e..143ee9e 100644 --- a/src/main/java/edu/handong/csee/histudy/controller/TeamController.java +++ b/src/main/java/edu/handong/csee/histudy/controller/TeamController.java @@ -117,7 +117,7 @@ public ResponseEntity getTeamCourses( @Operation(summary = "그룹 팀원 목록 조회") @GetMapping("/users") - public ResponseEntity> getTeamUsers( + public ResponseEntity> getTeamUsers( @RequestAttribute Claims claims) { if (Role.isAuthorized(claims, Role.MEMBER)) { return ResponseEntity.ok(teamService.getTeamUsers(claims.getSubject())); diff --git a/src/main/java/edu/handong/csee/histudy/dto/UserDto.java b/src/main/java/edu/handong/csee/histudy/dto/UserDto.java index 1211b78..47fd13c 100644 --- a/src/main/java/edu/handong/csee/histudy/dto/UserDto.java +++ b/src/main/java/edu/handong/csee/histudy/dto/UserDto.java @@ -183,11 +183,33 @@ public static class UserMe { public UserMe(User user) { this.id = user.getId(); - this.sid = user.getSidWithMasking(); + this.sid = user.getSid(); this.name = user.getName(); this.email = user.getEmail(); } + } + + @Getter + @NoArgsConstructor(access = AccessLevel.PRIVATE) + public static class UserMeWithMasking extends UserMe { + @Schema(description = "User ID", example = "1", type = "number") + private Long id; + + @Schema(description = "User name", example = "John Doe") + private String name; + @Schema(description = "User student ID", example = "223****4") + private String sid; + + @Schema(description = "User email", example = "user@test.com") + private String email; + + public UserMeWithMasking(User user) { + this.id = user.getId(); + this.sid = user.getSidWithMasking(); + this.name = user.getName(); + this.email = user.getEmail(); + } } @Builder diff --git a/src/main/java/edu/handong/csee/histudy/service/TeamService.java b/src/main/java/edu/handong/csee/histudy/service/TeamService.java index 497bfc2..b2cc5d0 100644 --- a/src/main/java/edu/handong/csee/histudy/service/TeamService.java +++ b/src/main/java/edu/handong/csee/histudy/service/TeamService.java @@ -2,6 +2,7 @@ import edu.handong.csee.histudy.domain.*; import edu.handong.csee.histudy.dto.*; +import edu.handong.csee.histudy.exception.UserNotFoundException; import edu.handong.csee.histudy.repository.StudyGroupRepository; import edu.handong.csee.histudy.repository.UserRepository; import lombok.RequiredArgsConstructor; @@ -52,14 +53,15 @@ public TeamReportDto getTeamReports(long id, String email) { return new TeamReportDto(studyGroup.getId(), users, studyGroup.getTotalMinutes(), reports); } - public List getTeamUsers(String email) { - User user = userRepository.findUserByEmail(email).orElseThrow(); - if (user.getStudyGroup() != null) { - return user.getStudyGroup().getMembers() - .stream() - .map(UserDto.UserMe::new) - .toList(); - } else return Collections.emptyList(); + public List getTeamUsers(String email) { + User user = userRepository.findUserByEmail(email) + .orElseThrow(UserNotFoundException::new); + + return user.getStudyGroup() + .getMembers() + .stream() + .map(UserDto.UserMeWithMasking::new) + .toList(); } public TeamRankDto getAllTeams() {