From 6ca749a6ab4ea4121950b216091880d5cc696d19 Mon Sep 17 00:00:00 2001 From: iamchaeeon <129289883+yeochaeeon@users.noreply.github.com> Date: Thu, 16 May 2024 15:43:06 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=95=BC=EA=B5=AC=EA=B2=8C=EC=9E=84=20?= =?UTF-8?q?=EB=B2=A0=ED=8C=85=EA=B0=80=EB=8A=A5=20=EA=B8=88=EC=95=A1=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20(#446)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 야구게임 베팅가능 금액 변경 * fix:야구게임 오류 수정 * refactor: 코드리뷰 반영 Co-authored-by: 정핸모 * refactor: 코드리뷰 반영 Co-authored-by: 정핸모 --------- Co-authored-by: 정핸모 --- .../homepage/domain/game/application/BaseballService.kt | 7 ++++++- .../java/com/keeper/homepage/global/error/ErrorCode.java | 1 + .../keeper/homepage/domain/game/api/GameControllerTest.kt | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/keeper/homepage/domain/game/application/BaseballService.kt b/src/main/java/com/keeper/homepage/domain/game/application/BaseballService.kt index b55dad1ae..6c95a58c0 100644 --- a/src/main/java/com/keeper/homepage/domain/game/application/BaseballService.kt +++ b/src/main/java/com/keeper/homepage/domain/game/application/BaseballService.kt @@ -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 = "야구 게임 획득" @@ -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) } @@ -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 } diff --git a/src/main/java/com/keeper/homepage/global/error/ErrorCode.java b/src/main/java/com/keeper/homepage/global/error/ErrorCode.java index 7f57a78d4..658a81d99 100644 --- a/src/main/java/com/keeper/homepage/global/error/ErrorCode.java +++ b/src/main/java/com/keeper/homepage/global/error/ErrorCode.java @@ -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 diff --git a/src/test/java/com/keeper/homepage/domain/game/api/GameControllerTest.kt b/src/test/java/com/keeper/homepage/domain/game/api/GameControllerTest.kt index 10da98164..f3c94dfa3 100644 --- a/src/test/java/com/keeper/homepage/domain/game/api/GameControllerTest.kt +++ b/src/test/java/com/keeper/homepage/domain/game/api/GameControllerTest.kt @@ -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(