Skip to content

Commit

Permalink
refactor: 중복 코드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
k000927 committed Aug 21, 2024
1 parent ba124ed commit 574bb2d
Showing 1 changed file with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,28 @@ public AdminRushEventResponseDto createRushEvent(RushEventRequestDto rushEventRe
RushEventOptionRequestDto leftOption = rushEventRequestDto.getLeftOptionRequestDto();
RushEventOptionRequestDto rightOption = rushEventRequestDto.getRightOptionRequestDto();

RushOption leftRushOption = rushOptionRepository.save(new RushOption(
rushEvent,
leftOption.getMainText(),
leftOption.getSubText(),
leftOption.getResultMainText(),
leftOption.getResultSubText(),
leftOptionImgSrc,
Position.LEFT
));

RushOption rightRushOption = rushOptionRepository.save(new RushOption(
rushEvent,
rightOption.getMainText(),
rightOption.getSubText(),
rightOption.getResultMainText(),
rightOption.getResultSubText(),
rightOptionImgSrc,
Position.RIGHT
));
RushOption leftRushOption = createAndSaveRushOption(rushEvent, leftOption, leftOptionImgSrc, Position.LEFT);
RushOption rightRushOption = createAndSaveRushOption(rushEvent, rightOption, rightOptionImgSrc, Position.RIGHT);

rushEvent.addOption(leftRushOption, rightRushOption);
return AdminRushEventResponseDto.of(rushEvent);
}

public RushOption createAndSaveRushOption(RushEvent rushEvent, RushEventOptionRequestDto optionDto, String imgSrc, Position position) {

RushOption rushOption = new RushOption(
rushEvent,
optionDto.getMainText(),
optionDto.getSubText(),
optionDto.getResultMainText(),
optionDto.getResultSubText(),
imgSrc,
position
);

return rushOptionRepository.save(rushOption);
}

// 선착순 이벤트 조회
public List<AdminRushEventResponseDto> getRushEvents() {
List<RushEvent> rushEvents = rushEventRepository.findAll();
Expand Down Expand Up @@ -555,7 +553,6 @@ public void deleteLotteryEventExpectation(Long casperId) {
() -> new CustomException(CustomErrorCode.CASPERBOT_NOT_FOUND)
);

// todo: config에서 가져오도록 변경
final String LIST_KEY = "recentData";

// 긍정적인 문구 리스트
Expand Down

0 comments on commit 574bb2d

Please sign in to comment.