전투시스템 중복 시간체크

전투시스템 이벤트 아이디 dynamodb 기준관리
This commit is contained in:
2025-02-18 15:54:26 +09:00
parent 78cc70488a
commit 255c2e13c9
13 changed files with 230 additions and 48 deletions

View File

@@ -26,8 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -126,12 +124,17 @@ public class BattleEventService {
battleEventRequest.setEventOperationTime(operation_time);
// int is_time = battleMapper.chkTimeOver(battleEventRequest);
// if(is_time > 0){
// return BattleEventResponse.builder()
// .status(CommonCode.ERROR.getHttpStatus())
// .result(ErrorCode.ERROR_BATTLE_EVENT_TIME_OVER.toString())
// .build();
// }
List<BattleEvent> existingList = battleMapper.getCheckBattleEventList(battleEventRequest);
boolean isTime = isTimeOverlapping(existingList, battleEventRequest);
if(isTime){
return BattleEventResponse.builder()
.status(CommonCode.ERROR.getHttpStatus())
.result(ErrorCode.ERROR_BATTLE_EVENT_TIME_OVER.toString())
.build();
}
int next_event_id = dynamodbBattleEventService.getEventId() + 1;
battleEventRequest.setEventId(next_event_id);
int result = battleMapper.postBattleEvent(battleEventRequest);
log.info("AdminToolDB BattleEvent Save: {}", battleEventRequest);
@@ -171,10 +174,10 @@ public class BattleEventService {
BattleEvent before_info = battleMapper.getBattleEventDetail(id);
if(!before_info.getStatus().equals(LandAuction.AUCTION_STATUS.WAIT) && !before_info.getStatus().equals(LandAuction.AUCTION_STATUS.RESV_START)){
if(!before_info.getStatus().equals(BattleEvent.BATTLE_STATUS.STOP)){
return BattleEventResponse.builder()
.status(CommonCode.ERROR.getHttpStatus())
.result(ErrorCode.ERROR_AUCTION_STATUS_IMPOSSIBLE.toString())
.result(ErrorCode.ERROR_BATTLE_EVENT_STATUS_IMPOSSIBLE.toString())
.build();
}
@@ -284,6 +287,18 @@ public class BattleEventService {
int total_time = round_time + ((round_count - 1) * (round_time + round_wait_time)) + result_wait_time + server_wait_time;
return total_time;
return total_time; // 초
}
private boolean isTimeOverlapping(List<BattleEvent> existingList, BattleEventRequest battleEventRequest){
LocalTime newStartTime = battleEventRequest.getEventStartDt().toLocalTime();
LocalTime newEndTime = newStartTime.plusSeconds(battleEventRequest.getEventOperationTime());
return existingList.stream().anyMatch(schedule -> {
LocalTime existingStartTime = schedule.getEventStartDt().toLocalTime();
LocalTime existingEndTime = existingStartTime.plusSeconds(schedule.getEventOperationTime());
return !existingStartTime.isAfter(newEndTime) && !newStartTime.isAfter(existingEndTime);
});
}
}