Skip to content

Commit

Permalink
Merge pull request #185 from Modagbul/main
Browse files Browse the repository at this point in the history
[release] 존재하지 않은 팀일 때 오류 처리
  • Loading branch information
minsu20 authored Jan 3, 2024
2 parents e9e0f5e + d1144a9 commit 88819b9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .deploy/deploy_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sleep 40
EXIST_AFTER=$(docker ps --filter name=${DOCKER_APP_NAME}-${AFTER_COMPOSE_COLOR} --filter status=running -q)
if [ -n "$EXIST_AFTER" ]; then
# nginx.config를 컨테이너에 맞게 변경해주고 reload 한다
cp ./nginx.${AFTER_COMPOSE_COLOR}.conf /etc/nginx/nginx.conf
sudo cp ./nginx.${AFTER_COMPOSE_COLOR}.conf /etc/nginx/nginx.conf
sudo nginx -s reload

# 이전 컨테이너 종료
Expand Down
114 changes: 0 additions & 114 deletions .github/workflows/ci-cd.yml

This file was deleted.

16 changes: 0 additions & 16 deletions Dockerfile

This file was deleted.

67 changes: 0 additions & 67 deletions deploy.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SignInTeamUseCase {
private final TeamMemberSaveService teamMemberSaveService;
public CreateTeamResponse signInTeam(String socialId, Long teamId){
Member member=memberGetService.getMemberBySocialId(socialId);
Team team=teamGetService.getTeamByTeamId(teamId);
Team team=teamGetService.getTeamIncludeDeletedByTeamId(teamId);
teamMemberSaveService.addTeamMember(team, member);
return new CreateTeamResponse(team.getTeamId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public interface TeamCustomRepository {
GetTeamResponse findTeamByMemberId(Long memberId);
Optional<Team> findTeamByTeamId(Long TeamId);
Optional<Team> findTeamIncludeDeletedByTeamId(Long teamId);
List<Long> findTeamIdByMemberId(Long memberId);
List<GetMyPageTeamBlock> findMyPageTeamByMemberId(Long memberId);
List<MyTeamsRes> findTeamNameByTeamId(List<Long> teamId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public Optional<Team> findTeamByTeamId(Long teamId) {
.fetchOne());
}

@Override
public Optional<Team> findTeamIncludeDeletedByTeamId(Long teamId){
return Optional.ofNullable(queryFactory.selectFrom(team)
.where(team.teamId.eq(teamId))
.fetchOne());
}

@Override
public List<Long> findTeamIdByMemberId(Long memberId){
LocalDateTime threeDaysAgo = LocalDateTime.now().minusDays(3);
Expand Down Expand Up @@ -181,7 +188,7 @@ public Page<GetNewTeamResponse> findNewTeam(String dateSort, Pageable pageable)
@Override
public GetTeamCountResponse findTeamCount(Long memberId, Long teamId) {
LocalDateTime threeDaysAgo = LocalDateTime.now().minusDays(3);
long count=queryFactory
Long count=queryFactory
.select(team.count()) // 팀의 개수를 세기 위해 수정
.from(teamMember)
.innerJoin(teamMember.team, team)
Expand All @@ -192,14 +199,24 @@ public GetTeamCountResponse findTeamCount(Long memberId, Long teamId) {
.or(team.deletionTime.after(threeDaysAgo)))) // 강제종료된 경우 3일이 지나지 않았다면
.fetchOne(); // 단일 결과 (개수) 반환

if (count == null) {
count = 0L; // null인 경우 0으로 처리
}

GetTeamCountResponse response=queryFactory
.select(new QGetTeamCountResponse(team.name, member.nickName))
.from(team)
.join(member).on(team.leaderId.eq(member.memberId))
.where(team.teamId.eq(teamId))
.fetchOne();

response.updateCount(count);
if (response == null) {
// response가 null인 경우, 적절한 기본값 설정 또는 예외 처리
response = new GetTeamCountResponse("기본 팀 이름", "기본 멤버 닉네임");
response.updateCount(0L);
} else {
response.updateCount(count);
}

return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public List<Long> getTeamIdByMemberId(Long memberId) {
return teamRepository.findTeamIdByMemberId(memberId);
}

public Team getTeamIncludeDeletedByTeamId(Long teamId){
return teamRepository.findTeamIncludeDeletedByTeamId(teamId).orElseThrow(NotFoundByTeamIdException::new);
}

public Team getTeamByTeamId(Long teamId){
return teamRepository.findTeamByTeamId(teamId).orElseThrow(NotFoundByTeamIdException::new);
}
Expand Down

0 comments on commit 88819b9

Please sign in to comment.