Skip to content

Commit

Permalink
Merge pull request #189 from Codiary-UMC-6th/fix/#187-team-admin-profโ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆile-update

Fix: ํŒ€ ํŒ”๋กœ์šฐ ๋ฐ ํ”„๋กœํ•„ ์ˆ˜์ • ๊ถŒํ•œ ๋ถ„๋ฆฌ ๋กœ์ง ์ˆ˜์ •
  • Loading branch information
insa658723 authored Aug 20, 2024
2 parents 9746806 + 5d5c4d6 commit 3ebe500
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static TeamResponseDTO.CreateTeamResponseDTO toCreateMemberDTO(Team team)
}

//ํŒ€ ์กฐํšŒ
public static TeamResponseDTO.TeamCheckResponseDTO toTeamCheckResponseDTO(Team team) {
public static TeamResponseDTO.TeamCheckResponseDTO toTeamCheckResponseDTO(Team team, boolean isAdmin) {
List<TeamMemberResponseDTO.TeamMemberDTO> members = team.getTeamMemberList().stream()
.map(TeamMemberConverter::toTeamMemberDTO)
.collect(Collectors.toList());
Expand All @@ -46,6 +46,7 @@ public static TeamResponseDTO.TeamCheckResponseDTO toTeamCheckResponseDTO(Team t
.email(team.getEmail())
.linkedIn(team.getLinkedin())
.members(members)
.isAdmin(isAdmin)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
import com.codiary.backend.global.domain.entity.Member;
import com.codiary.backend.global.domain.entity.Team;
import com.codiary.backend.global.domain.entity.TeamFollow;
import com.codiary.backend.global.repository.TeamBannerImageRepository;
import com.codiary.backend.global.repository.TeamFollowRepository;
import com.codiary.backend.global.repository.TeamProfileImageRepository;
import com.codiary.backend.global.domain.enums.MemberRole;
import com.codiary.backend.global.jwt.SecurityUtil;
import com.codiary.backend.global.repository.*;
import com.codiary.backend.global.converter.TeamConverter;
import com.codiary.backend.global.domain.entity.Team;
import com.codiary.backend.global.repository.TeamRepository;
import com.codiary.backend.global.web.dto.Team.TeamResponseDTO;
import lombok.RequiredArgsConstructor;
import org.hibernate.Hibernate;
Expand All @@ -29,6 +28,7 @@ public class TeamQueryServiceImpl implements TeamQueryService {
private final TeamRepository teamRepository;
private final TeamFollowService teamFollowService;
private final TeamFollowRepository teamFollowRepository;
private final MemberRepository memberRepository;

@Override
public ApiResponse<TeamResponseDTO.TeamImageDTO> getBannerImage(Long teamId) {
Expand Down Expand Up @@ -60,8 +60,22 @@ public TeamResponseDTO.TeamCheckResponseDTO getTeamById(Long teamId) {
Team team = teamRepository.findById(teamId)
.orElseThrow(() -> new IllegalArgumentException("Invalid team ID"));

Member currentMember = getRequester();

boolean isAdmin = team.getTeamMemberList().stream()
.anyMatch(teamMember ->
teamMember.getMember().getMemberId().equals(currentMember.getMemberId()) &&
teamMember.getTeamMemberRole() == MemberRole.ADMIN
);

team.getTeamMemberList().size();
return TeamConverter.toTeamCheckResponseDTO(team);
return TeamConverter.toTeamCheckResponseDTO(team, isAdmin);
}

private Member getRequester() {
String userEmail = SecurityUtil.getCurrentMemberEmail(); // ํ˜„์žฌ ์‚ฌ์šฉ์ž์˜ ์ด๋ฉ”์ผ์„ ๊ฐ€์ ธ์˜ด
return memberRepository.findByEmail(userEmail)
.orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_FOUND));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public static class TeamCheckResponseDTO { // ํŒ€ ์กฐํšŒ
String email;
String linkedIn;
private List<TeamMemberResponseDTO.TeamMemberDTO> members; // ํŒ€์› ๋ชฉ๋ก ์ถ”๊ฐ€
// ํŒ€ ํŒ”๋กœ์šฐ ์ •๋ณด๋ฅผ ์ถ”๊ฐ€
private TeamFollowResponseDto followInfo;
private Boolean isAdmin;
private TeamFollowResponseDto followInfo; // ํŒ€ ํŒ”๋กœ์šฐ ์ •๋ณด๋ฅผ ์ถ”๊ฐ€
}

@Getter
Expand Down

0 comments on commit 3ebe500

Please sign in to comment.