Skip to content

Commit

Permalink
feat(suggestion): change the suggestion function during the pre-sched…
Browse files Browse the repository at this point in the history
…uled period
  • Loading branch information
Chaerim1001 committed Sep 22, 2023
1 parent 5ea9036 commit 159f97e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public class SuggestionController {
@GetMapping
public ResponseDto<List<SuggestionResponseDto>> readSuggestion(@MemberId Long memberId) {
LocalDateTime requestTime = LocalDateTime.now();
List<SuggestionResponseDto> response = suggestionService.readSuggestion(memberId,
// List<SuggestionResponseDto> response = suggestionService.readSuggestion(memberId, requestTime);
// 사전 예약 카드 노출
List<SuggestionResponseDto> response = suggestionService.tempSuggestion(memberId,
requestTime);

return ResponseDto.success("Get Suggestion Success", response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ List<SuggestionTeamData> findSuggestionTeamForTeamLeader(Long memberId, int memb
* 추천 히스토리 팀 정보 조회
* */
List<SuggestionHistoryData> findSuggestionHistoryTeam(Long memberId, LocalDateTime requestTime);

// 사전 예약
List<SuggestionTeamData> findTempTeam(Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,34 @@ public List<SuggestionHistoryData> findSuggestionHistoryTeam(Long memberId,
)
.fetch();
}

@Override
public List<SuggestionTeamData> findTempTeam(Long memberId) {
List<Long> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ public interface SuggestionService {
* */
List<SuggestionResponseDto> readSuggestion(Long memberId, LocalDateTime requestTime);


/*
* 오늘의 추천 여부 확인
* */
CheckSuggestionResponseDto checkTodaySuggestionHistory(Long memberId,
LocalDateTime requestTime);

/*
* 사전 예약 정보 노출
* */
List<SuggestionResponseDto> tempSuggestion(Long memberId, LocalDateTime requestTime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ public List<SuggestionResponseDto> readSuggestion(Long memberId, LocalDateTime r
return SuggestionResponseDto.of(suggestionTeamList);
}

@Transactional
@Override
public List<SuggestionResponseDto> tempSuggestion(Long memberId, LocalDateTime requestTime) {
Member member = memberRepository.findByMemberId(memberId)
.orElseThrow(MemberNotFoundException::new)
.checkMemberValid();

// 이미 추천을 받은 경우
if (!teamRepository.findHistory(memberId, requestTime).isEmpty()) {
throw new SuggestionHistoryExistsException();
}

List<SuggestionTeamData> suggestionTeamList = teamRepository.findTempTeam(
member.getMemberId());
saveHistory(suggestionTeamList, member);

return SuggestionResponseDto.of(suggestionTeamList);
}


@Transactional(readOnly = true)
@Override
public CheckSuggestionResponseDto checkTodaySuggestionHistory(Long memberId,
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/sub
Submodule sub updated from e8c223 to 7e420e

0 comments on commit 159f97e

Please sign in to comment.