generated from pricelees/issue-pr-template
refactor: 인기 테마 조회 API 수정에 따른 reservation에서의 API 제거
This commit is contained in:
parent
e552636aec
commit
a4d28322fb
@ -121,23 +121,6 @@ class ReservationService(
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun findMostReservedThemeIds(count: Int): MostReservedThemeIdListResponse {
|
||||
log.info { "[ReservationService.findMostReservedThemeIds] 인기 테마 조회 시작: count=$count" }
|
||||
val previousWeekSunday = DateUtils.getSundayOfPreviousWeek(LocalDate.now())
|
||||
val previousWeekSaturday = previousWeekSunday.plusDays(6)
|
||||
|
||||
val themeIds: List<Long> = reservationRepository.findMostReservedThemeIds(
|
||||
dateFrom = previousWeekSunday,
|
||||
dateTo = previousWeekSaturday,
|
||||
count = count
|
||||
)
|
||||
|
||||
return MostReservedThemeIdListResponse(themeIds = themeIds).also {
|
||||
log.info { "[ReservationService.findMostReservedThemeIds] 인기 테마 조회 완료: count=${it.themeIds.size}" }
|
||||
}
|
||||
}
|
||||
|
||||
private fun findOrThrow(id: Long): ReservationEntity {
|
||||
log.info { "[ReservationService.findOrThrow] 예약 조회 시작: reservationId=${id}" }
|
||||
|
||||
|
||||
@ -16,14 +16,6 @@ import roomescape.common.dto.response.CommonApiResponse
|
||||
import roomescape.reservation.web.*
|
||||
|
||||
interface ReservationAPI {
|
||||
|
||||
@Public
|
||||
@Operation(summary = "가장 많이 예약된 테마 ID 조회")
|
||||
@ApiResponses(ApiResponse(responseCode = "200", useReturnTypeSchema = true))
|
||||
fun findMostReservedThemeIds(
|
||||
@RequestParam count: Int
|
||||
): ResponseEntity<CommonApiResponse<MostReservedThemeIdListResponse>>
|
||||
|
||||
@Operation(summary = "결제 전 임시 예약 저장")
|
||||
@ApiResponses(ApiResponse(responseCode = "200", useReturnTypeSchema = true))
|
||||
fun createPendingReservation(
|
||||
|
||||
@ -1,27 +1,8 @@
|
||||
package roomescape.reservation.infrastructure.persistence
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.data.repository.query.Param
|
||||
import java.time.LocalDate
|
||||
|
||||
interface ReservationRepository : JpaRepository<ReservationEntity, Long> {
|
||||
|
||||
fun findAllByUserIdAndStatusIsIn(userId: Long, statuses: List<ReservationStatus>): List<ReservationEntity>
|
||||
|
||||
@Query("""
|
||||
SELECT s.themeId
|
||||
FROM ReservationEntity r
|
||||
JOIN ScheduleEntity s ON s._id = r.scheduleId
|
||||
WHERE r.status = roomescape.reservation.infrastructure.persistence.ReservationStatus.CONFIRMED
|
||||
AND s.date BETWEEN :dateFrom AND :dateTo
|
||||
GROUP BY s.themeId
|
||||
ORDER BY count(r) DESC
|
||||
LIMIT :count
|
||||
""")
|
||||
fun findMostReservedThemeIds(
|
||||
@Param("dateFrom") dateFrom: LocalDate,
|
||||
@Param("dateTo") dateTo: LocalDate,
|
||||
@Param("count") count: Int
|
||||
): List<Long>
|
||||
}
|
||||
|
||||
@ -14,16 +14,6 @@ import roomescape.reservation.docs.ReservationAPI
|
||||
class ReservationController(
|
||||
private val reservationService: ReservationService
|
||||
) : ReservationAPI {
|
||||
|
||||
@GetMapping("/popular-themes")
|
||||
override fun findMostReservedThemeIds(
|
||||
@RequestParam count: Int
|
||||
): ResponseEntity<CommonApiResponse<MostReservedThemeIdListResponse>> {
|
||||
val response = reservationService.findMostReservedThemeIds(count)
|
||||
|
||||
return ResponseEntity.ok(CommonApiResponse(response))
|
||||
}
|
||||
|
||||
@PostMapping("/pending")
|
||||
override fun createPendingReservation(
|
||||
@User user: CurrentUserContext,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user