Skip to content

Commit dcace4f

Browse files
authored
[BE] SISC1-52 [FIX] 베팅 게임 버그 수정 (#74)
1 parent 8028b8b commit dcace4f

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

backend/src/main/java/org/sejongisc/backend/BackendApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
66
import org.springframework.retry.annotation.EnableRetry;
7+
import org.springframework.scheduling.annotation.EnableScheduling;
78

9+
@EnableScheduling
810
@EnableJpaAuditing
911
@EnableRetry
1012
@SpringBootApplication

backend/src/main/java/org/sejongisc/backend/betting/dto/UserBetRequest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.sejongisc.backend.betting.dto;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import jakarta.validation.constraints.AssertTrue;
45
import jakarta.validation.constraints.Min;
56
import jakarta.validation.constraints.NotNull;
67
import lombok.AllArgsConstructor;
@@ -24,6 +25,10 @@ public class UserBetRequest {
2425
@JsonProperty("isFree")
2526
private boolean free;
2627

27-
@Min(value = 10, message = "베팅 포인트는 10 이상이어야 합니다.")
2828
private Integer stakePoints;
29+
30+
@AssertTrue(message = "베팅 시 포인트는 10 이상이어야 합니다.")
31+
public boolean isStakePointsValid() {
32+
return free || (stakePoints != null && stakePoints >= 10);
33+
}
2934
}

backend/src/main/java/org/sejongisc/backend/betting/service/BettingService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public UserBet postUserBet(UUID userId, UserBetRequest userBetRequest) {
102102
int stake = 0;
103103

104104
if (!userBetRequest.isFree()) {
105+
if (!userBetRequest.isStakePointsValid()) {
106+
throw new CustomException(ErrorCode.BET_POINT_TOO_LOW);
107+
}
105108
pointHistoryService.createPointHistory(
106109
userId,
107110
-userBetRequest.getStakePoints(),

backend/src/main/java/org/sejongisc/backend/common/exception/ErrorCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public enum ErrorCode {
6565
BET_DUPLICATE(HttpStatus.CONFLICT, "이미 이 라운드에 베팅했습니다."),
6666
BET_TIME_INVALID(HttpStatus.CONFLICT, "베팅 가능 시간이 아닙니다."),
6767
BET_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 베팅을 찾을 수 없습니다."),
68-
BET_ROUND_CLOSED(HttpStatus.CONFLICT, "이미 마감된 라운드입니다.");
68+
BET_ROUND_CLOSED(HttpStatus.CONFLICT, "이미 마감된 라운드입니다."),
69+
BET_POINT_TOO_LOW(HttpStatus.CONFLICT, "베팅 포인트는 10 이상이어야 합니다.");
6970

7071
private final HttpStatus status;
7172
private final String message;

0 commit comments

Comments
 (0)