Skip to content

Commit

Permalink
fix : 불던지기 목록에서 로그인한 사용자 제외
Browse files Browse the repository at this point in the history
  • Loading branch information
seungueonn committed Nov 29, 2023
1 parent 629d6ca commit 1198e96
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package com.moing.backend.domain.fire.application.dto.res;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
@AllArgsConstructor
public class FireReceiveRes {

private Long receiveMemberId;
private String nickname;
private String fireStatus;

public FireReceiveRes(Long receiveMemberId, String nickname) {
this.receiveMemberId = receiveMemberId;
this.nickname = nickname;
}

public void updateFireStatus(boolean status) {
if (status)
this.fireStatus = "True";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public List<FireReceiveRes> getFireReceiveList(String userId,Long teamId, Long m
res -> res.updateFireStatus(fireQueryService.hasFireCreatedWithinOneHour(memberId,res.getReceiveMemberId())
));

if (!missionArchiveQueryService.isDone(memberId, missionId)) {
fireReceiveRes.add(0,FireReceiveRes.builder()
.receiveMemberId(memberId)
.nickname(member.getNickName())
.fireStatus("False")
.build());
}
// if (!missionArchiveQueryService.isDone(memberId, missionId)) {
// fireReceiveRes.add(0,FireReceiveRes.builder()
// .receiveMemberId(memberId)
// .nickname(member.getNickName())
// .fireStatus("False")
// .build());
// }

return fireReceiveRes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;

import javax.persistence.EntityManager;
Expand Down Expand Up @@ -51,42 +52,46 @@ public boolean hasFireCreatedWithinOneHour(Long throwMemberId, Long receiveMembe

public Optional<List<FireReceiveRes>> getFireReceivers(Long teamId, Long missionId, Long memberId) {

JPQLQuery<Long> missionDonePeople = select(missionArchive.member.memberId)
.from(missionArchive, mission)
.where(missionArchive.mission.id.eq(missionId),
mission.id.eq(missionId)
)
.groupBy(missionArchive.member.memberId,
missionArchive.mission.id,
missionArchive.count,
mission.number)
.having(
missionArchive.mission.id.eq(missionId),
missionArchive.count.max().goe(mission.number)
);

LocalDateTime oneHourAgo = LocalDateTime.now().minusHours(1); // 현재 시간에서 1시간을 뺀 시간

BooleanExpression oneHourStatus = JPAExpressions
.select()
.from(fire)
.where(
fire.throwMemberId.eq(memberId),
fire.receiveMemberId.eq(teamMember.member.memberId),
fire.receiveMemberId.notIn(missionDonePeople),
fire.createdDate.after(oneHourAgo) // createdDate가 oneHourAgo 이후인 데이터
)

.exists();


return Optional.ofNullable(queryFactory
.select(Projections.constructor(FireReceiveRes.class,
teamMember.member.memberId,
teamMember.member.nickName,
oneHourStatus
teamMember.member.nickName
// oneHourStatus.stringValue()
// teamMember.member.nickName
))
.from(teamMember)
.where(
teamMember.team.teamId.eq(teamId),
teamMember.member.memberId.notIn(
JPAExpressions
.select(missionArchive.member.memberId)
.from(missionArchive,mission)
.where(missionArchive.mission.id.eq(missionId),
mission.id.eq(missionId),
missionArchive.member.memberId.notIn(memberId))
.groupBy(missionArchive.member.memberId, missionArchive.mission.id,
missionArchive.count, mission.number)
.having(
missionArchive.mission.id.eq(missionId),
missionArchive.count.max().goe(mission.number)
)
)
teamMember.member.memberId.ne(memberId),
teamMember.member.memberId.notIn(missionDonePeople)
)
.fetch());

Expand Down

0 comments on commit 1198e96

Please sign in to comment.