Skip to content

Commit

Permalink
Merge pull request #157 from Team-HMH/feat/#149-get-earned-point-api
Browse files Browse the repository at this point in the history
feat: ๋ฐ›์„ ํฌ์ธํŠธ ๋ฐ˜ํ™˜ api
  • Loading branch information
kseysh authored Jun 9, 2024
2 parents 23af87d + f224357 commit 7b42e37
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
17 changes: 17 additions & 0 deletions src/main/java/sopt/org/hmh/domain/point/controller/PointApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,4 +86,20 @@ ResponseEntity<BaseResponse<EarnPointResponse>> orderEarnPointAndChallengeEarned
description = "์„œ๋ฒ„ ๋‚ด๋ถ€ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.",
content = @Content)})
ResponseEntity<BaseResponse<UsagePointResponse>> orderGetUsagePoint();

@Operation(
summary = "๋ฐ›์„ ํฌ์ธํŠธ ๋ฐ›๊ธฐ API",
responses = {
@ApiResponse(
responseCode = "200",
description = "์‚ฌ์šฉํ•  ํฌ์ธํŠธ ๋ฐ˜ํ™˜์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
@ApiResponse(
responseCode = "400",
description = "์ž˜๋ชป๋œ ์š”์ฒญ์ž…๋‹ˆ๋‹ค.",
content = @Content),
@ApiResponse(
responseCode = "500",
description = "์„œ๋ฒ„ ๋‚ด๋ถ€ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.",
content = @Content)})
ResponseEntity<BaseResponse<EarnedPointResponse>> orderGetEarnedPoint();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,12 +58,21 @@ public ResponseEntity<BaseResponse<EarnPointResponse>> orderEarnPointAndChalleng
pointFacade.earnPointAndChallengeEarned(userId, challengeDateRequest.challengeDate())));
}

@Override
@GetMapping("/earn")
public ResponseEntity<BaseResponse<EarnedPointResponse>> 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<BaseResponse<UsagePointResponse>> 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)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package sopt.org.hmh.domain.point.dto.response;

public record EarnedPointResponse(
Integer earnPoint
) {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sopt.org.hmh.domain.point.dto.response;

public record UsagePointResponse(
Integer usagePoint
Integer usagePoint
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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, "์ฑŒ๋ฆฐ์ง€ ํฌ์ธํŠธ ์ˆ˜๋ น ์—ฌ๋ถ€ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."),
;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<ChallengePointStatusResponse> challengePointStatusResponseList =
Expand Down

0 comments on commit 7b42e37

Please sign in to comment.