Skip to content

Commit

Permalink
Merge pull request #118 from softeerbootcamp4th/feat/#117-dto-fix
Browse files Browse the repository at this point in the history
Feat/#117 dto fix
  • Loading branch information
wjddn2165 authored Aug 13, 2024
2 parents 526b988 + 15f6484 commit c45ef28
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package JGS.CasperEvent.domain.event.dto.RequestDto.rushEventDto;

import JGS.CasperEvent.global.enums.Position;
import lombok.Getter;
import lombok.ToString;

@ToString
@Getter
public class RushEventOptionRequestDto {
private Long rushOptionId;
private Position position;
private String mainText;
private String subText;
private String resultMainText;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
package JGS.CasperEvent.domain.event.dto.RequestDto.rushEventDto;

import com.fasterxml.jackson.annotation.JsonProperty;
import JGS.CasperEvent.global.enums.CustomErrorCode;
import JGS.CasperEvent.global.enums.Position;
import JGS.CasperEvent.global.error.exception.CustomException;
import lombok.Getter;
import lombok.ToString;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Set;

@ToString
@Getter
public class RushEventRequestDto {
private Long rushEventId;
private LocalDate eventDate;
private LocalTime startTime;
private LocalTime endTime;
private int winnerCount;
private String prizeDescription;
@JsonProperty("leftOption")
private RushEventOptionRequestDto leftOption;
@JsonProperty("rightOption")
private RushEventOptionRequestDto rightOption;
private Set<RushEventOptionRequestDto> options;

public RushEventOptionRequestDto getLeftOption() {
return options.stream()
.filter(option -> option.getPosition() == Position.LEFT)
.findFirst().orElseThrow(() -> new CustomException(CustomErrorCode.INVALID_RUSH_EVENT_OPTION));
}

public RushEventOptionRequestDto getRightOption() {
return options.stream()
.filter(option -> option.getPosition() == Position.RIGHT)
.findFirst().orElseThrow(() -> new CustomException(CustomErrorCode.INVALID_RUSH_EVENT_OPTION));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public RushEvent(LocalDateTime startDateTime, LocalDateTime endDateTime,
this.prizeDescription = prizeDescription;
}

public void updateOption(RushOption leftOption, RushOption rightOption){
public void addOption(RushOption leftOption, RushOption rightOption){
this.options.add(leftOption);
this.options.add(rightOption);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public enum CustomErrorCode {
EVENT_IN_PROGRESS_CANNOT_CHANGE_START_TIME("현재 진행 중인 이벤트의 시작 시간을 변경할 수 없습니다.", 400),
EVENT_IN_PROGRESS_END_TIME_BEFORE_NOW("현재 진행 중인 이벤트의 종료 시간을 현재 시간보다 이전으로 설정할 수 없습니다.", 400),
EVENT_BEFORE_START_TIME("이벤트 시작 시간은 현재 시간 이후로 설정해야 합니다.", 400),
EVENT_END_TIME_BEFORE_START_TIME("종료 시간은 시작 시간 이후로 설정해야 합니다.", 400);
EVENT_END_TIME_BEFORE_START_TIME("종료 시간은 시작 시간 이후로 설정해야 합니다.", 400),
INVALID_RUSH_EVENT_OPTION("밸런스 게임 선택지가 유효하지 않습니다.");



private final String message;
Expand Down

0 comments on commit c45ef28

Please sign in to comment.