Skip to content

Commit

Permalink
Merge pull request #162 from WE-ARE-RACCOONS/RAC-304
Browse files Browse the repository at this point in the history
RAC-304 hotFix : 토큰 없이 μ„ λ°° μƒμ„Έμ‘°νšŒ μ•ˆλ˜λŠ” 였λ₯˜ ν•΄κ²°
  • Loading branch information
ywj9811 authored Mar 6, 2024
2 parents 20e367b + 8a4ebdf commit 60d02c3
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ public class SeniorInfoUseCase {
private final AvailableGetService availableGetService;

public SeniorDetailResponse getSeniorDetail(User user, Long seniorId) {
if (user != null)
return checkIsMine(user, seniorId);
return getResponse(seniorId, false);
}

private SeniorDetailResponse checkIsMine(User user, Long seniorId) {
Senior mySenior = seniorGetService.byUser(user);
if (mySenior.getSeniorId().equals(seniorId))
return getResponse(mySenior, true);
Senior senior = seniorGetService.bySeniorIdWithCertification(seniorId);
return getResponse(senior, false);
return getResponseMine(mySenior, true);
return getResponse(seniorId, false);
}

private SeniorDetailResponse getResponse(Senior senior, boolean isMine) {
private SeniorDetailResponse getResponse(Long seniorId, boolean isMine) {
Senior senior = seniorGetService.bySeniorIdWithCertification(seniorId);
seniorUpdateService.updateHit(senior);
List<Available> availables = availableGetService.bySenior(senior);
List<AvailableTimeResponse> times = availables.stream()
Expand All @@ -46,6 +52,14 @@ private SeniorDetailResponse getResponse(Senior senior, boolean isMine) {
return mapToSeniorDetail(senior, times, isMine);
}

private SeniorDetailResponse getResponseMine(Senior senior, boolean isMine) {
List<Available> availables = availableGetService.bySenior(senior);
List<AvailableTimeResponse> times = availables.stream()
.map(AvailableMapper::mapToAvailableTimes)
.toList();
return mapToSeniorDetail(senior, times, isMine);
}

public AllSeniorSearchResponse getSearchSenior(String search, Integer page, String sort) {
Page<Senior> seniors = seniorGetService.bySearch(search, page, sort);
List<SeniorSearchResponse> selectSeniors = seniors.stream()
Expand Down

0 comments on commit 60d02c3

Please sign in to comment.