Skip to content

Commit 45a785e

Browse files
authored
Merge pull request #180 from team-gogo/fix/coupon-query-api-specs
2 parents d1dc3f8 + 8b9785f commit 45a785e

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/main/kotlin/gogo/gogostage/domain/coupon/root/application/CouponServiceImpl.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package gogo.gogostage.domain.coupon.root.application
22

33
import gogo.gogostage.domain.coupon.root.application.dto.QueryCouponDto
44
import gogo.gogostage.domain.coupon.root.application.dto.UseCouponDto
5-
import gogo.gogostage.domain.coupon.root.persistence.Coupon
65
import gogo.gogostage.domain.stage.root.application.StageValidator
7-
import gogo.gogostage.global.internal.student.stub.StudentByIdStub
86
import gogo.gogostage.global.util.UserContextUtil
97
import org.springframework.stereotype.Service
108
import 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

Comments
 (0)