From 23478a2f9035e1dd218124b91104486b30a06e18 Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 20:25:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat=20-=20#149=20=EB=B0=9B=EC=9D=84=20?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EB=B0=98=ED=99=98=20api=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmh/domain/point/controller/PointApi.java | 17 +++++++++++++++++ .../point/controller/PointController.java | 12 +++++++++++- .../point/dto/response/EarnedPointResponse.java | 6 ++++++ .../point/dto/response/UsagePointResponse.java | 3 ++- .../domain/point/exception/PointSuccess.java | 1 + 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java diff --git a/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java b/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java index 527575ce..97d5eea4 100644 --- a/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java +++ b/src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java @@ -10,6 +10,7 @@ import sopt.org.hmh.domain.point.dto.request.ChallengeDateRequest; import sopt.org.hmh.domain.point.dto.response.ChallengePointStatusListResponse; import sopt.org.hmh.domain.point.dto.response.EarnPointResponse; +import sopt.org.hmh.domain.point.dto.response.EarnedPointResponse; import sopt.org.hmh.domain.point.dto.response.UsagePointResponse; import sopt.org.hmh.domain.point.dto.response.UsePointResponse; import sopt.org.hmh.global.auth.jwt.JwtConstants; @@ -85,4 +86,20 @@ ResponseEntity> orderEarnPointAndChallengeEarned description = "서버 내부 오류입니다.", content = @Content)}) ResponseEntity> orderGetUsagePoint(); + + @Operation( + summary = "받을 포인트 받기 API", + responses = { + @ApiResponse( + responseCode = "200", + description = "사용할 포인트 반환에 성공하였습니다."), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청입니다.", + content = @Content), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류입니다.", + content = @Content)}) + ResponseEntity> orderGetEarnedPoint(); } diff --git a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java index 209b5f2c..5ed744ea 100644 --- a/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java +++ b/src/main/java/sopt/org/hmh/domain/point/controller/PointController.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import sopt.org.hmh.domain.challenge.domain.ChallengeConstants; import sopt.org.hmh.domain.point.dto.request.ChallengeDateRequest; import sopt.org.hmh.domain.point.dto.response.*; import sopt.org.hmh.domain.point.exception.PointSuccess; @@ -57,12 +58,21 @@ public ResponseEntity> orderEarnPointAndChalleng pointFacade.earnPointAndChallengeEarned(userId, challengeDateRequest.challengeDate()))); } + @Override + @GetMapping("/earn") + public ResponseEntity> orderGetEarnedPoint() { + return ResponseEntity + .status(PointSuccess.GET_EARNED_POINT_SUCCESS.getHttpStatus()) + .body(BaseResponse.success(PointSuccess.GET_EARNED_POINT_SUCCESS, + new EarnedPointResponse(ChallengeConstants.EARNED_POINT))); + } + @Override @GetMapping("/use") public ResponseEntity> orderGetUsagePoint() { return ResponseEntity .status(PointSuccess.GET_USAGE_POINT_SUCCESS.getHttpStatus()) .body(BaseResponse.success(PointSuccess.GET_USAGE_POINT_SUCCESS, - pointFacade.getUsagePoint())); + new UsagePointResponse(ChallengeConstants.USAGE_POINT))); } } diff --git a/src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java b/src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java new file mode 100644 index 00000000..85c892a0 --- /dev/null +++ b/src/main/java/sopt/org/hmh/domain/point/dto/response/EarnedPointResponse.java @@ -0,0 +1,6 @@ +package sopt.org.hmh.domain.point.dto.response; + +public record EarnedPointResponse( + Integer earnPoint +) { +} diff --git a/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java b/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java index e394564d..a5b614d0 100644 --- a/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java +++ b/src/main/java/sopt/org/hmh/domain/point/dto/response/UsagePointResponse.java @@ -1,6 +1,7 @@ package sopt.org.hmh.domain.point.dto.response; public record UsagePointResponse( - Integer usagePoint + Integer usagePoint ) { + } diff --git a/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java b/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java index 31cf7471..ea6608e0 100644 --- a/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java +++ b/src/main/java/sopt/org/hmh/domain/point/exception/PointSuccess.java @@ -10,6 +10,7 @@ public enum PointSuccess implements SuccessBase { POINT_USAGE_SUCCESS(HttpStatus.OK, "포인트 사용에 성공하였습니다"), POINT_EARN_SUCCESS(HttpStatus.OK, "포인트 받기에 성공하였습니다"), GET_USAGE_POINT_SUCCESS(HttpStatus.OK, "사용할 포인트 반환에 성공하였습니다"), + GET_EARNED_POINT_SUCCESS(HttpStatus.OK, "받을 포인트 반환에 성공하였습니다"), GET_CHALLENGE_POINT_STATUS_LIST_SUCCESS(HttpStatus.OK, "챌린지 포인트 수령 여부 리스트 조회에 성공하였습니다."), ; From f22435794f3ac5c2f7be8c03090349fa7bcc67b1 Mon Sep 17 00:00:00 2001 From: kseysh Date: Sun, 9 Jun 2024 20:25:30 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor=20-=20#149=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=A0=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?controller=EC=97=90=EC=84=9C=20=ED=95=B4=EA=B2=B0=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/hmh/domain/point/service/PointFacade.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java b/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java index 26cf8b05..c150a476 100644 --- a/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java +++ b/src/main/java/sopt/org/hmh/domain/point/service/PointFacade.java @@ -1,9 +1,7 @@ package sopt.org.hmh.domain.point.service; import java.time.LocalDate; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -52,11 +50,6 @@ public EarnPointResponse earnPointAndChallengeEarned(Long userId, LocalDate chal ); } - @Transactional(readOnly = true) - public UsagePointResponse getUsagePoint() { - return new UsagePointResponse(ChallengeConstants.USAGE_POINT); - } - public ChallengePointStatusListResponse getChallengePointStatusList(Long userId) { Challenge challenge = challengeService.findCurrentChallengeByUserId(userId); List challengePointStatusResponseList =