From e461a23d1d14a0bf64f4f90f10d9351815628372 Mon Sep 17 00:00:00 2001 From: yeochaeeon Date: Thu, 9 May 2024 14:23:52 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EC=95=BC=EA=B5=AC=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20=EB=B2=A0=ED=8C=85=EA=B0=80=EB=8A=A5=20=EA=B8=88?= =?UTF-8?q?=EC=95=A1=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/game/application/BaseballService.kt | 10 +++++++--- .../com/keeper/homepage/global/error/ErrorCode.java | 1 + .../homepage/domain/game/api/GameControllerTest.kt | 2 +- 3 files changed, 9 insertions(+), 4 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..e31e620a2 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 1000..3000) { + throw BusinessException(requestMember.id, "memberId", ErrorCode.INVALID_BETTING_POINT) + } + if (requestMember.point < bettingPoint) { throw BusinessException(requestMember.id, "memberId", ErrorCode.NOT_ENOUGH_POINT) } @@ -130,8 +134,8 @@ class BaseballService( val earnablePoint = baseballResultEntity.earnablePoint if (baseballResultEntity.isEnd()) { - requestMember.addPoint(earnablePoint, EARN_POINT_MESSAGE) - gameEntity.baseball.baseballDayPoint = earnablePoint + requestMember.addPoint(earnablePoint*2, EARN_POINT_MESSAGE) + gameEntity.baseball.baseballDayPoint = earnablePoint*2 } return BaseballResponse( 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..90459d7fa 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("베팅포인트는 1000이상 3000이하의 숫자여야합니다",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( From c65d5e2f49ea748b992ef26d52e786e50e9c0573 Mon Sep 17 00:00:00 2001 From: yeochaeeon Date: Fri, 10 May 2024 17:03:06 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=EC=95=BC=EA=B5=AC=EA=B2=8C=EC=9E=84=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homepage/domain/game/application/BaseballService.kt | 5 +++-- 1 file changed, 3 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 e31e620a2..b21df40b2 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 @@ -134,8 +134,9 @@ class BaseballService( val earnablePoint = baseballResultEntity.earnablePoint if (baseballResultEntity.isEnd()) { - requestMember.addPoint(earnablePoint*2, EARN_POINT_MESSAGE) - gameEntity.baseball.baseballDayPoint = earnablePoint*2 + earnablePoint * 2 + requestMember.addPoint(earnablePoint, EARN_POINT_MESSAGE) + gameEntity.baseball.baseballDayPoint = earnablePoint } return BaseballResponse( From 4b007a57f8499a3e7e1bdf240d9370c1f929424d Mon Sep 17 00:00:00 2001 From: iamchaeeon <129289883+yeochaeeon@users.noreply.github.com> Date: Sat, 11 May 2024 21:53:39 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 정핸모 --- .../keeper/homepage/domain/game/application/BaseballService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b21df40b2..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 @@ -66,7 +66,7 @@ class BaseballService( if (bettingPoint <= 0) { throw BusinessException(requestMember.id, "memberId", ErrorCode.POINT_MUST_BE_POSITIVE) } - if (bettingPoint !in 1000..3000) { + if (bettingPoint !in MIN_BETTING_POINT.. MAX_BETTING_POINT) { throw BusinessException(requestMember.id, "memberId", ErrorCode.INVALID_BETTING_POINT) } From 08f648dacf0355d730b37ffee2766dee6e0e12a0 Mon Sep 17 00:00:00 2001 From: iamchaeeon <129289883+yeochaeeon@users.noreply.github.com> Date: Sat, 11 May 2024 21:54:08 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 정핸모 --- src/main/java/com/keeper/homepage/global/error/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 90459d7fa..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,7 +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("베팅포인트는 1000이상 3000이하의 숫자여야합니다",HttpStatus.BAD_REQUEST), + INVALID_BETTING_POINT("베팅포인트는 " + MIN_BETTING_POINT + "이상 " + MAX_BETTING_POINT + "이하의 숫자여야합니다",HttpStatus.BAD_REQUEST), // FILE FILE_NOT_FOUND("해당 파일은 존재하지 않습니다.", HttpStatus.BAD_REQUEST), // ATTENDANCE