-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
123 additions
and
3 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/java/com/project/pieceserver/domain/donate/client/api/DonateController.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,42 @@ | ||
package com.project.pieceserver.domain.donate.client.api; | ||
|
||
import com.project.pieceserver.domain.donate.client.dto.request.DonateMoneyRequest; | ||
import com.project.pieceserver.domain.donate.client.dto.request.DonatePointRequest; | ||
import com.project.pieceserver.domain.donate.client.dto.response.DonateResponse; | ||
import com.project.pieceserver.domain.donate.usecase.DonateUseCase; | ||
import com.project.pieceserver.global.common.dto.response.BaseResponse; | ||
import com.project.pieceserver.global.common.dto.response.BaseResponseData; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
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; | ||
|
||
@RestController | ||
@RequestMapping("/donate") | ||
@RequiredArgsConstructor | ||
@Tag(name = "후원 API") | ||
public class DonateController { | ||
|
||
private final DonateUseCase donateUseCase; | ||
|
||
@PostMapping("/money") | ||
@Operation(summary = "계좌 후원") | ||
public BaseResponseData<DonateResponse> donateMoney(@Valid @RequestBody DonateMoneyRequest donateMoneyRequest) { | ||
return BaseResponseData.ok( | ||
"후원 성공", | ||
donateUseCase.saveBankLog(donateMoneyRequest)); | ||
} | ||
|
||
@PostMapping("/point") | ||
@Operation(summary = "포인트 후원") | ||
public BaseResponseData<DonateResponse> donatePoint(@Valid @RequestBody DonatePointRequest donatePointRequest) { | ||
return BaseResponseData.ok( | ||
"후원 성공", | ||
donateUseCase.savePointLog(donatePointRequest)); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...ain/java/com/project/pieceserver/domain/donate/client/dto/request/DonateMoneyRequest.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,5 @@ | ||
package com.project.pieceserver.domain.donate.client.dto.request; | ||
|
||
public record DonateMoneyRequest( | ||
int money | ||
){} |
5 changes: 5 additions & 0 deletions
5
...ain/java/com/project/pieceserver/domain/donate/client/dto/request/DonatePointRequest.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,5 @@ | ||
package com.project.pieceserver.domain.donate.client.dto.request; | ||
|
||
public record DonatePointRequest( | ||
int point | ||
){} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/project/pieceserver/domain/donate/client/dto/response/DonateResponse.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,8 @@ | ||
package com.project.pieceserver.domain.donate.client.dto.response; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record DonateResponse( | ||
int balance | ||
){} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/project/pieceserver/domain/user/exception/NotEnoughMoneyException.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,14 @@ | ||
package com.project.pieceserver.domain.user.exception; | ||
|
||
import com.project.pieceserver.domain.user.exception.error.UserError; | ||
import com.project.pieceserver.global.exception.BusinessException; | ||
|
||
public class NotEnoughMoneyException extends BusinessException { | ||
|
||
public static final NotEnoughMoneyException EXCEPTION = new NotEnoughMoneyException(); | ||
|
||
private NotEnoughMoneyException() { | ||
super(UserError.NOT_ENOUGH_MONEY); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/project/pieceserver/domain/user/exception/NotEnoughPointException.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,14 @@ | ||
package com.project.pieceserver.domain.user.exception; | ||
|
||
import com.project.pieceserver.domain.user.exception.error.UserError; | ||
import com.project.pieceserver.global.exception.BusinessException; | ||
|
||
public class NotEnoughPointException extends BusinessException { | ||
|
||
public static final NotEnoughPointException EXCEPTION = new NotEnoughPointException(); | ||
|
||
private NotEnoughPointException() { | ||
super(UserError.NOT_ENOUGH_POINT); | ||
} | ||
|
||
} |
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