@@ -2,9 +2,7 @@ package gogo.gogostage.domain.coupon.root.application
22
33import gogo.gogostage.domain.coupon.root.application.dto.QueryCouponDto
44import gogo.gogostage.domain.coupon.root.application.dto.UseCouponDto
5- import gogo.gogostage.domain.coupon.root.persistence.Coupon
65import gogo.gogostage.domain.stage.root.application.StageValidator
7- import gogo.gogostage.global.internal.student.stub.StudentByIdStub
86import gogo.gogostage.global.util.UserContextUtil
97import org.springframework.stereotype.Service
108import org.springframework.transaction.annotation.Transactional
@@ -23,22 +21,18 @@ class CouponServiceImpl(
2321 override fun query (couponId : String ): QueryCouponDto {
2422 val student = userUtil.getCurrentStudent()
2523 val coupon = couponReader.read(couponId)
26- valid (student, coupon)
24+ stageValidator.validStage (student, coupon.stage.id )
2725 return couponMapper.map(coupon)
2826 }
2927
3028 @Transactional
3129 override fun use (couponId : String ): UseCouponDto {
3230 val student = userUtil.getCurrentStudent()
3331 val coupon = couponReader.readForUpdate(couponId)
34- valid(student, coupon)
35- val couponResult = couponProcessor.use(student, coupon)
36- return couponMapper.mapResult(coupon, couponResult)
37- }
38-
39- private fun valid (student : StudentByIdStub , coupon : Coupon ) {
4032 couponValidator.valid(coupon)
4133 stageValidator.validStage(student, coupon.stage.id)
34+ val couponResult = couponProcessor.use(student, coupon)
35+ return couponMapper.mapResult(coupon, couponResult)
4236 }
4337
4438}
0 commit comments