Skip to content

Commit 88819b9

Browse files
authored
Merge pull request #185 from Modagbul/main
[release] 존재하지 않은 팀일 때 오류 처리
2 parents e9e0f5e + d1144a9 commit 88819b9

File tree

8 files changed

+26
-201
lines changed

8 files changed

+26
-201
lines changed

.deploy/deploy_prod.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ sleep 40
5252
EXIST_AFTER=$(docker ps --filter name=${DOCKER_APP_NAME}-${AFTER_COMPOSE_COLOR} --filter status=running -q)
5353
if [ -n "$EXIST_AFTER" ]; then
5454
# nginx.config를 컨테이너에 맞게 변경해주고 reload 한다
55-
cp ./nginx.${AFTER_COMPOSE_COLOR}.conf /etc/nginx/nginx.conf
55+
sudo cp ./nginx.${AFTER_COMPOSE_COLOR}.conf /etc/nginx/nginx.conf
5656
sudo nginx -s reload
5757

5858
# 이전 컨테이너 종료

.github/workflows/ci-cd.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

deploy.sh

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/main/java/com/moing/backend/domain/team/application/service/SignInTeamUseCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class SignInTeamUseCase {
2222
private final TeamMemberSaveService teamMemberSaveService;
2323
public CreateTeamResponse signInTeam(String socialId, Long teamId){
2424
Member member=memberGetService.getMemberBySocialId(socialId);
25-
Team team=teamGetService.getTeamByTeamId(teamId);
25+
Team team=teamGetService.getTeamIncludeDeletedByTeamId(teamId);
2626
teamMemberSaveService.addTeamMember(team, member);
2727
return new CreateTeamResponse(team.getTeamId());
2828
}

src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
public interface TeamCustomRepository {
1717
GetTeamResponse findTeamByMemberId(Long memberId);
1818
Optional<Team> findTeamByTeamId(Long TeamId);
19+
Optional<Team> findTeamIncludeDeletedByTeamId(Long teamId);
1920
List<Long> findTeamIdByMemberId(Long memberId);
2021
List<GetMyPageTeamBlock> findMyPageTeamByMemberId(Long memberId);
2122
List<MyTeamsRes> findTeamNameByTeamId(List<Long> teamId);

src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public Optional<Team> findTeamByTeamId(Long teamId) {
4949
.fetchOne());
5050
}
5151

52+
@Override
53+
public Optional<Team> findTeamIncludeDeletedByTeamId(Long teamId){
54+
return Optional.ofNullable(queryFactory.selectFrom(team)
55+
.where(team.teamId.eq(teamId))
56+
.fetchOne());
57+
}
58+
5259
@Override
5360
public List<Long> findTeamIdByMemberId(Long memberId){
5461
LocalDateTime threeDaysAgo = LocalDateTime.now().minusDays(3);
@@ -181,7 +188,7 @@ public Page<GetNewTeamResponse> findNewTeam(String dateSort, Pageable pageable)
181188
@Override
182189
public GetTeamCountResponse findTeamCount(Long memberId, Long teamId) {
183190
LocalDateTime threeDaysAgo = LocalDateTime.now().minusDays(3);
184-
long count=queryFactory
191+
Long count=queryFactory
185192
.select(team.count()) // 팀의 개수를 세기 위해 수정
186193
.from(teamMember)
187194
.innerJoin(teamMember.team, team)
@@ -192,14 +199,24 @@ public GetTeamCountResponse findTeamCount(Long memberId, Long teamId) {
192199
.or(team.deletionTime.after(threeDaysAgo)))) // 강제종료된 경우 3일이 지나지 않았다면
193200
.fetchOne(); // 단일 결과 (개수) 반환
194201

202+
if (count == null) {
203+
count = 0L; // null인 경우 0으로 처리
204+
}
205+
195206
GetTeamCountResponse response=queryFactory
196207
.select(new QGetTeamCountResponse(team.name, member.nickName))
197208
.from(team)
198209
.join(member).on(team.leaderId.eq(member.memberId))
199210
.where(team.teamId.eq(teamId))
200211
.fetchOne();
201212

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

204221
return response;
205222
}

src/main/java/com/moing/backend/domain/team/domain/service/TeamGetService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public List<Long> getTeamIdByMemberId(Long memberId) {
3434
return teamRepository.findTeamIdByMemberId(memberId);
3535
}
3636

37+
public Team getTeamIncludeDeletedByTeamId(Long teamId){
38+
return teamRepository.findTeamIncludeDeletedByTeamId(teamId).orElseThrow(NotFoundByTeamIdException::new);
39+
}
40+
3741
public Team getTeamByTeamId(Long teamId){
3842
return teamRepository.findTeamByTeamId(teamId).orElseThrow(NotFoundByTeamIdException::new);
3943
}

0 commit comments

Comments
 (0)