Skip to content

Commit

Permalink
feat: 야구게임 베팅가능 금액 변경 (#446)
Browse files Browse the repository at this point in the history
* feat: 야구게임 베팅가능 금액 변경

* fix:야구게임 오류 수정

* refactor: 코드리뷰 반영

Co-authored-by: 정핸모 <[email protected]>

* refactor: 코드리뷰 반영

Co-authored-by: 정핸모 <[email protected]>

---------

Co-authored-by: 정핸모 <[email protected]>
  • Loading branch information
yeochaeeon and gusah009 authored May 16, 2024
1 parent 15759c3 commit 6ca749a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.Transactional
const val REDIS_KEY_PREFIX = "baseball_"
const val GUESS_NUMBER_LENGTH = 4
const val TRY_COUNT = 9
const val MAX_BETTING_POINT = 5000L
const val MAX_BETTING_POINT = 3000L
const val MIN_BETTING_POINT = 1000L
const val BETTING_POINT_MESSAGE = "야구 게임 베팅"
const val EARN_POINT_MESSAGE = "야구 게임 획득"
Expand Down Expand Up @@ -66,6 +66,10 @@ class BaseballService(
if (bettingPoint <= 0) {
throw BusinessException(requestMember.id, "memberId", ErrorCode.POINT_MUST_BE_POSITIVE)
}
if (bettingPoint !in MIN_BETTING_POINT.. MAX_BETTING_POINT) {
throw BusinessException(requestMember.id, "memberId", ErrorCode.INVALID_BETTING_POINT)
}

if (requestMember.point < bettingPoint) {
throw BusinessException(requestMember.id, "memberId", ErrorCode.NOT_ENOUGH_POINT)
}
Expand Down Expand Up @@ -130,6 +134,7 @@ class BaseballService(
val earnablePoint = baseballResultEntity.earnablePoint

if (baseballResultEntity.isEnd()) {
earnablePoint * 2
requestMember.addPoint(earnablePoint, EARN_POINT_MESSAGE)
gameEntity.baseball.baseballDayPoint = earnablePoint
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public enum ErrorCode {
NOT_ENOUGH_POINT("베팅 포인트는 보유한 포인트보다 많을 수 없습니다.", HttpStatus.BAD_REQUEST),
POINT_MUST_BE_POSITIVE("베팅 포인트는 양수여야 합니다.", HttpStatus.BAD_REQUEST),
NOT_PLAYED_YET("아직 게임을 시작하지 않았습니다.", HttpStatus.BAD_REQUEST),
INVALID_BETTING_POINT("베팅포인트는 " + MIN_BETTING_POINT + "이상 " + MAX_BETTING_POINT + "이하의 숫자여야합니다",HttpStatus.BAD_REQUEST),
// FILE
FILE_NOT_FOUND("해당 파일은 존재하지 않습니다.", HttpStatus.BAD_REQUEST),
// ATTENDANCE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class GameControllerTest : GameApiTestHelper() {
.andExpect(status().isOk)
.andExpect(jsonPath("$.guessNumberLength").value(4))
.andExpect(jsonPath("$.tryCount").value(9))
.andExpect(jsonPath("$.maxBettingPoint").value(5000L))
.andExpect(jsonPath("$.maxBettingPoint").value(3000L))
.andExpect(jsonPath("$.minBettingPoint").value(1000L))
.andDo(
document(
Expand Down

0 comments on commit 6ca749a

Please sign in to comment.