-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#22] refactor : 쿠폰 controller 역할에 맞게 클래스 분리 리팩토링
- Loading branch information
1 parent
2fcd17a
commit 252c4be
Showing
8 changed files
with
105 additions
and
43 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/com/flab/goodchoice/coupon/api/CouponInfoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.flab.goodchoice.coupon.api; | ||
|
||
import com.flab.goodchoice.coupon.application.CouponQueryService; | ||
import com.flab.goodchoice.coupon.dto.CouponInfoResponse; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@RequestMapping("/api/coupons") | ||
@RestController | ||
public class CouponInfoController { | ||
|
||
private final CouponQueryService couponQueryService; | ||
|
||
public CouponInfoController(CouponQueryService couponQueryService) { | ||
this.couponQueryService = couponQueryService; | ||
} | ||
|
||
@GetMapping | ||
public List<CouponInfoResponse> getAllCoupons() { | ||
return couponQueryService.getAllCoupons(); | ||
} | ||
|
||
@GetMapping("/{couponToken}") | ||
public CouponInfoResponse getCoupon(@PathVariable final UUID couponToken) { | ||
return couponQueryService.getCoupon(couponToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/flab/goodchoice/coupon/api/CouponIssueInfoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.flab.goodchoice.coupon.api; | ||
|
||
import com.flab.goodchoice.coupon.application.CouponIssuanceService; | ||
import com.flab.goodchoice.coupon.dto.MemberSpecificCouponResponse; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RequestMapping("/api/coupons") | ||
@RestController | ||
public class CouponIssueInfoController { | ||
|
||
private final CouponIssuanceService couponIssuanceService; | ||
|
||
public CouponIssueInfoController(CouponIssuanceService couponIssuanceService) { | ||
this.couponIssuanceService = couponIssuanceService; | ||
} | ||
|
||
@GetMapping("/publish/{memberId}") | ||
public List<MemberSpecificCouponResponse> getMemberCoupon(@PathVariable Long memberId) { | ||
return couponIssuanceService.getMemberCoupon(memberId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/flab/goodchoice/coupon/api/CouponUseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.flab.goodchoice.coupon.api; | ||
|
||
import com.flab.goodchoice.coupon.application.CouponUseService; | ||
import com.flab.goodchoice.coupon.dto.CouponUsedCancelInfoResponse; | ||
import com.flab.goodchoice.coupon.dto.CouponUsedInfoResponse; | ||
import com.flab.goodchoice.coupon.dto.CouponUsedRequest; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.validation.Valid; | ||
|
||
@RequestMapping("/api/coupons") | ||
@RestController | ||
public class CouponUseController { | ||
|
||
private final CouponUseService couponUseService; | ||
|
||
public CouponUseController(CouponUseService couponUseService) { | ||
this.couponUseService = couponUseService; | ||
} | ||
|
||
@PostMapping("/use") | ||
public CouponUsedInfoResponse useCoupon(@RequestBody @Valid CouponUsedRequest request) { | ||
return couponUseService.useCoupon(request.memberId(), request.couponPublishToken(), request.price()); | ||
} | ||
|
||
@PostMapping("/cancel") | ||
public CouponUsedCancelInfoResponse usedCouponCancel(@RequestBody @Valid CouponUsedRequest request) { | ||
return couponUseService.usedCouponCancel(request.memberId(), request.couponPublishToken(), request.price()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters