-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 예약 도메인 추가 및 패키지 도메인 일부 변경 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dfd8a03
feat: Package, Reservation 생성
sosow0212 4a0d9ef
feat: 예약 목업 코드 생성
sosow0212 f02c001
refactor: 코드 일부 수정
sosow0212 284b2ec
test: 도메인 로직 테스트 추가
sosow0212 9d8508d
refactor: Package와 PackageProduct, PackageTags, ReservationSlot 생명주기 통일
sosow0212 892f0cb
refactor: 예약 메시지 및 상수화
sosow0212 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/com/study/core/product/domain/ProductRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| package com.study.core.product.domain | ||
|
|
||
| interface ProductRepository { | ||
|
|
||
| fun findAllByIdIn(productIds: List<Long>): List<Product> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/com/study/core/product/infrastructure/ProductRepositoryImpl.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| package com.study.core.product.infrastructure | ||
|
|
||
| import com.study.core.product.domain.Product | ||
| import com.study.core.product.domain.ProductRepository | ||
| import org.springframework.stereotype.Repository | ||
|
|
||
| @Repository | ||
| class ProductRepositoryImpl( | ||
| private val productJpaRepository: ProductJpaRepository | ||
| ) : ProductRepository { | ||
|
|
||
| override fun findAllByIdIn(productIds: List<Long>): List<Product> { | ||
| return productJpaRepository.findAllByIdIn(productIds) | ||
| } | ||
| } |
35 changes: 29 additions & 6 deletions
35
src/main/kotlin/com/study/core/productpackage/application/PackageCommandService.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,39 @@ | ||
| package com.study.core.productpackage.application | ||
|
|
||
| import com.study.core.product.domain.Product | ||
| import com.study.core.product.domain.ProductRepository | ||
| import com.study.core.productpackage.application.dto.CreatePackageCommand | ||
| import com.study.core.productpackage.domain.Package | ||
| import com.study.core.productpackage.infrastructure.PackageCommandRepository | ||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
|
|
||
| /** | ||
| * TODO : 도메인 설계 Merge이후 작업 | ||
| */ | ||
| @Transactional | ||
| @Service | ||
| class PackageCommandService { | ||
| class PackageCommandService( | ||
| private val packageCommandRepository: PackageCommandRepository, | ||
| private val productRepository: ProductRepository, | ||
| ) { | ||
|
|
||
| fun createPackage(): Package { | ||
| TODO() | ||
| fun createPackage(command: CreatePackageCommand): Package { | ||
| val products = findProducts(command.productIds) | ||
| val pkg = Package.createWithTimeSlots( | ||
| name = command.name, | ||
| description = command.description, | ||
| products = products, | ||
| tagNames = command.tagNames, | ||
| slotStartDate = command.slotStartDate, | ||
| slotEndDate = command.slotEndDate, | ||
| slotStartHour = command.slotStartHour, | ||
| slotEndHour = command.slotEndHour | ||
| ) | ||
|
|
||
| return packageCommandRepository.save(pkg) | ||
| } | ||
|
|
||
| private fun findProducts(productIds: List<Long>): List<Product> { | ||
| val products = productRepository.findAllByIdIn(productIds) | ||
| require(products.size == productIds.size) { "One or more products are not found." } | ||
| return products | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/study/core/productpackage/application/dto/CreatePackageCommand.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.study.core.productpackage.application.dto | ||
|
|
||
| import java.time.LocalDate | ||
|
|
||
| data class CreatePackageCommand( | ||
| val name: String, | ||
| val description: String, | ||
| val slotStartDate: LocalDate, // 패키지 생성 시 예약 시작 가능한 날짜 | ||
| val slotEndDate: LocalDate, // 패키지 생성 시 패키지 마감 날짜 | ||
| val slotStartHour: Int = 9, // 예약 가능한 타임 슬롯 시작 지점 | ||
| val slotEndHour: Int = 16, // 예약 가능한 타임 슬록 마지막 지점 | ||
| val productIds: List<Long> = emptyList(), // 예약에 포함할 패키지 ids | ||
| val tagNames: List<String> = emptyList() // 패키지에 해당하는 tags | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
src/main/kotlin/com/study/core/productpackage/domain/Tag.kt
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/com/study/core/productpackage/infrastructure/PackageCommandRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| package com.study.core.productpackage.infrastructure | ||
|
|
||
| import com.study.core.productpackage.domain.Package | ||
| import org.springframework.stereotype.Repository | ||
|
|
||
| @Repository | ||
| class PackageCommandRepository( | ||
| private val packageJpaRepository: PackageJpaRepository | ||
| ) { | ||
|
|
||
| fun save(pkg: Package): Package = packageJpaRepository.save(pkg) | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/com/study/core/reservation/application/ReservationCommandService.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.study.core.reservation.application | ||
|
|
||
| import com.study.core.reservation.application.dto.CreateReservationCommand | ||
| import com.study.core.reservation.domain.Reservation | ||
| import com.study.core.reservation.domain.ReservationRepository | ||
| import com.study.core.reservation.domain.ReservationSlotRepository | ||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
|
|
||
| @Transactional | ||
| @Service | ||
| class ReservationCommandService( | ||
| private val reservationRepository: ReservationRepository, | ||
| private val reservationSlotRepository: ReservationSlotRepository | ||
| ) { | ||
|
|
||
| fun createReservation(command: CreateReservationCommand): Reservation { | ||
| val reservationTimeSlot = reservationSlotRepository.findByIdForUpdate(command.reservationSlotId) | ||
| ?: throw IllegalArgumentException("Reservation slot not found: ${command.reservationSlotId}") | ||
| reservationTimeSlot.validateBookingStatusAndPackageValid(command.packageId) | ||
|
|
||
| val reservation = Reservation( | ||
| reservationSlot = reservationTimeSlot, | ||
| userId = command.userId, | ||
| headCount = command.headCount, | ||
| visitDate = reservationTimeSlot.reservationDate, | ||
| visitStartTime = reservationTimeSlot.startTime, | ||
| visitEndTime = reservationTimeSlot.endTime, | ||
| totalPrice = command.totalPrice | ||
| ).request() | ||
|
|
||
| return reservationRepository.save(reservation) | ||
| } | ||
|
|
||
| fun cancelReservation(reservationId: Long): Reservation { | ||
| val reservation = reservationRepository.findById(reservationId) | ||
| ?: throw IllegalArgumentException("Reservation not found: $reservationId") | ||
| val updated = reservation.cancel() | ||
| return reservationRepository.save(updated) | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/study/core/reservation/application/dto/CreateReservationCommand.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.study.core.reservation.application.dto | ||
|
|
||
| import java.math.BigDecimal | ||
|
|
||
| data class CreateReservationCommand( | ||
| val packageId: Long, | ||
| val reservationSlotId: Long, // 예약 가능한 타임슬롯 id | ||
| val userId: Long, | ||
| val headCount: Int, // 인원 수 | ||
| val totalPrice: BigDecimal // 패키지 총액 (반정규화) | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인원 수, 예약 요청 메시지는 피그마 상으로는 예약 시에 입력받고 있는 것 같지 않은데 어떤 방식으로 입력받는 건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앗 그러네요 예약 요청 메시지 같은 게 보통 있어서 관성적으로 추가한 것 같은데 제거하겠습니다.