전투시스템 중지 처리
This commit is contained in:
@@ -53,6 +53,13 @@ public class BattleController {
|
|||||||
return ResponseEntity.ok().body(battleEventService.updateBattleEvent(id, battleEventRequest));
|
return ResponseEntity.ok().body(battleEventService.updateBattleEvent(id, battleEventRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/event/stop/{id}")
|
||||||
|
public ResponseEntity<BattleEventResponse> updateStopBattleEvent(
|
||||||
|
@PathVariable("id")Long id, @RequestBody BattleEventRequest battleEventRequest){
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(battleEventService.updateStopBattleEvent(id, battleEventRequest));
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping("/event/delete")
|
@DeleteMapping("/event/delete")
|
||||||
public ResponseEntity<BattleEventResponse> deleteBattleEvent(
|
public ResponseEntity<BattleEventResponse> deleteBattleEvent(
|
||||||
@RequestBody BattleEventRequest battleEventRequest){
|
@RequestBody BattleEventRequest battleEventRequest){
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class BattleEvent {
|
|||||||
STOP,
|
STOP,
|
||||||
END,
|
END,
|
||||||
FAIL,
|
FAIL,
|
||||||
|
CANCEL,
|
||||||
RUNNING
|
RUNNING
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,15 @@ public class BattleEventService {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 일자만 필요해서 UTC시간으로 변경되다보니 한국시간(+9)을 더해서 마지막시간으로 설정
|
||||||
|
LocalDateTime end_dt_kst = battleEventRequest.getEventEndDt()
|
||||||
|
.plusHours(9)
|
||||||
|
.withHour(23)
|
||||||
|
.withMinute(59)
|
||||||
|
.withSecond(59)
|
||||||
|
.withNano(0);
|
||||||
|
battleEventRequest.setEventEndDt(end_dt_kst);
|
||||||
|
|
||||||
int next_event_id = dynamodbBattleEventService.getEventId() + 1;
|
int next_event_id = dynamodbBattleEventService.getEventId() + 1;
|
||||||
battleEventRequest.setEventId(next_event_id);
|
battleEventRequest.setEventId(next_event_id);
|
||||||
|
|
||||||
@@ -181,6 +190,15 @@ public class BattleEventService {
|
|||||||
.build();
|
.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 result = battleMapper.updateBattleEvent(battleEventRequest);
|
int result = battleMapper.updateBattleEvent(battleEventRequest);
|
||||||
log.info("AdminToolDB BattleEvent Update Complete: {}", battleEventRequest);
|
log.info("AdminToolDB BattleEvent Update Complete: {}", battleEventRequest);
|
||||||
|
|
||||||
@@ -199,7 +217,50 @@ public class BattleEventService {
|
|||||||
CommonUtils.getClientIp()
|
CommonUtils.getClientIp()
|
||||||
);
|
);
|
||||||
|
|
||||||
// dynamodbLandAuctionService.updateLandAuction(landRequest);
|
dynamodbBattleEventService.updateBattleEvent(battleEventRequest);
|
||||||
|
|
||||||
|
return BattleEventResponse.builder()
|
||||||
|
.resultData(BattleEventResponse.ResultData.builder()
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(transactionManager = "transactionManager")
|
||||||
|
public BattleEventResponse updateStopBattleEvent(Long id, BattleEventRequest battleEventRequest){
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
|
||||||
|
BattleEvent info = battleMapper.getBattleEventDetail(id);
|
||||||
|
|
||||||
|
if(info.getStatus().equals(BattleEvent.BATTLE_STATUS.RUNNING)){
|
||||||
|
return BattleEventResponse.builder()
|
||||||
|
.status(CommonCode.ERROR.getHttpStatus())
|
||||||
|
.result(ErrorCode.ERROR_BATTLE_EVENT_STATUS_START_IMPOSSIBLE.toString())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
map.put("id", id);
|
||||||
|
map.put("status", BattleEvent.BATTLE_STATUS.STOP);
|
||||||
|
map.put("updateBy", CommonUtils.getAdmin().getId());
|
||||||
|
int result = battleMapper.updateStatusBattleEvent(map);
|
||||||
|
try{
|
||||||
|
log.info("BattleEvent Stop Complete: {}", objectMapper.writeValueAsString(info));
|
||||||
|
}catch(Exception e){
|
||||||
|
log.error("BattleEvent Stop Failed: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
mysqlHistoryLogService.updateHistoryLog(
|
||||||
|
HISTORYTYPE.BATTLE_EVENT_UPDATE,
|
||||||
|
MysqlConstants.TABLE_NAME_BATTLE_EVENT,
|
||||||
|
HISTORYTYPE.BATTLE_EVENT_UPDATE.name(),
|
||||||
|
info,
|
||||||
|
battleMapper.getBattleEventDetail(id),
|
||||||
|
CommonUtils.getAdmin().getEmail(),
|
||||||
|
CommonUtils.getClientIp()
|
||||||
|
);
|
||||||
|
|
||||||
|
dynamodbBattleEventService.updateStopBattleEvent(info);
|
||||||
|
|
||||||
return BattleEventResponse.builder()
|
return BattleEventResponse.builder()
|
||||||
.resultData(BattleEventResponse.ResultData.builder()
|
.resultData(BattleEventResponse.ResultData.builder()
|
||||||
@@ -219,7 +280,7 @@ public class BattleEventService {
|
|||||||
Long id = item.getId();
|
Long id = item.getId();
|
||||||
BattleEvent info = battleMapper.getBattleEventDetail(id);
|
BattleEvent info = battleMapper.getBattleEventDetail(id);
|
||||||
|
|
||||||
if(!info.getStatus().equals(LandAuction.AUCTION_STATUS.WAIT) && !info.getStatus().equals(LandAuction.AUCTION_STATUS.RESV_START)){
|
if(!info.getStatus().equals(BattleEvent.BATTLE_STATUS.STOP)){
|
||||||
is_falil.set(true);
|
is_falil.set(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.caliverse.admin.dynamodb.repository;
|
package com.caliverse.admin.dynamodb.repository;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.BattleEvent;
|
||||||
import com.caliverse.admin.domain.request.BattleEventRequest;
|
import com.caliverse.admin.domain.request.BattleEventRequest;
|
||||||
import com.caliverse.admin.dynamodb.domain.doc.BattleEventDoc;
|
import com.caliverse.admin.dynamodb.domain.doc.BattleEventDoc;
|
||||||
|
|
||||||
public interface BattleEventRepository extends DynamoDBRepository<BattleEventDoc> {
|
public interface BattleEventRepository extends DynamoDBRepository<BattleEventDoc> {
|
||||||
int findEventId();
|
int findEventId();
|
||||||
void insert(BattleEventRequest battleEventRequest);
|
void insert(BattleEventRequest battleEventRequest);
|
||||||
void updateStop(BattleEventRequest battleEventRequest);
|
void update(BattleEventRequest battleEventRequest);
|
||||||
|
void delete(BattleEventRequest battleEventRequest);
|
||||||
|
void updateStop(BattleEvent battleEvent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
|||||||
|
|
||||||
if (docs.isEmpty()) return 0;
|
if (docs.isEmpty()) return 0;
|
||||||
|
|
||||||
BattleEventDoc latestDoc = docs.stream().max(Comparator.comparing(BattleEventDoc::getSK))
|
BattleEventDoc latestDoc = docs.stream().max(Comparator.comparing(doc -> Integer.parseInt(doc.getSK())))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -59,8 +59,24 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEvent(Integer sk){
|
||||||
|
Key key = Key.builder()
|
||||||
|
.partitionValue(DynamoDBConstants.PK_KEY_BATTLE_EVENT)
|
||||||
|
.sortValue(String.valueOf(sk))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
BattleEventDoc doc = findById(key);
|
||||||
|
|
||||||
|
return doc != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insert(BattleEventRequest battleEventRequest) {
|
public void insert(BattleEventRequest battleEventRequest) {
|
||||||
|
if(isEvent(battleEventRequest.getEventId())){
|
||||||
|
log.error("insert EventId: {} is duplication", battleEventRequest.getEventId());
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
LocalDateTime nowDate = LocalDateTime.now();
|
LocalDateTime nowDate = LocalDateTime.now();
|
||||||
LocalDateTime start_dt = battleEventRequest.getEventStartDt();
|
LocalDateTime start_dt = battleEventRequest.getEventStartDt();
|
||||||
BattleEvent.BATTLE_REPEAT_TYPE repeatType = battleEventRequest.getRepeatType();
|
BattleEvent.BATTLE_REPEAT_TYPE repeatType = battleEventRequest.getRepeatType();
|
||||||
@@ -90,7 +106,7 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
|||||||
|
|
||||||
BattleEventDoc doc = new BattleEventDoc();
|
BattleEventDoc doc = new BattleEventDoc();
|
||||||
doc.setPK(DynamoDBConstants.PK_KEY_BATTLE_EVENT);
|
doc.setPK(DynamoDBConstants.PK_KEY_BATTLE_EVENT);
|
||||||
doc.setSK(String.valueOf(battleEventRequest.getId()));
|
doc.setSK(String.valueOf(battleEventRequest.getEventId()));
|
||||||
doc.setDocType(DynamoDBConstants.DOC_BATTLE_EVENT);
|
doc.setDocType(DynamoDBConstants.DOC_BATTLE_EVENT);
|
||||||
doc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
doc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||||
doc.setCreatedDateTime(convertUTCDate(nowDate));
|
doc.setCreatedDateTime(convertUTCDate(nowDate));
|
||||||
@@ -114,11 +130,64 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStop(BattleEventRequest battleEventRequest) {
|
public void update(BattleEventRequest battleEventRequest) {
|
||||||
|
LocalDateTime nowDate = LocalDateTime.now();
|
||||||
|
LocalDateTime start_dt = battleEventRequest.getEventStartDt();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Key key = Key.builder()
|
Key key = Key.builder()
|
||||||
.partitionValue(DynamoDBConstants.PK_KEY_BATTLE_EVENT)
|
.partitionValue(DynamoDBConstants.PK_KEY_BATTLE_EVENT)
|
||||||
.sortValue(battleEventRequest.getId())
|
.sortValue(String.valueOf(battleEventRequest.getEventId()))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
BattleEventDoc beforeDoc = findById(key);
|
||||||
|
|
||||||
|
if (beforeDoc != null) {
|
||||||
|
BattleEventDoc afterDoc = deepCopy(beforeDoc, BattleEventDoc.class);
|
||||||
|
|
||||||
|
BattleEventAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), BattleEventAttrib.class);
|
||||||
|
attrib.setStartDay(stringToISODateTime(start_dt.toLocalDate().atStartOfDay()));
|
||||||
|
attrib.setStartHour(start_dt.getHour());
|
||||||
|
attrib.setStartMin(start_dt.getMinute());
|
||||||
|
attrib.setEndDate(stringToISODateTime(battleEventRequest.getEventEndDt()));
|
||||||
|
attrib.setConfigDataId(battleEventRequest.getConfigId());
|
||||||
|
attrib.setRewardGroupId(battleEventRequest.getRewardGroupId());
|
||||||
|
attrib.setHotTime(battleEventRequest.getHotTime());
|
||||||
|
attrib.setRoundCount(battleEventRequest.getRoundCount());
|
||||||
|
attrib.setActive(true);
|
||||||
|
|
||||||
|
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||||
|
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(nowDate));
|
||||||
|
|
||||||
|
update(afterDoc);
|
||||||
|
|
||||||
|
log.info("BattleEventDoc Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||||
|
|
||||||
|
dynamodbHistoryLogService.updateHistoryLog(
|
||||||
|
HISTORYTYPE.BATTLE_EVENT_UPDATE,
|
||||||
|
HISTORYTYPE.BATTLE_EVENT_UPDATE.name(),
|
||||||
|
beforeDoc,
|
||||||
|
afterDoc,
|
||||||
|
CommonUtils.getAdmin().getEmail(),
|
||||||
|
CommonUtils.getClientIp()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(BattleEventRequest battleEventRequest) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateStop(BattleEvent battleEvent) {
|
||||||
|
try {
|
||||||
|
Key key = Key.builder()
|
||||||
|
.partitionValue(DynamoDBConstants.PK_KEY_BATTLE_EVENT)
|
||||||
|
.sortValue(String.valueOf(battleEvent.getEventId()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
BattleEventDoc beforeDoc = findById(key);
|
BattleEventDoc beforeDoc = findById(key);
|
||||||
@@ -134,11 +203,11 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
|
|||||||
|
|
||||||
update(afterDoc);
|
update(afterDoc);
|
||||||
|
|
||||||
log.info("BattleEventDoc Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
log.info("BattleEventDoc Update Stop Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||||
|
|
||||||
dynamodbHistoryLogService.updateHistoryLog(
|
dynamodbHistoryLogService.updateHistoryLog(
|
||||||
HISTORYTYPE.BATTLE_EVENT_DELETE,
|
HISTORYTYPE.BATTLE_EVENT_UPDATE,
|
||||||
HISTORYTYPE.BATTLE_EVENT_DELETE.name(),
|
HISTORYTYPE.BATTLE_EVENT_UPDATE.name(),
|
||||||
beforeDoc,
|
beforeDoc,
|
||||||
afterDoc,
|
afterDoc,
|
||||||
CommonUtils.getAdmin().getEmail(),
|
CommonUtils.getAdmin().getEmail(),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.caliverse.admin.dynamodb.service;
|
package com.caliverse.admin.dynamodb.service;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.BattleEvent;
|
||||||
import com.caliverse.admin.domain.request.BattleEventRequest;
|
import com.caliverse.admin.domain.request.BattleEventRequest;
|
||||||
import com.caliverse.admin.dynamodb.repository.BattleEventRepository;
|
import com.caliverse.admin.dynamodb.repository.BattleEventRepository;
|
||||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||||
@@ -18,12 +19,18 @@ public class DynamodbBattleEventService {
|
|||||||
battleEventRepository.insert(battleEventRequest);
|
battleEventRepository.insert(battleEventRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DynamoDBTransaction
|
||||||
|
public void updateBattleEvent(BattleEventRequest battleEventRequest) {
|
||||||
|
battleEventRepository.update(battleEventRequest);
|
||||||
|
}
|
||||||
|
|
||||||
public int getEventId(){
|
public int getEventId(){
|
||||||
return battleEventRepository.findEventId();
|
return battleEventRepository.findEventId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateStopBattleEvent(BattleEventRequest battleEventRequest) {
|
@DynamoDBTransaction
|
||||||
|
public void updateStopBattleEvent(BattleEvent battleEvent) {
|
||||||
|
battleEventRepository.updateStop(battleEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public enum ErrorCode {
|
|||||||
//Battle
|
//Battle
|
||||||
ERROR_BATTLE_EVENT_TIME_OVER("해당 시간에 속하는 이벤트가 존재합니다."),
|
ERROR_BATTLE_EVENT_TIME_OVER("해당 시간에 속하는 이벤트가 존재합니다."),
|
||||||
ERROR_BATTLE_EVENT_STATUS_IMPOSSIBLE("수정할 수 없는 이벤트상태입니다."),
|
ERROR_BATTLE_EVENT_STATUS_IMPOSSIBLE("수정할 수 없는 이벤트상태입니다."),
|
||||||
|
ERROR_BATTLE_EVENT_STATUS_START_IMPOSSIBLE("진행중인 이벤트상태입니다."),
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
// DyanamoDB
|
// DyanamoDB
|
||||||
|
|||||||
@@ -155,7 +155,7 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getCheckBattleEventList" resultMap="BattleEventResultMap">
|
<select id="getCheckBattleEventList" parameterType="com.caliverse.admin.domain.request.BattleEventRequest" resultMap="BattleEventResultMap">
|
||||||
SELECT id
|
SELECT id
|
||||||
, event_id
|
, event_id
|
||||||
, repeat_type
|
, repeat_type
|
||||||
@@ -164,6 +164,9 @@
|
|||||||
, event_end_dt
|
, event_end_dt
|
||||||
FROM battle_event
|
FROM battle_event
|
||||||
WHERE status NOT IN ('END', 'FAIL')
|
WHERE status NOT IN ('END', 'FAIL')
|
||||||
|
<if test="id != null and id != ''">
|
||||||
|
AND id <> #{id}
|
||||||
|
</if>
|
||||||
AND (
|
AND (
|
||||||
/* NONE 타입인 경우 */
|
/* NONE 타입인 경우 */
|
||||||
(repeat_type = 'NONE' AND DATE (event_start_dt) BETWEEN
|
(repeat_type = 'NONE' AND DATE (event_start_dt) BETWEEN
|
||||||
@@ -253,11 +256,15 @@
|
|||||||
<!--수정-->
|
<!--수정-->
|
||||||
<update id="updateBattleEvent" parameterType="com.caliverse.admin.domain.request.BattleEventRequest">
|
<update id="updateBattleEvent" parameterType="com.caliverse.admin.domain.request.BattleEventRequest">
|
||||||
UPDATE battle_event SET group_id = #{groupId}
|
UPDATE battle_event SET group_id = #{groupId}
|
||||||
, resv_end_dt = #{resvEndDt}
|
, event_name = #{eventName}
|
||||||
, auction_start_dt = #{auctionStartDt}
|
, config_id = #{configId}
|
||||||
, auction_end_dt = #{auctionEndDt}
|
, event_start_dt = #{eventStartDt}
|
||||||
, currency_type = #{currencyType}
|
, event_end_dt = #{eventEndDt}
|
||||||
, start_price = #{startPrice}
|
, reward_group_id = #{rewardGroupId}
|
||||||
|
, round_time = #{roundTime}
|
||||||
|
, round_count = #{roundCount}
|
||||||
|
, hot_time = #{hotTime}
|
||||||
|
, status = 'WAIT'
|
||||||
, update_by = #{updateBy}
|
, update_by = #{updateBy}
|
||||||
, update_dt = NOW()
|
, update_dt = NOW()
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
@@ -276,6 +283,10 @@
|
|||||||
<update id="updateStatusBattleEvent" parameterType="map">
|
<update id="updateStatusBattleEvent" parameterType="map">
|
||||||
UPDATE battle_event
|
UPDATE battle_event
|
||||||
SET status = #{status}
|
SET status = #{status}
|
||||||
|
<if test="updateBy != null and updateBy != ''">
|
||||||
|
, update_by = #{updateBy}
|
||||||
|
, update_dt = NOW()
|
||||||
|
</if>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
@@ -295,7 +306,7 @@
|
|||||||
, a.config_id
|
, a.config_id
|
||||||
, a.reward_group_id
|
, a.reward_group_id
|
||||||
FROM battle_event
|
FROM battle_event
|
||||||
WHERE (status = 'WAIT' or status = 'AUCTION_START' or status = 'RESV_START')
|
WHERE (status = 'WAIT' or status = 'RUNNING' or status = 'REGISTER')
|
||||||
AND deleted = 0
|
AND deleted = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user