Skip to content

Commit

Permalink
Merge pull request #183 from lemonssoju/fix/122-getGroupProfile
Browse files Browse the repository at this point in the history
[fix/122-getGroupProfile] 그룹 프로필 조회 시 현재 멤버만 조회하도록 수정
  • Loading branch information
JoongHyun-Kim committed Jun 5, 2024
2 parents cfc4c7f + ac15923 commit 9d50c4d
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ private String calculateRecentUpdate(Team group) {
// 그룹 프로필 조회
public BaseResponse<GroupProfileResponse> getGroupProfile(Long groupIdx) {
Team group = groupRepository.findById(groupIdx).orElseThrow(() -> new BaseException(INVALID_GROUP_IDX));
List<String> memberImageList = group.getUserTeams().stream()
.map(userTeam -> userTeam.getUser().getProfile().getProfileImage())
.limit(3)
.toList();
// List<String> memberImageList = group.getUserTeams().stream()
// .map(userTeam -> userTeam.getUser().getProfile().getProfileImage())
// .limit(3).toList();

Integer puzzleCount = puzzleRepository.countByTeam(group);

Expand All @@ -101,11 +100,23 @@ public BaseResponse<GroupProfileResponse> getGroupProfile(Long groupIdx) {

long dayCount = ChronoUnit.DAYS.between(startLocalDate, today);

GroupProfileResponse profile = new GroupProfileResponse(group.getName(), group.getAdmin().getProfile().getNickname(), group.getStartDate().getYear(), memberImageList,
GroupProfileResponse profile = new GroupProfileResponse(group.getName(), group.getAdmin().getProfile().getNickname(), group.getStartDate().getYear(), getMemberImageList(group),
group.getUserTeams().size(), puzzleCount, dayCount);
return new BaseResponse<>(profile);
}

private List<String> getMemberImageList(Team group) {
List<String> imageList = new ArrayList<>();
imageList.add(group.getAdmin().getProfile().getProfileImage());

List<String> memberImages = group.getUserTeams().stream()
.filter(userTeam -> "active".equals(userTeam.getStatus()))
.map(userTeam -> userTeam.getUser().getProfile().getProfileImage())
.limit(2).toList();
imageList.addAll(memberImages);
return imageList;
}


// [관리자] 그룹 수정 화면 조회
public BaseResponse<GroupEditViewResponse> getGroupEditView(Long groupIdx) {
Expand Down Expand Up @@ -188,8 +199,8 @@ public BaseResponse<String> withdrawGroup(Long groupIdx) {

UserTeam userTeam = validateMember(user, group);
userTeam.delete();
userTeam.removeTeam(group);
userTeam.removeUser(user);
//userTeam.removeTeam(group);
//userTeam.removeUser(user);
userTeamRepository.save(userTeam);

return new BaseResponse<>(SUCCESS);
Expand Down

0 comments on commit 9d50c4d

Please sign in to comment.