Skip to content

Commit 7aa6770

Browse files
committed
fix: 대여기록에 근무자 기록되도록 수정
1 parent 3a8bad6 commit 7aa6770

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/main/kotlin/site/billilge/api/backend/domain/rental/dto/request/AdminRentalHistoryRequest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ data class AdminRentalHistoryRequest(
1414
val count: Int,
1515

1616
@field:Schema(description = "대여 시작 시간 정보")
17-
val rentalTime: RentalTime
17+
val rentalTime: RentalTime,
18+
19+
@field:Schema(description = "근무자 ID", example = "2")
20+
val workerId: Long,
1821
) {
1922
@Schema(description = "대여 시작 시간 (시간 및 분)")
2023
data class RentalTime(

src/main/kotlin/site/billilge/api/backend/domain/rental/facade/AdminRentalFacade.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ class AdminRentalFacade(
4848
@Transactional
4949
fun createRentalByAdmin(request: AdminRentalHistoryRequest) {
5050
val rentAt = resolveKoreanRentAt(request.rentalTime.hour, request.rentalTime.minute)
51+
val worker = memberService.findById(request.workerId)
5152
val member = memberService.findById(request.memberId)
5253
val item = itemService.getItemById(request.itemId)
5354
rentalService.createRentalByAdmin(
55+
worker,
5456
member,
5557
item,
5658
request.count,

src/main/kotlin/site/billilge/api/backend/domain/rental/service/RentalService.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class RentalService(
8484
}
8585

8686
@Transactional
87-
fun createRentalByAdmin(rentUser: Member, item: Item, count: Int, rentAt: LocalDateTime) {
87+
fun createRentalByAdmin(worker: Member, rentUser: Member, item: Item, count: Int, rentAt: LocalDateTime) {
8888
validateStock(count, item.count)
8989

9090
if (!rentUser.isFeePaid) throw ApiException(RentalErrorCode.MEMBER_IS_NOT_PAYER_ADMIN)
@@ -102,6 +102,14 @@ class RentalService(
102102
}
103103

104104
rentalRepository.save(newRental)
105+
106+
rentalStatusWorkerLogRepository.save(
107+
RentalStatusWorkerLog(
108+
rentalHistory = newRental,
109+
rentalStatus = newRental.rentalStatus,
110+
worker = worker
111+
)
112+
)
105113
}
106114

107115
@Transactional
@@ -266,6 +274,14 @@ class RentalService(
266274

267275
else -> return
268276
}
277+
278+
rentalStatusWorkerLogRepository.save(
279+
RentalStatusWorkerLog(
280+
rentalHistory = rentalHistory,
281+
rentalStatus = newStatus,
282+
worker = worker
283+
)
284+
)
269285
}
270286

271287
private fun validatePayer(member: Member) {

0 commit comments

Comments
 (0)