Skip to content

Commit

Permalink
Fix : 최근 공지가 최대 5개를 반환하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
dlgocks1 committed Dec 3, 2023
1 parent ad7a7a6 commit a3222e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class NotificationController(
) {
@GetMapping("/latest")
@Operation(summary = "02-01 본인 기수 최신 공지 조회")
fun getThisWeekNotification(@AuthenticationPrincipal user: User): CommonResponse<NotificationRes.NotificationDto> {
fun getThisWeekNotification(@AuthenticationPrincipal user: User): CommonResponse<List<NotificationRes.NotificationDto>> {
return CommonResponse.onSuccess(notificationService.getThisWeekNotification(user))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class NotificationService(
private val generationWeekRepository: GenerationWeeksInfoRepository,
private val notificationConvertor: NotificationConvertor
) {
fun getThisWeekNotification(user: User): NotificationRes.NotificationDto {
fun getThisWeekNotification(user: User): List<NotificationRes.NotificationDto> {
val notification = notificationRepository.findAllByGenerationWeeksInfoGeneration(
user.nowGeneration, PageRequest.of(0, 1, Sort.by("createdAt").descending()),
user.nowGeneration, PageRequest.of(0, 5, Sort.by("createdAt").descending()),
)
return if (notification.isEmpty) {
throw NotFoundException(NotificationExceptionErrorCode.NOT_FOUND_LATEST_NOTIFICATION)
} else {
notificationConvertor.getNotification(notification.first())
notification.take(5).map(notificationConvertor::getNotification)
}
}

Expand Down

0 comments on commit a3222e3

Please sign in to comment.