Skip to content

Commit

Permalink
Merge pull request #248 from Modagbul/main
Browse files Browse the repository at this point in the history
[release] MNG-15
  • Loading branch information
minsu20 authored Feb 12, 2024
2 parents 00a21a2 + 73d2079 commit 06740bd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moing.backend.domain.fire.domain.repository;

import com.moing.backend.domain.block.domain.repository.BlockRepositoryUtils;
import com.moing.backend.domain.fire.application.dto.res.FireReceiveRes;
import com.moing.backend.domain.mission.domain.entity.constant.MissionType;
import com.querydsl.core.types.Projections;
Expand Down Expand Up @@ -52,6 +53,8 @@ public Optional<List<FireReceiveRes>> getFireReceivers(Long teamId, Long mission

JPQLQuery<Long> completedMembersOfAll = allMissionDone(missionId);

BooleanExpression blockCondition= BlockRepositoryUtils.blockCondition(memberId, teamMember.member.memberId);

return Optional.ofNullable(queryFactory
.select(Projections.constructor(FireReceiveRes.class,
teamMember.member.memberId,
Expand All @@ -64,7 +67,8 @@ public Optional<List<FireReceiveRes>> getFireReceivers(Long teamId, Long mission
teamMember.member.memberId.ne(memberId),
teamMember.member.memberId.notIn(completedMembersOfAll)
.and(teamMember.member.memberId.notIn(todayCompletedMemberOfRepeat)),
teamMember.isDeleted.ne(Boolean.TRUE)
teamMember.isDeleted.ne(Boolean.TRUE),
blockCondition
)
.fetch());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package com.moing.backend.domain.missionArchive.domain.repository;

import com.moing.backend.domain.board.application.dto.response.BoardBlocks;
import com.moing.backend.domain.block.domain.repository.BlockRepositoryUtils;
import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.mission.application.dto.res.FinishMissionBoardRes;
import com.moing.backend.domain.mission.application.dto.res.RepeatMissionBoardRes;
import com.moing.backend.domain.mission.application.dto.res.SingleMissionBoardRes;
import com.moing.backend.domain.mission.domain.entity.QMission;
import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus;
import com.moing.backend.domain.mission.domain.entity.constant.MissionType;
import com.moing.backend.domain.mission.domain.entity.constant.MissionWay;
import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchivePhotoRes;
import com.moing.backend.domain.missionArchive.application.dto.res.MyArchiveStatus;
import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive;
import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus;
import com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive;
import com.moing.backend.domain.missionRead.domain.entity.QMissionRead;
import com.moing.backend.domain.missionRead.domain.repository.MissionReadRepositoryUtils;
import com.moing.backend.domain.team.domain.entity.QTeam;
import com.moing.backend.domain.teamMember.domain.entity.QTeamMember;
import com.querydsl.core.Tuple;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Order;
Expand All @@ -27,14 +22,10 @@
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import feign.Param;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.jpa.repository.Query;

import javax.persistence.EntityManager;
import javax.swing.text.html.Option;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -43,18 +34,10 @@
import java.util.List;
import java.util.Optional;

import static com.moing.backend.domain.board.domain.entity.QBoard.board;
import static com.moing.backend.domain.boardRead.domain.entity.QBoardRead.boardRead;
import static com.moing.backend.domain.member.domain.entity.QMember.member;
import static com.moing.backend.domain.mission.domain.entity.QMission.mission;
import static com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive.*;
import static com.moing.backend.domain.missionRead.domain.entity.QMissionRead.missionRead;
import static com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive.missionArchive;
import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState;
import static com.moing.backend.domain.team.domain.entity.QTeam.team;
import static com.moing.backend.domain.teamMember.domain.entity.QTeamMember.teamMember;
import static javax.swing.Spring.constant;
import static org.springframework.data.jpa.domain.Specification.not;
import static org.springframework.data.jpa.domain.Specification.where;

@Slf4j
public class MissionArchiveCustomRepositoryImpl implements MissionArchiveCustomRepository {
Expand Down Expand Up @@ -192,13 +175,16 @@ public Optional<List<MissionArchive>> findOthersArchives(Long memberId, Long mis

BooleanExpression dateInRange = createRepeatTypeConditionByArchive();

BooleanExpression blockCondition= BlockRepositoryUtils.blockCondition(memberId, missionArchive.member.memberId);

return Optional.ofNullable(queryFactory
.select(missionArchive)
.from(missionArchive)
.where(
missionArchive.mission.id.eq(missionId),
missionArchive.member.memberId.ne(memberId),
missionArchive.status.eq(MissionArchiveStatus.COMPLETE).or(missionArchive.status.eq(MissionArchiveStatus.SKIP)),
blockCondition,
(missionArchive.mission.type.eq(MissionType.REPEAT)
.and(missionArchive.mission.status.eq(MissionStatus.ONGOING)).and(dateInRange))
.or(missionArchive.mission.type.eq(MissionType.REPEAT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public GetTeamResponse getTeam(String socialId) {
public GetTeamDetailResponse getTeamDetailResponse(String socialId, Long teamId) {
Member member = memberGetService.getMemberBySocialId(socialId);
Integer boardNum = boardGetService.getUnReadBoardNum(teamId, member.getMemberId());
List<TeamMemberInfo> teamMemberInfoList = teamMemberGetService.getTeamMemberInfo(teamId);
List<TeamMemberInfo> teamMemberInfoList = teamMemberGetService.getTeamMemberInfo(member.getMemberId(), teamId);
Team team = teamGetService.getTeamByTeamId(teamId);
return TeamMapper.toTeamDetailResponse(member.getMemberId(), team, boardNum, teamMemberInfoList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

public interface TeamMemberCustomRepository {
Optional<List<NewUploadInfo>> findNewUploadInfo(Long teamId, Long memberId);
List<TeamMemberInfo> findTeamMemberInfoByTeamId(Long teamId);
List<TeamMemberInfo> findTeamMemberInfoByTeamId(Long memberId, Long teamId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public Optional<List<NewUploadInfo>> findNewUploadInfo(Long teamId, Long memberI
}

@Override
public List<TeamMemberInfo> findTeamMemberInfoByTeamId(Long teamId){
public List<TeamMemberInfo> findTeamMemberInfoByTeamId(Long memberId, Long teamId){

BooleanExpression blockCondition= BlockRepositoryUtils.blockCondition(memberId, teamMember.member.memberId);


return queryFactory
.select(new QTeamMemberInfo(
teamMember.member.memberId,
Expand All @@ -53,7 +57,8 @@ public List<TeamMemberInfo> findTeamMemberInfoByTeamId(Long teamId){
.from(teamMember)
.innerJoin(teamMember.team, team) // innerJoin을 사용하여 최적화
.where(teamMember.team.teamId.eq(teamId) // where 절을 하나로 합침
.and(teamMember.isDeleted.eq(false)))
.and(teamMember.isDeleted.eq(false))
.and(blockCondition))
.groupBy(teamMember.member.memberId)
.fetch();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public TeamMember getTeamMemberNotDeleted(Member member, Team team) {
}


public List<TeamMemberInfo> getTeamMemberInfo(Long teamId){
return teamMemberRepository.findTeamMemberInfoByTeamId(teamId);
public List<TeamMemberInfo> getTeamMemberInfo(Long memberId, Long teamId){
return teamMemberRepository.findTeamMemberInfoByTeamId(memberId, teamId);
}

public Optional<List<NewUploadInfo>> getNewUploadInfo(Long teamId, Long memberId) {
Expand Down

0 comments on commit 06740bd

Please sign in to comment.