Skip to content

Commit

Permalink
Release: v0.6.2 (#135)
Browse files Browse the repository at this point in the history
그룹 팀원 조회시 학번 마스킹
  • Loading branch information
zionhann authored Sep 13, 2023
2 parents 6fd65eb + b385f02 commit 7407655
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public ResponseEntity<CourseDto> getTeamCourses(

@Operation(summary = "그룹 팀원 목록 조회")
@GetMapping("/users")
public ResponseEntity<List<UserDto.UserMe>> getTeamUsers(
public ResponseEntity<List<UserDto.UserMeWithMasking>> getTeamUsers(
@RequestAttribute Claims claims) {
if (Role.isAuthorized(claims, Role.MEMBER)) {
return ResponseEntity.ok(teamService.getTeamUsers(claims.getSubject()));
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/edu/handong/csee/histudy/dto/UserDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,29 @@ public UserMe(User user) {
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 = "[email protected]")
private String email;

public UserMeWithMasking(User user) {
this.id = user.getId();
this.sid = user.getSidWithMasking();
this.name = user.getName();
this.email = user.getEmail();
}
}

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ public interface StudyGroupRepository extends JpaRepository<StudyGroup, Long> {
@Modifying
@Query("delete from StudyGroup s where s.tag = -1")
void deleteEmptyGroup();

@Query("select max(s.tag) from StudyGroup s")
Optional<Integer> countMaxTag();
}
20 changes: 11 additions & 9 deletions src/main/java/edu/handong/csee/histudy/service/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,14 +53,15 @@ public TeamReportDto getTeamReports(long id, String email) {
return new TeamReportDto(studyGroup.getId(), users, studyGroup.getTotalMinutes(), reports);
}

public List<UserDto.UserMe> 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<UserDto.UserMeWithMasking> getTeamUsers(String email) {
User user = userRepository.findUserByEmail(email)
.orElseThrow(UserNotFoundException::new);

return user.getStudyGroup()
.getMembers()
.stream()
.map(UserDto.UserMeWithMasking::new)
.toList();
}

public TeamRankDto getAllTeams() {
Expand All @@ -74,7 +76,7 @@ public TeamRankDto getAllTeams() {
public TeamDto.MatchResults matchTeam() {
// Get users who are not in a team
List<User> users = userRepository.findUnassignedApplicants();
int latestGroupTag = (int) studyGroupRepository.count();
int latestGroupTag = studyGroupRepository.countMaxTag().orElse(0);
AtomicInteger tag = new AtomicInteger(latestGroupTag + 1);

// First matching
Expand Down

0 comments on commit 7407655

Please sign in to comment.