diff --git a/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java index 001ea28d..699ec33b 100644 --- a/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/team/domain/repository/TeamCustomRepositoryImpl.java @@ -8,6 +8,7 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; +import com.querydsl.jpa.impl.JPAUpdateClause; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.support.PageableExecutionUtils; @@ -94,6 +95,7 @@ private List getTeamBlock(Long memberId) { .from(teamMember) .innerJoin(teamMember.team, team) .on(teamMember.member.memberId.eq(memberId)) + .where(team.approvalStatus.eq(ApprovalStatus.APPROVAL)) // 승인 되었고 .where(teamMember.isDeleted.eq(false)// 탈퇴하지 않았다면 .and(team.isDeleted.eq(false) // 강제종료되지 않았거나 .or(team.deletionTime.after(threeDaysAgo))))// 강제종료된 경우 3일이 지나지 않았다면 @@ -115,15 +117,21 @@ public List findTeamNameByTeamId(List teamId) { @Override public void updateTeamStatus(boolean isApproved, List teamIds) { - ApprovalStatus approvalStatus = ApprovalStatus.REJECTION; + ApprovalStatus approvalStatus = isApproved ? ApprovalStatus.APPROVAL : ApprovalStatus.REJECTION; + + JPAUpdateClause updateClause = queryFactory + .update(team) + .set(team.approvalStatus, approvalStatus); + + // 승인되었을 때만 현재 시간으로 approvalTime 설정 if (isApproved) { - approvalStatus = ApprovalStatus.APPROVAL; + updateClause.set(team.approvalTime, LocalDateTime.now()); } - queryFactory - .update(team) - .set(team.approvalStatus, approvalStatus) + + updateClause .where(team.teamId.in(teamIds)) .execute(); + em.flush(); em.clear(); } diff --git a/src/main/java/com/moing/backend/domain/team/presentation/constant/TeamResponseMessage.java b/src/main/java/com/moing/backend/domain/team/presentation/constant/TeamResponseMessage.java index 6107598d..55dca2b6 100644 --- a/src/main/java/com/moing/backend/domain/team/presentation/constant/TeamResponseMessage.java +++ b/src/main/java/com/moing/backend/domain/team/presentation/constant/TeamResponseMessage.java @@ -15,7 +15,7 @@ public enum TeamResponseMessage { DISBAND_TEAM_SUCCESS("[소모임장 권한] 소모임을 강제 종료했습니다."), UPDATE_TEAM_SUCCESS("[소모임장 권한] 소모임을 수정했습니다"), WITHDRAW_TEAM_SUCCESS("[소모임원 권한] 소모임을 탈퇴하였습니다"), - SEND_APPROVAL_ALARM_SUCCESS("소모임들이 승인되었습니다.."), + SEND_APPROVAL_ALARM_SUCCESS("소모임들이 승인되었습니다."), SEND_REJECTION_ALARM_SUCCESS("소모임들이 반려되었습니다."), GET_NEW_TEAM_SUCCESS("새로운 소모임들을 조회했습니다."); private final String message;