Skip to content

Commit

Permalink
Feature/issues with mashong days (#451)
Browse files Browse the repository at this point in the history
* add with mashong days

* add with mashong days

---------

Co-authored-by: jongmin.jung <jongmin.jung@navercorp.com>
  • Loading branch information
alertjjm and jongmin.jung authored Jul 27, 2024
1 parent 7d7ee9b commit 8290dfc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

@Service
@RequiredArgsConstructor
public class MashongFacadeService {
Expand Down Expand Up @@ -149,4 +152,12 @@ public PlatformMashongStatusResponse readCurrentStatus(Long memberGenerationId)

return PlatformMashongStatusResponse.of(platformMashong, mashongPopcorn);
}

@Transactional(readOnly = true)
public Long withMashongDaysCount(Long memberGenerationId) {
LocalDate now = LocalDate.now();
MemberGeneration memberGeneration = memberService.findByMemberGenerationId(memberGenerationId);
LocalDate generationStartedAt = memberGeneration.getGeneration().getStartedAt();
return ChronoUnit.DAYS.between(generationStartedAt, now);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@ public ApiResponse<PlatformMashongStatusResponse> readStatus(@ApiIgnore MemberAu
PlatformMashongStatusResponse result = mashongFacadeService.readCurrentStatus(memberAuth.getMemberGenerationId());
return ApiResponse.success(result);
}

@ApiOperation(value = "매숑이와 함께한 날 Days count")
@GetMapping("/with-mashong-days")
public ApiResponse<Long> withMashongDays(@ApiIgnore MemberAuth memberAuth) {
Long withMashongDays = mashongFacadeService.withMashongDaysCount(memberAuth.getMemberGenerationId());
return ApiResponse.success(withMashongDays);
}
}

0 comments on commit 8290dfc

Please sign in to comment.