-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#326] 후원 및 환불 api 리팩토링 및 구현 #327
Changes from 7 commits
cabc5c4
36ca94d
2088aab
3492217
338755b
b990b0e
28ce321
9d0327e
53299fa
c5cc7be
d6d32db
c0a746d
4c69eed
80c12e0
c414b18
5377aa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.example.tyfserver.donation.domain; | ||
|
||
public enum DonationType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Donation이 창작자, 후원자로 바뀌게 한다면 얘는 필요 없어지겠다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 응 맞어! 그리고 지금 코드도 이 enum을 사용하고 있지는 않아 미리 만들어뒀어! 그리고 Donation 엔티티 필드에 DonationStatus 가 아직 있는데 이것도 삭제해야하는데 아직 삭제안했업 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 말 나온김에 DonationStatus Donation 필드에서 빼놔야겠다 |
||
DONATED, DONATING; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,8 @@ public void reduce(final long amount) { | |
} | ||
this.point -= amount; | ||
} | ||
|
||
public boolean lessThan(Long point) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 메소드 명 좋다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 근데 payment도메인의 reduce 함수에서 "포인트가 총액보다 적게 있습니다" 예외가 RuntimeException으로 되어있당 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 땡큐 이거 예외 만들어놓앗는데 여기다가 적용안했네 굿 |
||
return this.point < point; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,23 +15,26 @@ public class MemberResponse { | |
private String pageName; | ||
private String bio; | ||
private String profileImage; | ||
private long point; | ||
private boolean bankRegistered; | ||
|
||
public MemberResponse(Member member) { | ||
this(member.getEmail(), member.getNickname(), member.getPageName(), | ||
member.getBio(), member.getProfileImage(), isBankRegistered(member)); | ||
member.getBio(), member.getProfileImage(), member.getAvailablePoint(), isBankRegistered(member)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MemberResponse에 AvailablePoint만 주는 이유는 members/me/point API가 있어서 겠쥬? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 API는 현재 보유 포인트 달라고 했어서 이거 준거야! |
||
} | ||
|
||
private static boolean isBankRegistered(Member member) { | ||
return member.getAccountStatus() == AccountStatus.REGISTERED; | ||
} | ||
|
||
public MemberResponse(String email, String nickname, String pageName, String bio, String profileImage, boolean bankRegistered) { | ||
public MemberResponse(String email, String nickname, String pageName, String bio, | ||
String profileImage, long point, boolean bankRegistered) { | ||
this.email = email; | ||
this.nickname = nickname; | ||
this.pageName = pageName; | ||
this.bio = bio; | ||
this.profileImage = profileImage; | ||
this.point = point; | ||
this.bankRegistered = bankRegistered; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.tyfserver.member.exception; | ||
|
||
import com.example.tyfserver.common.exception.BaseException; | ||
|
||
public class NotEnoughPointException extends BaseException { | ||
|
||
public static final String ERROR_CODE = "donation-010"; | ||
private static final String MESSAGE = "보유 포인트가 충분하지 않습니다."; | ||
|
||
public NotEnoughPointException() { | ||
super(ERROR_CODE, MESSAGE); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,13 @@ | |
import com.example.tyfserver.auth.dto.LoginMember; | ||
import com.example.tyfserver.auth.dto.VerifiedRefunder; | ||
import com.example.tyfserver.payment.dto.*; | ||
import com.example.tyfserver.payment.exception.PaymentCompleteRequestException; | ||
import com.example.tyfserver.payment.exception.PaymentPendingRequestException; | ||
import com.example.tyfserver.payment.exception.RefundVerificationException; | ||
import com.example.tyfserver.payment.exception.RefundVerificationReadyException; | ||
import com.example.tyfserver.payment.service.PaymentService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.BindingResult; | ||
import org.springframework.web.bind.annotation.*; | ||
|
@@ -21,8 +23,7 @@ public class PaymentController { | |
|
||
private final PaymentService paymentService; | ||
|
||
//todo: /payments 에서 /charge/ready 쪽으로 옮겨가야됨. PaymentController 네이밍이 ChargeController로 바뀔지도? | ||
@PostMapping | ||
@PostMapping("/charge/ready") | ||
public ResponseEntity<PaymentPendingResponse> payment(@Valid @RequestBody PaymentPendingRequest paymentPendingRequest, BindingResult result, | ||
LoginMember loginMember) { | ||
if (result.hasErrors()) { | ||
|
@@ -33,6 +34,16 @@ public ResponseEntity<PaymentPendingResponse> payment(@Valid @RequestBody Paymen | |
return ResponseEntity.ok(response); | ||
} | ||
|
||
@PostMapping("/charge") | ||
public ResponseEntity<PaymentCompleteResponse> completePayment(@Valid @RequestBody PaymentCompleteRequest paymentCompleteRequest, BindingResult result) { | ||
if (result.hasErrors()) { | ||
throw new PaymentCompleteRequestException(); | ||
} | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED) | ||
.body(paymentService.completePayment(paymentCompleteRequest)); | ||
} | ||
|
||
@PostMapping("/refund/verification/ready") | ||
public ResponseEntity<RefundVerificationReadyResponse> refundVerificationReady(@Valid @RequestBody RefundVerificationReadyRequest verificationReadyRequest, BindingResult result, | ||
LoginMember loginMember) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서 LoginMember를 사용하지 않는데, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이게... 처음에 토큰 필요한 애들이니깐 미리 LoginMember 써놔야지~! 했다가 안쓰는 애들이 많겠구나 싶어서 놔둔거였어 !! 테스트코드하면서 필요하면 추가하고 안쓰면 빼고 해주면 좋을 것 같어! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금은 안쓰지만, 앞으로 변경 될 후원로직을 생각하면 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테스트 짜면서 알아서들 지워주세요 허헣 |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.example.tyfserver.payment.domain; | ||
|
||
import com.example.tyfserver.payment.exception.ItemNotFoundException; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum Item { | ||
ITEM_1("1000포인트 충전", 1000L), | ||
ITEM_3("3000포인트 충전", 3000L), | ||
ITEM_5("5000포인트 충전", 5000L), | ||
ITEM_10("10000포인트 충전", 10000L), | ||
ITEM_50("50000포인트 충전", 50000L), | ||
ITEM_100("100000포인트 충전", 100000L); | ||
|
||
private String itemName; | ||
private long itemPrice; | ||
Be-poz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Item(String itemName, long itemPrice) { | ||
this.itemName = itemName; | ||
this.itemPrice = itemPrice; | ||
} | ||
|
||
public static Item findItem(String itemId) { | ||
return Arrays.stream(Item.values()) | ||
.filter(item -> item.name().equals(itemId)) | ||
.findAny() | ||
.orElseThrow(ItemNotFoundException::new); | ||
} | ||
|
||
public String getItemName() { | ||
return itemName; | ||
} | ||
|
||
public long getItemPrice() { | ||
return itemPrice; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이제 쓰이지 않는
CREATOR_PREFIX_DOMAIN
상수는 제거하자