Skip to content

Commit

Permalink
[diary] show only 6 photos
Browse files Browse the repository at this point in the history
  • Loading branch information
Noverish committed May 19, 2024
1 parent 3c8b1a5 commit f665344
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kim.hyunsub.common.fs.client.PhotoServiceClient
import kim.hyunsub.common.model.ApiPageResult
import kim.hyunsub.common.model.LocalDateRange
import kim.hyunsub.diary.model.api.ApiDiary
import kim.hyunsub.diary.model.dto.DiaryPhotoSearchParams
import kim.hyunsub.diary.repository.mapper.DiaryMapper
import kim.hyunsub.diary.service.ApiDiaryService
import kim.hyunsub.photo.model.api.ApiPhotoPreview
Expand All @@ -24,12 +25,16 @@ class DiaryDetailBo(
return apiDiaryService.detail(token, diary)
}

fun photos(token: String, date: LocalDate, page: Int?): ApiPageResult<ApiPhotoPreview> {
val dateRange = LocalDateRange(
start = date,
end = date
fun photos(token: String, date: LocalDate, params: DiaryPhotoSearchParams): ApiPageResult<ApiPhotoPreview> {
val searchParams = PhotoSearchParams(
page = params.page,
asc = true,
dateRange = LocalDateRange(
start = date,
end = date,
),
)
val params = PhotoSearchParams(dateRange = dateRange)
return photoServiceClient.searchPhoto(token, params)

return photoServiceClient.searchPhoto(token, searchParams)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import kim.hyunsub.common.web.config.WebConstants
import kim.hyunsub.common.web.model.UserAuth
import kim.hyunsub.diary.bo.DiaryDetailBo
import kim.hyunsub.diary.model.api.ApiDiary
import kim.hyunsub.diary.model.dto.DiaryPhotoSearchParams
import kim.hyunsub.photo.model.api.ApiPhotoPreview
import org.springframework.web.bind.annotation.CookieValue
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import java.time.LocalDate

Expand All @@ -33,8 +34,8 @@ class DiaryDetailController(
user: UserAuth,
@PathVariable date: LocalDate,
@CookieValue(WebConstants.TOKEN_COOKIE_NAME) token: String,
@RequestParam(required = false) page: Int?,
@ModelAttribute params: DiaryPhotoSearchParams,
): ApiPageResult<ApiPhotoPreview> {
return diaryDetailBo.photos(token, date, page)
return diaryDetailBo.photos(token, date, params)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package kim.hyunsub.diary.model.dto

data class DiaryPhotoSearchParams(
val page: Int?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ class ApiDiaryService(

val friends2 = friends ?: friendServiceClient.selectMeetFriends(token, date)

val dateRange = LocalDateRange(
start = date,
end = date,
val photoParams = PhotoSearchParams(
dateRange = LocalDateRange(
start = date,
end = date,
),
pageSize = 6,
asc = true,
)
val photoParams = PhotoSearchParams(dateRange = dateRange)
val photoResult = photoServiceClient.searchPhoto(token, photoParams)

return ApiDiary(
Expand Down

0 comments on commit f665344

Please sign in to comment.