Skip to content

Commit

Permalink
Merge pull request #194 from GSM-MSG/193-fix/updatereservation-aop
Browse files Browse the repository at this point in the history
검증 로직을 수정합니다. update reservation 단에서 useStatus 검증 aop는 대표자 검증만
  • Loading branch information
esperar authored Nov 6, 2023
2 parents 031f334 + b3357d3 commit 5728914
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class ReservationControlAspect(
val reservation = reservationService.queryReservationById(reservationId)

userValidator.checkRepresentative(currentUser, reservation)
userValidator.checkUsersUseStatus(userService.queryAllUserById(request.users))
}

@Before("delegateRepresentativeUseCasePointcut(reservationId, userId)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package team.msg.hiv2.domain.reservation.application.usecase
import team.msg.hiv2.domain.reservation.application.service.ReservationService
import team.msg.hiv2.domain.reservation.presentation.data.request.UpdateReservationRequest
import team.msg.hiv2.domain.user.application.service.UserService
import team.msg.hiv2.domain.user.application.validator.UserValidator
import team.msg.hiv2.domain.user.domain.constant.UseStatus
import team.msg.hiv2.global.annotation.usecase.UseCase
import java.util.UUID

@UseCase
class UpdateReservationUseCase(
private val reservationService: ReservationService,
private val userService: UserService
private val userService: UserService,
private val userValidator: UserValidator
) {

fun execute(reservationId: UUID, request: UpdateReservationRequest){
Expand All @@ -22,6 +24,8 @@ class UpdateReservationUseCase(

val users = request.users.map { userService.queryUserById(it) }

userValidator.checkUsersUseStatus(users)

reservationService.save(reservation.copy(reason = request.reason))
userService.saveAll(users.map { it.copy(reservationId = reservationId) })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class UpdateReservationUseCaseTest {
@Mock
private lateinit var reservationService: ReservationService

@Mock
private lateinit var userValidator: UserValidator

private lateinit var updateReservationUseCase: UpdateReservationUseCase

private val floor = 3
Expand Down Expand Up @@ -97,7 +100,7 @@ class UpdateReservationUseCaseTest {
@BeforeEach
fun setUp(){
updateReservationUseCase = UpdateReservationUseCase(
reservationService, userService
reservationService, userService, userValidator
)
}

Expand Down

0 comments on commit 5728914

Please sign in to comment.