Skip to content

Commit 6cf12f4

Browse files
committed
add: coupon controller
1 parent 24aae0a commit 6cf12f4

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package gogo.gogostage.domain.coupon.root.presentation
2+
3+
import gogo.gogostage.domain.coupon.root.application.CouponService
4+
import gogo.gogostage.domain.coupon.root.application.dto.QueryCouponDto
5+
import gogo.gogostage.domain.coupon.root.application.dto.UseCouponDto
6+
import org.springframework.http.ResponseEntity
7+
import org.springframework.web.bind.annotation.GetMapping
8+
import org.springframework.web.bind.annotation.PostMapping
9+
import org.springframework.web.bind.annotation.RequestMapping
10+
import org.springframework.web.bind.annotation.RequestParam
11+
import org.springframework.web.bind.annotation.RestController
12+
13+
@RestController
14+
@RequestMapping("/stage")
15+
class CouponController(
16+
private val couponService: CouponService,
17+
) {
18+
19+
@GetMapping("/coupon")
20+
fun query(
21+
@RequestParam couponId: String,
22+
): ResponseEntity<QueryCouponDto> {
23+
val response = couponService.query(couponId)
24+
return ResponseEntity.ok(response)
25+
}
26+
27+
@PostMapping("/coupon")
28+
fun use(
29+
@RequestParam couponId: String,
30+
): ResponseEntity<UseCouponDto> {
31+
val response = couponService.use(couponId)
32+
return ResponseEntity.ok(response)
33+
}
34+
35+
}

src/main/kotlin/gogo/gogostage/global/config/SecurityConfig.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class SecurityConfig(
9494
// image
9595
httpRequests.requestMatchers(HttpMethod.POST, "/stage/image").hasAnyRole(Authority.USER.name, Authority.STAFF.name)
9696

97+
// coupon
98+
httpRequests.requestMatchers(HttpMethod.GET, "/stage/coupon").hasAnyRole(Authority.USER.name, Authority.STAFF.name)
99+
httpRequests.requestMatchers(HttpMethod.POST, "/stage/coupon").hasAnyRole(Authority.USER.name, Authority.STAFF.name)
100+
97101
// server to server
98102
httpRequests.requestMatchers(HttpMethod.GET, "/stage/api/point/{stage_id}").access { _, context -> hasIpAddress(context) }
99103
httpRequests.requestMatchers(HttpMethod.GET, "/stage/api/match/info").access { _, context -> hasIpAddress(context) }

0 commit comments

Comments
 (0)