-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da1ebcd
commit c17a7a6
Showing
6 changed files
with
129 additions
and
6 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/com/t3t/frontserver/coupon/adapter/CouponAdapter.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,40 @@ | ||
package com.t3t.frontserver.coupon.adapter; | ||
|
||
import com.t3t.frontserver.coupon.client.CouponApiClient; | ||
import com.t3t.frontserver.member.exception.CouponApiClientException; | ||
import com.t3t.frontserver.util.FeignClientUtils; | ||
import feign.FeignException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class CouponAdapter { | ||
private final CouponApiClient couponApiClient; | ||
|
||
/** | ||
* 회원이 도서 쿠폰 발급받기 위해 사용하는 api | ||
* @author joohyun1996(이주현) | ||
*/ | ||
public String registerBookCouponByMember(){ | ||
try{ | ||
couponApiClient.registerBookCoupon(); | ||
return "쿠폰이 등록되었습니다"; | ||
}catch(FeignException e){ | ||
throw new CouponApiClientException("도서쿠폰 등록에 실패하였습니다 " + FeignClientUtils.getMessageFromFeignException(e)); | ||
} | ||
} | ||
|
||
/** | ||
* 회원이 카테고리 쿠폰 발급받기 위해 사용하는 api | ||
* @author joohyun1996(이주현) | ||
*/ | ||
public String registerCategoryCouponByMember(){ | ||
try{ | ||
couponApiClient.registerCategoryCoupon(); | ||
return "쿠폰이 등록되었습니다"; | ||
}catch(FeignException e){ | ||
throw new CouponApiClientException("카테고리쿠폰 등록에 실패하였습니다 " + FeignClientUtils.getMessageFromFeignException(e)); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/t3t/frontserver/coupon/client/CouponApiClient.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,17 @@ | ||
package com.t3t.frontserver.coupon.client; | ||
|
||
import com.t3t.frontserver.model.response.BaseResponse; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
||
|
||
@FeignClient(name = "couponApiClient", url = "${t3t.feignClient.url}") | ||
public interface CouponApiClient { | ||
|
||
@PostMapping("/at/bookstore/members/coupons/book") | ||
ResponseEntity<BaseResponse<Void>> registerBookCoupon(); | ||
|
||
@PostMapping("/at/bookstore/members/coupons/category") | ||
ResponseEntity<BaseResponse<Void>> registerCategoryCoupon(); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/t3t/frontserver/coupon/controller/CouponRestController.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,22 @@ | ||
package com.t3t.frontserver.coupon.controller; | ||
|
||
import com.t3t.frontserver.coupon.service.CouponService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class CouponRestController { | ||
private final CouponService couponService; | ||
|
||
@PostMapping("/coupons/book") | ||
public void registerBookCouponByMember(){ | ||
couponService.registerBookCoupon(); | ||
} | ||
|
||
@PostMapping("/coupons/category") | ||
public void registerCategoryCouponByMember(){ | ||
couponService.registerCategoryCoupon(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/t3t/frontserver/coupon/service/CouponService.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,19 @@ | ||
package com.t3t.frontserver.coupon.service; | ||
|
||
import com.t3t.frontserver.coupon.adapter.CouponAdapter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CouponService { | ||
private final CouponAdapter couponAdapter; | ||
|
||
public String registerBookCoupon(){ | ||
return couponAdapter.registerBookCouponByMember(); | ||
} | ||
|
||
public String registerCategoryCoupon(){ | ||
return couponAdapter.registerCategoryCouponByMember(); | ||
} | ||
} |
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