Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@EnableJpaAuditing
@EnableRetry
@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sejongisc.backend.betting.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
Expand All @@ -24,6 +25,10 @@ public class UserBetRequest {
@JsonProperty("isFree")
private boolean free;

@Min(value = 10, message = "베팅 포인트는 10 이상이어야 합니다.")
private Integer stakePoints;

@AssertTrue(message = "베팅 시 포인트는 10 이상이어야 합니다.")
public boolean isStakePointsValid() {
return free || (stakePoints != null && stakePoints >= 10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public UserBet postUserBet(UUID userId, UserBetRequest userBetRequest) {
int stake = 0;

if (!userBetRequest.isFree()) {
if (!userBetRequest.isStakePointsValid()) {
throw new CustomException(ErrorCode.BET_POINT_TOO_LOW);
}
pointHistoryService.createPointHistory(
userId,
-userBetRequest.getStakePoints(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public enum ErrorCode {
BET_DUPLICATE(HttpStatus.CONFLICT, "이미 이 라운드에 베팅했습니다."),
BET_TIME_INVALID(HttpStatus.CONFLICT, "베팅 가능 시간이 아닙니다."),
BET_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 베팅을 찾을 수 없습니다."),
BET_ROUND_CLOSED(HttpStatus.CONFLICT, "이미 마감된 라운드입니다.");
BET_ROUND_CLOSED(HttpStatus.CONFLICT, "이미 마감된 라운드입니다."),
BET_POINT_TOO_LOW(HttpStatus.CONFLICT, "베팅 포인트는 10 이상이어야 합니다.");

private final HttpStatus status;
private final String message;
Expand Down