Skip to content

Commit

Permalink
Merge pull request #86 from Modagbul/fix/auth
Browse files Browse the repository at this point in the history
소모임 조회 수정
  • Loading branch information
minsu20 authored Nov 26, 2023
2 parents 901d323 + 83ea384 commit a228f57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,6 +95,7 @@ private List<TeamBlock> 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일이 지나지 않았다면
Expand All @@ -115,15 +117,21 @@ public List<MyTeamsRes> findTeamNameByTeamId(List<Long> teamId) {

@Override
public void updateTeamStatus(boolean isApproved, List<Long> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a228f57

Please sign in to comment.