-
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.
Merge pull request #110 from nhnacademy-be5-T3Team/feature/coupon
쿠폰 발급 관련 뷰 개발
- Loading branch information
Showing
25 changed files
with
729 additions
and
19 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/com/t3t/frontserver/admin/controller/CouponController.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.admin.controller; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
@Controller | ||
public class CouponController { | ||
@GetMapping("/admin/coupons/register") | ||
public String getRegisterView(){ | ||
return "admin/page/couponRegister"; | ||
} | ||
|
||
@GetMapping("/admin/coupons/usageHistory") | ||
public String getUsage(){ | ||
return "admin/page/couponHistory"; | ||
} | ||
} |
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/model/response/CouponDetailFindResponse.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.model.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CouponDetailFindResponse { | ||
public String couponId; | ||
public BigDecimal discountRate; | ||
public BigDecimal discountFee; | ||
public LocalDate couponExpireDate; | ||
public String couponType; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/t3t/frontserver/coupon/model/response/CouponDetailResponse.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,16 @@ | ||
package com.t3t.frontserver.coupon.model.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CouponDetailResponse { | ||
public String couponId; | ||
public String couponUseType; | ||
public LocalDateTime couponUseDate; | ||
} |
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
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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/t3t/frontserver/member/controller/MemberRestController.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,30 @@ | ||
package com.t3t.frontserver.member.controller; | ||
|
||
import com.t3t.frontserver.member.model.response.MemberAdminResponse; | ||
import com.t3t.frontserver.member.service.MemberService; | ||
import com.t3t.frontserver.model.response.BaseResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class MemberRestController { | ||
private final MemberService memberService; | ||
|
||
@GetMapping("/members") | ||
public ResponseEntity<List<MemberAdminResponse>> findAllMembersByName(@RequestParam("name") String name){ | ||
BaseResponse<List<MemberAdminResponse>> data = new BaseResponse<List<MemberAdminResponse>>().data(memberService.findMemberByName(name)); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).body(data.getData()); | ||
} | ||
|
||
@PostMapping("/coupon/{couponType}/{memberId}") | ||
public ResponseEntity<BaseResponse<Void>> registerCouponToUserByAdmin(@PathVariable("couponType") String couponType, | ||
@PathVariable("memberId") Long memberId){ | ||
return ResponseEntity.status(HttpStatus.CREATED).body(new BaseResponse<Void>().message(memberService.registCouponToMemberByAdmin(couponType, memberId))); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/t3t/frontserver/member/exception/CouponApiClientException.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,13 @@ | ||
package com.t3t.frontserver.member.exception; | ||
|
||
public class CouponApiClientException extends RuntimeException{ | ||
private static final String DEFAULT_MESSAGES = "쿠폰 발급에 실패하였습니다"; | ||
|
||
public CouponApiClientException() { | ||
super(DEFAULT_MESSAGES); | ||
} | ||
|
||
public CouponApiClientException(String message) { | ||
super(message); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/t3t/frontserver/member/model/response/MemberAdminResponse.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,16 @@ | ||
package com.t3t.frontserver.member.model.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class MemberAdminResponse { | ||
public Long id; | ||
public String name; | ||
public String email; | ||
} |
Oops, something went wrong.