chore: 클래스명 수정(Query -> Find / Command -> Write)

This commit is contained in:
이상진 2025-08-06 19:09:47 +09:00
parent 2c4ee5fecd
commit cf23122e91
7 changed files with 42 additions and 43 deletions

View File

@ -14,7 +14,7 @@ private val log = KotlinLogging.logger {}
@Service @Service
@Transactional(readOnly = true) @Transactional(readOnly = true)
class ReservationQueryService( class ReservationFindService(
private val reservationFinder: ReservationFinder private val reservationFinder: ReservationFinder
) { ) {
fun findReservations(): ReservationRetrieveListResponse { fun findReservations(): ReservationRetrieveListResponse {

View File

@ -18,7 +18,7 @@ private val log = KotlinLogging.logger {}
@Service @Service
@Transactional @Transactional
class ReservationWithPaymentService( class ReservationWithPaymentService(
private val reservationCommandService: ReservationCommandService, private val reservationWriteService: ReservationWriteService,
private val paymentService: PaymentService, private val paymentService: PaymentService,
) { ) {
fun createReservationAndPayment( fun createReservationAndPayment(
@ -28,7 +28,7 @@ class ReservationWithPaymentService(
): ReservationCreateResponse { ): ReservationCreateResponse {
log.info { "[ReservationWithPaymentService.createReservationAndPayment] 시작: memberId=$memberId, paymentInfo=$approvedPaymentInfo" } log.info { "[ReservationWithPaymentService.createReservationAndPayment] 시작: memberId=$memberId, paymentInfo=$approvedPaymentInfo" }
val reservation: ReservationEntity = reservationCommandService.createReservationWithPayment(request, memberId) val reservation: ReservationEntity = reservationWriteService.createReservationWithPayment(request, memberId)
.also { paymentService.createPayment(approvedPaymentInfo, it) } .also { paymentService.createPayment(approvedPaymentInfo, it) }
return reservation.toCreateResponse() return reservation.toCreateResponse()
@ -50,7 +50,7 @@ class ReservationWithPaymentService(
log.info { "[ReservationWithPaymentService.deleteReservationAndPayment] 시작: reservationId=$reservationId" } log.info { "[ReservationWithPaymentService.deleteReservationAndPayment] 시작: reservationId=$reservationId" }
val paymentCancelRequest = paymentService.createCanceledPayment(reservationId) val paymentCancelRequest = paymentService.createCanceledPayment(reservationId)
reservationCommandService.deleteReservation(reservationId, memberId) reservationWriteService.deleteReservation(reservationId, memberId)
log.info { "[ReservationWithPaymentService.deleteReservationAndPayment] 완료: reservationId=$reservationId" } log.info { "[ReservationWithPaymentService.deleteReservationAndPayment] 완료: reservationId=$reservationId" }
return paymentCancelRequest return paymentCancelRequest
} }

View File

@ -14,7 +14,7 @@ private val log: KLogger = KotlinLogging.logger {}
@Service @Service
@Transactional @Transactional
class ReservationCommandService( class ReservationWriteService(
private val reservationFinder: ReservationFinder, private val reservationFinder: ReservationFinder,
private val reservationWriter: ReservationWriter private val reservationWriter: ReservationWriter
) { ) {

View File

@ -10,8 +10,8 @@ import roomescape.payment.infrastructure.client.PaymentApproveRequest
import roomescape.payment.infrastructure.client.PaymentApproveResponse import roomescape.payment.infrastructure.client.PaymentApproveResponse
import roomescape.payment.infrastructure.client.TossPaymentClient import roomescape.payment.infrastructure.client.TossPaymentClient
import roomescape.payment.web.PaymentCancelRequest import roomescape.payment.web.PaymentCancelRequest
import roomescape.reservation.business.ReservationCommandService import roomescape.reservation.business.ReservationWriteService
import roomescape.reservation.business.ReservationQueryService import roomescape.reservation.business.ReservationFindService
import roomescape.reservation.business.ReservationWithPaymentService import roomescape.reservation.business.ReservationWithPaymentService
import roomescape.reservation.docs.ReservationAPI import roomescape.reservation.docs.ReservationAPI
import java.net.URI import java.net.URI
@ -20,13 +20,13 @@ import java.time.LocalDate
@RestController @RestController
class ReservationController( class ReservationController(
private val reservationWithPaymentService: ReservationWithPaymentService, private val reservationWithPaymentService: ReservationWithPaymentService,
private val reservationQueryService: ReservationQueryService, private val reservationFindService: ReservationFindService,
private val reservationCommandService: ReservationCommandService, private val reservationWriteService: ReservationWriteService,
private val paymentClient: TossPaymentClient private val paymentClient: TossPaymentClient
) : ReservationAPI { ) : ReservationAPI {
@GetMapping("/reservations") @GetMapping("/reservations")
override fun findReservations(): ResponseEntity<CommonApiResponse<ReservationRetrieveListResponse>> { override fun findReservations(): ResponseEntity<CommonApiResponse<ReservationRetrieveListResponse>> {
val response: ReservationRetrieveListResponse = reservationQueryService.findReservations() val response: ReservationRetrieveListResponse = reservationFindService.findReservations()
return ResponseEntity.ok(CommonApiResponse(response)) return ResponseEntity.ok(CommonApiResponse(response))
} }
@ -35,7 +35,7 @@ class ReservationController(
override fun findReservationsByMemberId( override fun findReservationsByMemberId(
@MemberId @Parameter(hidden = true) memberId: Long @MemberId @Parameter(hidden = true) memberId: Long
): ResponseEntity<CommonApiResponse<MyReservationRetrieveListResponse>> { ): ResponseEntity<CommonApiResponse<MyReservationRetrieveListResponse>> {
val response: MyReservationRetrieveListResponse = reservationQueryService.findReservationsByMemberId(memberId) val response: MyReservationRetrieveListResponse = reservationFindService.findReservationsByMemberId(memberId)
return ResponseEntity.ok(CommonApiResponse(response)) return ResponseEntity.ok(CommonApiResponse(response))
} }
@ -47,7 +47,7 @@ class ReservationController(
@RequestParam(required = false) dateFrom: LocalDate?, @RequestParam(required = false) dateFrom: LocalDate?,
@RequestParam(required = false) dateTo: LocalDate? @RequestParam(required = false) dateTo: LocalDate?
): ResponseEntity<CommonApiResponse<ReservationRetrieveListResponse>> { ): ResponseEntity<CommonApiResponse<ReservationRetrieveListResponse>> {
val response: ReservationRetrieveListResponse = reservationQueryService.searchReservations( val response: ReservationRetrieveListResponse = reservationFindService.searchReservations(
themeId, themeId,
memberId, memberId,
dateFrom, dateFrom,
@ -63,7 +63,7 @@ class ReservationController(
@PathVariable("id") reservationId: Long @PathVariable("id") reservationId: Long
): ResponseEntity<CommonApiResponse<Unit>> { ): ResponseEntity<CommonApiResponse<Unit>> {
if (reservationWithPaymentService.isNotPaidReservation(reservationId)) { if (reservationWithPaymentService.isNotPaidReservation(reservationId)) {
reservationCommandService.deleteReservation(reservationId, memberId) reservationWriteService.deleteReservation(reservationId, memberId)
return ResponseEntity.noContent().build() return ResponseEntity.noContent().build()
} }
@ -116,7 +116,7 @@ class ReservationController(
@MemberId @Parameter(hidden = true) memberId: Long, @MemberId @Parameter(hidden = true) memberId: Long,
): ResponseEntity<CommonApiResponse<ReservationCreateResponse>> { ): ResponseEntity<CommonApiResponse<ReservationCreateResponse>> {
val response: ReservationCreateResponse = val response: ReservationCreateResponse =
reservationCommandService.createReservationByAdmin(adminReservationRequest, memberId) reservationWriteService.createReservationByAdmin(adminReservationRequest, memberId)
return ResponseEntity.created(URI.create("/reservations/${response.id}")) return ResponseEntity.created(URI.create("/reservations/${response.id}"))
.body(CommonApiResponse(response)) .body(CommonApiResponse(response))
@ -124,7 +124,7 @@ class ReservationController(
@GetMapping("/reservations/waiting") @GetMapping("/reservations/waiting")
override fun findAllWaiting(): ResponseEntity<CommonApiResponse<ReservationRetrieveListResponse>> { override fun findAllWaiting(): ResponseEntity<CommonApiResponse<ReservationRetrieveListResponse>> {
val response: ReservationRetrieveListResponse = reservationQueryService.findAllWaiting() val response: ReservationRetrieveListResponse = reservationFindService.findAllWaiting()
return ResponseEntity.ok(CommonApiResponse(response)) return ResponseEntity.ok(CommonApiResponse(response))
} }
@ -134,7 +134,7 @@ class ReservationController(
@Valid @RequestBody waitingCreateRequest: WaitingCreateRequest, @Valid @RequestBody waitingCreateRequest: WaitingCreateRequest,
@MemberId @Parameter(hidden = true) memberId: Long, @MemberId @Parameter(hidden = true) memberId: Long,
): ResponseEntity<CommonApiResponse<ReservationCreateResponse>> { ): ResponseEntity<CommonApiResponse<ReservationCreateResponse>> {
val response: ReservationCreateResponse = reservationCommandService.createWaiting( val response: ReservationCreateResponse = reservationWriteService.createWaiting(
waitingCreateRequest, waitingCreateRequest,
memberId memberId
) )
@ -148,7 +148,7 @@ class ReservationController(
@MemberId @Parameter(hidden = true) memberId: Long, @MemberId @Parameter(hidden = true) memberId: Long,
@PathVariable("id") reservationId: Long @PathVariable("id") reservationId: Long
): ResponseEntity<CommonApiResponse<Unit>> { ): ResponseEntity<CommonApiResponse<Unit>> {
reservationCommandService.deleteWaiting(reservationId, memberId) reservationWriteService.deleteWaiting(reservationId, memberId)
return ResponseEntity.noContent().build() return ResponseEntity.noContent().build()
} }
@ -158,7 +158,7 @@ class ReservationController(
@MemberId @Parameter(hidden = true) memberId: Long, @MemberId @Parameter(hidden = true) memberId: Long,
@PathVariable("id") reservationId: Long @PathVariable("id") reservationId: Long
): ResponseEntity<CommonApiResponse<Unit>> { ): ResponseEntity<CommonApiResponse<Unit>> {
reservationCommandService.confirmWaiting(reservationId, memberId) reservationWriteService.confirmWaiting(reservationId, memberId)
return ResponseEntity.ok().build() return ResponseEntity.ok().build()
} }
@ -168,7 +168,7 @@ class ReservationController(
@MemberId @Parameter(hidden = true) memberId: Long, @MemberId @Parameter(hidden = true) memberId: Long,
@PathVariable("id") reservationId: Long @PathVariable("id") reservationId: Long
): ResponseEntity<CommonApiResponse<Unit>> { ): ResponseEntity<CommonApiResponse<Unit>> {
reservationCommandService.deleteWaiting(reservationId, memberId) reservationWriteService.deleteWaiting(reservationId, memberId)
return ResponseEntity.noContent().build() return ResponseEntity.noContent().build()
} }

View File

@ -10,7 +10,6 @@ import roomescape.reservation.exception.ReservationErrorCode
import roomescape.reservation.exception.ReservationException import roomescape.reservation.exception.ReservationException
import roomescape.reservation.implement.ReservationFinder import roomescape.reservation.implement.ReservationFinder
import roomescape.reservation.implement.ReservationWriter import roomescape.reservation.implement.ReservationWriter
import roomescape.reservation.infrastructure.persistence.ReservationEntity
import roomescape.reservation.infrastructure.persistence.ReservationStatus import roomescape.reservation.infrastructure.persistence.ReservationStatus
import roomescape.util.MemberFixture import roomescape.util.MemberFixture
import roomescape.util.ReservationFixture import roomescape.util.ReservationFixture
@ -21,7 +20,7 @@ class ReservationCommandServiceTest : FunSpec({
val reservationFinder: ReservationFinder = mockk() val reservationFinder: ReservationFinder = mockk()
val reservationWriter: ReservationWriter = mockk() val reservationWriter: ReservationWriter = mockk()
val reservationCommandService = ReservationCommandService(reservationFinder, reservationWriter) val reservationWriteService = ReservationWriteService(reservationFinder, reservationWriter)
context("createReservationWithPayment") { context("createReservationWithPayment") {
val request = ReservationFixture.createRequest() val request = ReservationFixture.createRequest()
@ -47,7 +46,7 @@ class ReservationCommandServiceTest : FunSpec({
) )
} returns createdReservation } returns createdReservation
val result = reservationCommandService.createReservationWithPayment(request, memberId) val result = reservationWriteService.createReservationWithPayment(request, memberId)
assertSoftly(result) { assertSoftly(result) {
this.date shouldBe request.date this.date shouldBe request.date
@ -64,7 +63,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.RESERVATION_DUPLICATED) } throws ReservationException(ReservationErrorCode.RESERVATION_DUPLICATED)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationCommandService.createReservationWithPayment(request, memberId) reservationWriteService.createReservationWithPayment(request, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.RESERVATION_DUPLICATED it.errorCode shouldBe ReservationErrorCode.RESERVATION_DUPLICATED
} }
@ -95,7 +94,7 @@ class ReservationCommandServiceTest : FunSpec({
) )
} returns createdReservation } returns createdReservation
val response = reservationCommandService.createReservationByAdmin(request, adminId) val response = reservationWriteService.createReservationByAdmin(request, adminId)
assertSoftly(response) { assertSoftly(response) {
this.date shouldBe request.date this.date shouldBe request.date
@ -131,7 +130,7 @@ class ReservationCommandServiceTest : FunSpec({
) )
} returns createdWaiting } returns createdWaiting
val response = reservationCommandService.createWaiting(request, memberId) val response = reservationWriteService.createWaiting(request, memberId)
assertSoftly(response) { assertSoftly(response) {
this.date shouldBe request.date this.date shouldBe request.date
@ -148,7 +147,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.ALREADY_RESERVE) } throws ReservationException(ReservationErrorCode.ALREADY_RESERVE)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationCommandService.createWaiting(request, memberId) reservationWriteService.createWaiting(request, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.ALREADY_RESERVE it.errorCode shouldBe ReservationErrorCode.ALREADY_RESERVE
} }
@ -165,7 +164,7 @@ class ReservationCommandServiceTest : FunSpec({
every { reservationWriter.deleteConfirmed(reservation, memberId) } just Runs every { reservationWriter.deleteConfirmed(reservation, memberId) } just Runs
shouldNotThrow<Exception> { shouldNotThrow<Exception> {
reservationCommandService.deleteReservation(reservationId, memberId) reservationWriteService.deleteReservation(reservationId, memberId)
} }
verify(exactly = 1) { reservationWriter.deleteConfirmed(reservation, memberId) } verify(exactly = 1) { reservationWriter.deleteConfirmed(reservation, memberId) }
@ -177,7 +176,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.RESERVATION_NOT_FOUND) } throws ReservationException(ReservationErrorCode.RESERVATION_NOT_FOUND)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationCommandService.deleteReservation(reservationId, memberId) reservationWriteService.deleteReservation(reservationId, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.RESERVATION_NOT_FOUND it.errorCode shouldBe ReservationErrorCode.RESERVATION_NOT_FOUND
} }
@ -190,7 +189,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.NOT_RESERVATION_OWNER) } throws ReservationException(ReservationErrorCode.NOT_RESERVATION_OWNER)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationCommandService.deleteReservation(reservationId, memberId) reservationWriteService.deleteReservation(reservationId, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.NOT_RESERVATION_OWNER it.errorCode shouldBe ReservationErrorCode.NOT_RESERVATION_OWNER
} }
@ -205,7 +204,7 @@ class ReservationCommandServiceTest : FunSpec({
every { reservationWriter.confirm(reservationId) } just Runs every { reservationWriter.confirm(reservationId) } just Runs
shouldNotThrow<Exception> { shouldNotThrow<Exception> {
reservationCommandService.confirmWaiting(reservationId, memberId) reservationWriteService.confirmWaiting(reservationId, memberId)
} }
verify(exactly = 1) { reservationWriter.confirm(reservationId) } verify(exactly = 1) { reservationWriter.confirm(reservationId) }
@ -217,7 +216,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.CONFIRMED_RESERVATION_ALREADY_EXISTS) } throws ReservationException(ReservationErrorCode.CONFIRMED_RESERVATION_ALREADY_EXISTS)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationCommandService.confirmWaiting(reservationId, memberId) reservationWriteService.confirmWaiting(reservationId, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.CONFIRMED_RESERVATION_ALREADY_EXISTS it.errorCode shouldBe ReservationErrorCode.CONFIRMED_RESERVATION_ALREADY_EXISTS
} }
@ -238,7 +237,7 @@ class ReservationCommandServiceTest : FunSpec({
every { reservationWriter.deleteWaiting(waitingReservation, memberId) } just Runs every { reservationWriter.deleteWaiting(waitingReservation, memberId) } just Runs
shouldNotThrow<Exception> { shouldNotThrow<Exception> {
reservationCommandService.deleteWaiting(reservationId, memberId) reservationWriteService.deleteWaiting(reservationId, memberId)
} }
verify(exactly = 1) { reservationWriter.deleteWaiting(waitingReservation, memberId) } verify(exactly = 1) { reservationWriter.deleteWaiting(waitingReservation, memberId) }
@ -250,7 +249,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.RESERVATION_NOT_FOUND) } throws ReservationException(ReservationErrorCode.RESERVATION_NOT_FOUND)
shouldThrow< ReservationException> { shouldThrow< ReservationException> {
reservationCommandService.deleteWaiting(reservationId, memberId) reservationWriteService.deleteWaiting(reservationId, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.RESERVATION_NOT_FOUND it.errorCode shouldBe ReservationErrorCode.RESERVATION_NOT_FOUND
} }
@ -263,7 +262,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.ALREADY_CONFIRMED) } throws ReservationException(ReservationErrorCode.ALREADY_CONFIRMED)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationCommandService.deleteWaiting(reservationId, memberId) reservationWriteService.deleteWaiting(reservationId, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.ALREADY_CONFIRMED it.errorCode shouldBe ReservationErrorCode.ALREADY_CONFIRMED
} }
@ -276,7 +275,7 @@ class ReservationCommandServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.NOT_RESERVATION_OWNER) } throws ReservationException(ReservationErrorCode.NOT_RESERVATION_OWNER)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationCommandService.deleteWaiting(reservationId, memberId) reservationWriteService.deleteWaiting(reservationId, memberId)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.NOT_RESERVATION_OWNER it.errorCode shouldBe ReservationErrorCode.NOT_RESERVATION_OWNER
} }

View File

@ -20,7 +20,7 @@ import java.time.LocalDate
class ReservationQueryServiceTest : FunSpec({ class ReservationQueryServiceTest : FunSpec({
val reservationFinder: ReservationFinder = mockk() val reservationFinder: ReservationFinder = mockk()
val reservationQueryService = ReservationQueryService(reservationFinder) val reservationFindService = ReservationFindService(reservationFinder)
context("findReservations") { context("findReservations") {
test("정상 응답") { test("정상 응답") {
@ -32,7 +32,7 @@ class ReservationQueryServiceTest : FunSpec({
reservationFinder.findAllByStatuses(*ReservationStatus.confirmedStatus()) reservationFinder.findAllByStatuses(*ReservationStatus.confirmedStatus())
} returns confirmedReservations } returns confirmedReservations
val response = reservationQueryService.findReservations() val response = reservationFindService.findReservations()
assertSoftly(response.reservations) { assertSoftly(response.reservations) {
this shouldHaveSize 2 this shouldHaveSize 2
@ -50,7 +50,7 @@ class ReservationQueryServiceTest : FunSpec({
reservationFinder.findAllByStatuses(ReservationStatus.WAITING) reservationFinder.findAllByStatuses(ReservationStatus.WAITING)
} returns waitingReservations } returns waitingReservations
val response = reservationQueryService.findAllWaiting() val response = reservationFindService.findAllWaiting()
assertSoftly(response.reservations) { assertSoftly(response.reservations) {
this shouldHaveSize 2 this shouldHaveSize 2
@ -67,7 +67,7 @@ class ReservationQueryServiceTest : FunSpec({
reservationFinder.findAllByMemberId(memberId) reservationFinder.findAllByMemberId(memberId)
} returns myReservations } returns myReservations
val response = reservationQueryService.findReservationsByMemberId(memberId) val response = reservationFindService.findReservationsByMemberId(memberId)
response.reservations shouldHaveSize 2 response.reservations shouldHaveSize 2
} }
@ -92,7 +92,7 @@ class ReservationQueryServiceTest : FunSpec({
reservationFinder.searchReservations(themeId, memberId, startFrom, endAt) reservationFinder.searchReservations(themeId, memberId, startFrom, endAt)
} returns searchedReservations } returns searchedReservations
val response = reservationQueryService.searchReservations(themeId, memberId, startFrom, endAt) val response = reservationFindService.searchReservations(themeId, memberId, startFrom, endAt)
assertSoftly(response.reservations) { assertSoftly(response.reservations) {
this shouldHaveSize 1 this shouldHaveSize 1
@ -109,7 +109,7 @@ class ReservationQueryServiceTest : FunSpec({
} throws ReservationException(ReservationErrorCode.INVALID_SEARCH_DATE_RANGE) } throws ReservationException(ReservationErrorCode.INVALID_SEARCH_DATE_RANGE)
shouldThrow<ReservationException> { shouldThrow<ReservationException> {
reservationQueryService.searchReservations(themeId, memberId, startFrom, invalidEndAt) reservationFindService.searchReservations(themeId, memberId, startFrom, invalidEndAt)
}.also { }.also {
it.errorCode shouldBe ReservationErrorCode.INVALID_SEARCH_DATE_RANGE it.errorCode shouldBe ReservationErrorCode.INVALID_SEARCH_DATE_RANGE
} }

View File

@ -18,11 +18,11 @@ import roomescape.reservation.web.ReservationCreateWithPaymentRequest
import roomescape.util.* import roomescape.util.*
class ReservationWithPaymentServiceTest : FunSpec({ class ReservationWithPaymentServiceTest : FunSpec({
val reservationService: ReservationCommandService = mockk() val reservationService: ReservationWriteService = mockk()
val paymentService: PaymentService = mockk() val paymentService: PaymentService = mockk()
val reservationWithPaymentService = ReservationWithPaymentService( val reservationWithPaymentService = ReservationWithPaymentService(
reservationCommandService = reservationService, reservationWriteService = reservationService,
paymentService = paymentService paymentService = paymentService
) )