diff --git a/src/main/java/com/e2i/wemeet/controller/suggestion/SuggestionController.java b/src/main/java/com/e2i/wemeet/controller/suggestion/SuggestionController.java index 2ea88651..832bb0b0 100644 --- a/src/main/java/com/e2i/wemeet/controller/suggestion/SuggestionController.java +++ b/src/main/java/com/e2i/wemeet/controller/suggestion/SuggestionController.java @@ -22,7 +22,9 @@ public class SuggestionController { @GetMapping public ResponseDto> readSuggestion(@MemberId Long memberId) { LocalDateTime requestTime = LocalDateTime.now(); - List response = suggestionService.readSuggestion(memberId, +// List response = suggestionService.readSuggestion(memberId, requestTime); + // 사전 예약 카드 노출 + List response = suggestionService.tempSuggestion(memberId, requestTime); return ResponseDto.success("Get Suggestion Success", response); diff --git a/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepository.java b/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepository.java index 99c80ea4..1c369bda 100644 --- a/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepository.java +++ b/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepository.java @@ -31,4 +31,7 @@ List findSuggestionTeamForTeamLeader(Long memberId, int memb * 추천 히스토리 팀 정보 조회 * */ List findSuggestionHistoryTeam(Long memberId, LocalDateTime requestTime); + + // 사전 예약 + List findTempTeam(Long memberId); } diff --git a/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepositoryImpl.java b/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepositoryImpl.java index 5c0e59f6..901572b3 100644 --- a/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepositoryImpl.java +++ b/src/main/java/com/e2i/wemeet/domain/team/suggestion/SuggestionRepositoryImpl.java @@ -137,4 +137,34 @@ public List findSuggestionHistoryTeam(Long memberId, ) .fetch(); } + + @Override + public List findTempTeam(Long memberId) { + List suggestionHistory = queryFactory + .select(history.team.teamId) + .from(history) + .where( + history.member.memberId.eq(memberId), + history.member.deletedAt.isNull() + ) + .fetch(); + + return queryFactory + .select(Projections.constructor(SuggestionTeamData.class, team, + teamImage.teamImageUrl.as("teamMainImageUrl"), + Projections.constructor(TeamLeaderData.class, member.nickname, member.mbti, + member.profileImage.lowUrl.as("profileImageUrl"), + member.collegeInfo.collegeCode.codeValue.as("college")) + ) + ) + .from(team) + .join(team.teamLeader, member).on(team.teamLeader.memberId.eq(member.memberId)) + .join(teamImage).on(teamImage.team.teamId.eq(team.teamId)) + .where( + team.deletedAt.isNull(), + team.teamId.eq(8L), + teamImage.sequence.eq(1) + ) + .fetch(); + } } diff --git a/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionService.java b/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionService.java index 21def0be..2ff0f7d1 100644 --- a/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionService.java +++ b/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionService.java @@ -12,9 +12,15 @@ public interface SuggestionService { * */ List readSuggestion(Long memberId, LocalDateTime requestTime); + /* * 오늘의 추천 여부 확인 * */ CheckSuggestionResponseDto checkTodaySuggestionHistory(Long memberId, LocalDateTime requestTime); + + /* + * 사전 예약 정보 노출 + * */ + List tempSuggestion(Long memberId, LocalDateTime requestTime); } diff --git a/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionServiceImpl.java b/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionServiceImpl.java index b809c9c0..95628b91 100644 --- a/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionServiceImpl.java +++ b/src/main/java/com/e2i/wemeet/service/suggestion/SuggestionServiceImpl.java @@ -45,6 +45,26 @@ public List readSuggestion(Long memberId, LocalDateTime r return SuggestionResponseDto.of(suggestionTeamList); } + @Transactional + @Override + public List tempSuggestion(Long memberId, LocalDateTime requestTime) { + Member member = memberRepository.findByMemberId(memberId) + .orElseThrow(MemberNotFoundException::new) + .checkMemberValid(); + + // 이미 추천을 받은 경우 + if (!teamRepository.findHistory(memberId, requestTime).isEmpty()) { + throw new SuggestionHistoryExistsException(); + } + + List suggestionTeamList = teamRepository.findTempTeam( + member.getMemberId()); + saveHistory(suggestionTeamList, member); + + return SuggestionResponseDto.of(suggestionTeamList); + } + + @Transactional(readOnly = true) @Override public CheckSuggestionResponseDto checkTodaySuggestionHistory(Long memberId, diff --git a/src/main/resources/sub b/src/main/resources/sub index e8c22317..7e420ee0 160000 --- a/src/main/resources/sub +++ b/src/main/resources/sub @@ -1 +1 @@ -Subproject commit e8c22317a866d326a296491fe48a13f31545c68d +Subproject commit 7e420ee0187b6bac4f588bfdf00f2a601d8c008a