랭크 관련 추가
itemRequest itemId 추가
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package com.caliverse.admin.domain.api;
|
||||
|
||||
import com.caliverse.admin.domain.request.RankRequest;
|
||||
import com.caliverse.admin.domain.response.RankResponse;
|
||||
import com.caliverse.admin.domain.service.RankService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "랭킹", description = "랭킹 api")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/v1/rank")
|
||||
public class RankController {
|
||||
private final RankService rankService;
|
||||
|
||||
@GetMapping("/schedule/list")
|
||||
public ResponseEntity<RankResponse> getRankingScheduleList(
|
||||
@RequestParam Map<String, String> requestParam){
|
||||
return ResponseEntity.ok().body( rankService.getList(requestParam));
|
||||
}
|
||||
|
||||
@GetMapping("/schedule/detail/{id}")
|
||||
public ResponseEntity<RankResponse> getRankingScheduleDetail(
|
||||
@PathVariable("id") Long id){
|
||||
return ResponseEntity.ok().body( rankService.getDetail(id));
|
||||
}
|
||||
|
||||
@PostMapping("/schedule")
|
||||
public ResponseEntity<RankResponse> postRankingSchedule(
|
||||
@RequestBody RankRequest rankRequest){
|
||||
|
||||
return ResponseEntity.ok().body(rankService.postRankingSchedule(rankRequest));
|
||||
}
|
||||
|
||||
@PutMapping("/schedule/{id}")
|
||||
public ResponseEntity<RankResponse> updateRankingSchedule(
|
||||
@PathVariable("id")Long id, @RequestBody RankRequest rankRequest){
|
||||
|
||||
return ResponseEntity.ok().body(rankService.updateRankingSchedule(id, rankRequest));
|
||||
}
|
||||
|
||||
@DeleteMapping("/schedule/delete")
|
||||
public ResponseEntity<RankResponse> deleteRankingSchedule(
|
||||
@RequestParam Long id){
|
||||
|
||||
return ResponseEntity.ok().body(rankService.deleteRankingSchedule(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.caliverse.admin.domain.dao.admin;
|
||||
|
||||
import com.caliverse.admin.domain.entity.RankingSchedule;
|
||||
import com.caliverse.admin.domain.request.RankRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface RankMapper {
|
||||
|
||||
List<RankingSchedule> getRankingScheduleList(Map map);
|
||||
int getTotal();
|
||||
RankingSchedule getRankingScheduleDetail(Long id);
|
||||
|
||||
int postRankingSchedule(RankRequest rankRequest);
|
||||
int updateRankingSchedule(RankRequest rankRequest);
|
||||
int deleteRankingSchedule(Map map);
|
||||
|
||||
int checkOverlap(RankRequest rankRequest);
|
||||
}
|
||||
@@ -29,6 +29,8 @@ public class LogGameRequest {
|
||||
private LogDomain logDomain;
|
||||
@JsonProperty("tran_id")
|
||||
private String tranId;
|
||||
@JsonProperty("item_id")
|
||||
private String itemId;
|
||||
//currency
|
||||
@JsonProperty("currency_type")
|
||||
private ECurrencyType currencyType;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.caliverse.admin.domain.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RankRequest {
|
||||
|
||||
private Long id;
|
||||
private String guid;
|
||||
private String title;
|
||||
@JsonProperty("start_dt")
|
||||
private LocalDateTime startDt;
|
||||
@JsonProperty("end_dt")
|
||||
private LocalDateTime endDt;
|
||||
@JsonProperty("base_dt")
|
||||
private LocalDateTime baseDt;
|
||||
@JsonProperty("meta_id")
|
||||
private Integer metaId;
|
||||
@JsonProperty("event_action_id")
|
||||
private Integer eventActionId;
|
||||
@JsonProperty("refresh_interval")
|
||||
private Integer refreshInterval;
|
||||
@JsonProperty("initialization_interval")
|
||||
private Integer initializationInterval;
|
||||
@JsonProperty("snapshot_interval")
|
||||
private Integer snapshotInterval;
|
||||
|
||||
@JsonProperty("create_by")
|
||||
private Long createBy;
|
||||
@JsonProperty("create_dt")
|
||||
private LocalDateTime createDt;
|
||||
@JsonProperty("update_by")
|
||||
private Long updateBy;
|
||||
@JsonProperty("update_dt")
|
||||
private LocalDateTime updateDt;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.caliverse.admin.domain.response;
|
||||
|
||||
import com.caliverse.admin.domain.entity.ItemDict;
|
||||
import com.caliverse.admin.domain.entity.metadata.MetaBrandData;
|
||||
import com.caliverse.admin.domain.entity.metadata.*;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -33,6 +33,21 @@ public class DictionaryResponse {
|
||||
@JsonProperty("brand_list")
|
||||
private List<MetaBrandData> brandList;
|
||||
|
||||
@JsonProperty("ranking_list")
|
||||
private List<MetaRankingData> rankingList;
|
||||
|
||||
@JsonProperty("battle_config_list")
|
||||
private List<MetaBattleConfigData> battleConfigList;
|
||||
|
||||
@JsonProperty("battle_reward_list")
|
||||
private List<MetaBattleRewardData> battleRewardList;
|
||||
|
||||
@JsonProperty("game_mode_list")
|
||||
private List<MetaGameModeData> gameModeList;
|
||||
|
||||
@JsonProperty("event_action_list")
|
||||
private List<MetaEventActionScoreData> eventActionList;
|
||||
|
||||
private String message;
|
||||
|
||||
private int total;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.caliverse.admin.domain.response;
|
||||
|
||||
import com.caliverse.admin.domain.entity.RankingSchedule;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RankResponse {
|
||||
private int status;
|
||||
|
||||
private String result;
|
||||
@JsonProperty("data")
|
||||
private ResultData resultData;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static class ResultData {
|
||||
|
||||
@JsonProperty("detail")
|
||||
private RankingSchedule rankingSchedule;
|
||||
|
||||
@JsonProperty("list")
|
||||
private List<RankingSchedule> rankingScheduleList;
|
||||
|
||||
private String message;
|
||||
|
||||
private int total;
|
||||
@JsonProperty("total_all")
|
||||
private int totalAll;
|
||||
@JsonProperty("page_no")
|
||||
private int pageNo;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import com.caliverse.admin.domain.RabbitMq.MessageHandlerService;
|
||||
import com.caliverse.admin.domain.dao.admin.RankMapper;
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.RankingSchedule;
|
||||
import com.caliverse.admin.domain.entity.WorldEvent;
|
||||
import com.caliverse.admin.domain.entity.log.LogAction;
|
||||
import com.caliverse.admin.domain.request.RankRequest;
|
||||
import com.caliverse.admin.domain.request.WorldEventRequest;
|
||||
import com.caliverse.admin.domain.response.RankResponse;
|
||||
import com.caliverse.admin.domain.response.RankResponse;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbBattleEventService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbRankService;
|
||||
import com.caliverse.admin.global.common.annotation.BusinessProcess;
|
||||
import com.caliverse.admin.global.common.annotation.RequestLog;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.mongodb.service.MysqlHistoryLogService;
|
||||
import com.caliverse.admin.redis.service.RedisUserInfoService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class RankService {
|
||||
|
||||
private final RankMapper rankMapper;
|
||||
private final MessageHandlerService messageHandlerService;
|
||||
private final RedisUserInfoService redisUserInfoService;
|
||||
private final DynamodbRankService dynamodbRankService;
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getList(Map requestParam){
|
||||
|
||||
//페이징 처리
|
||||
requestParam = CommonUtils.pageSetting(requestParam);
|
||||
|
||||
List<RankingSchedule> list = rankMapper.getRankingScheduleList(requestParam);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.rankingScheduleList(list)
|
||||
.total(rankMapper.getTotal())
|
||||
.totalAll(list.size())
|
||||
.pageNo(requestParam.get("page_no")!=null?
|
||||
Integer.parseInt(requestParam.get("page_no").toString()):1)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
@RequestLog
|
||||
public RankResponse getDetail(Long id){
|
||||
RankingSchedule rankingSchedule = rankMapper.getRankingScheduleDetail(id);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.rankingSchedule(rankingSchedule)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKING_SCHEDULE)
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
@RequestLog
|
||||
public RankResponse postRankingSchedule(RankRequest rankRequest){
|
||||
rankRequest.setCreateBy(CommonUtils.getAdmin().getId());
|
||||
|
||||
rankRequest.setGuid(CommonUtils.getSimpleCreateGuId());
|
||||
|
||||
rankMapper.postRankingSchedule(rankRequest);
|
||||
|
||||
long schedule_id = rankRequest.getId();
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("id",String.valueOf(schedule_id));
|
||||
|
||||
log.info("postRankingSchedule Insert Ranking Schedule id: {}", rankRequest.getId());
|
||||
|
||||
RankingSchedule rankingSchedule = rankMapper.getRankingScheduleDetail(rankRequest.getId());
|
||||
|
||||
if(redisUserInfoService.getAllServerList().isEmpty()){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_FOUND_SERVER.getMessage());
|
||||
}
|
||||
|
||||
dynamodbRankService.insertRankingSchedule(rankRequest);
|
||||
|
||||
notifyGameServers("postRankingSchedule", null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(SuccessCode.SAVE.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKING_SCHEDULE)
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
@RequestLog
|
||||
public RankResponse updateRankingSchedule(Long id, RankRequest rankRequest) {
|
||||
rankRequest.setId(id);
|
||||
rankRequest.setUpdateBy(CommonUtils.getAdmin().getId());
|
||||
rankRequest.setUpdateDt(LocalDateTime.now());
|
||||
|
||||
Long schedule_id = rankRequest.getId();
|
||||
RankingSchedule before_info = rankMapper.getRankingScheduleDetail(schedule_id);
|
||||
|
||||
rankMapper.updateRankingSchedule(rankRequest);
|
||||
|
||||
log.info("updateRankingSchedule Update Ranking Schedule Complete: {}", rankRequest.getId());
|
||||
|
||||
RankingSchedule after_info = rankMapper.getRankingScheduleDetail(schedule_id);
|
||||
|
||||
if(redisUserInfoService.getAllServerList().isEmpty()){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_FOUND_SERVER.getMessage());
|
||||
}
|
||||
|
||||
dynamodbRankService.updateRankingSchedule(rankRequest);
|
||||
|
||||
notifyGameServers("updateRankingSchedule", null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(SuccessCode.UPDATE.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@BusinessProcess(action = LogAction.RANKING_SCHEDULE)
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
@RequestLog
|
||||
public RankResponse deleteRankingSchedule(Long id){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("id",id);
|
||||
|
||||
RankingSchedule info = rankMapper.getRankingScheduleDetail(id);
|
||||
|
||||
if(info.getStartDt().isBefore(LocalDateTime.now())){
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.ERROR.getHttpStatus())
|
||||
.result(CommonCode.ERROR.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(ErrorCode.START_DATE_OVER.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
rankMapper.deleteRankingSchedule(map);
|
||||
|
||||
log.info("deleteRankingSchedule Delete Ranking Schedule Complete id: {}", id);
|
||||
|
||||
if(redisUserInfoService.getAllServerList().isEmpty()){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_FOUND_SERVER.getMessage());
|
||||
}
|
||||
|
||||
dynamodbRankService.deleteRankingSchedule(info);
|
||||
|
||||
notifyGameServers("deleteRankingSchedule", null);
|
||||
|
||||
return RankResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.resultData(RankResponse.ResultData.builder()
|
||||
.message(SuccessCode.DELETE.getMessage())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
private void notifyGameServers(String methodName, Runnable rollbackFunction) {
|
||||
// 운영DB 데이터 추가됐다고 게임서버 알림
|
||||
List<String> serverList = redisUserInfoService.getAllServerList();
|
||||
if(serverList.isEmpty()){
|
||||
log.error("{} serverList is empty", methodName);
|
||||
if (rollbackFunction != null) {
|
||||
rollbackFunction.run();
|
||||
}
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_FOUND_SERVER.getMessage());
|
||||
}
|
||||
|
||||
try{
|
||||
serverList.forEach(messageHandlerService::sendRankingScheduleMessage);
|
||||
} catch (Exception e) {
|
||||
log.error("{} messageHandlerService error: {}", methodName, e.getMessage(), e);
|
||||
if (rollbackFunction != null) {
|
||||
rollbackFunction.run();
|
||||
}
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.MESSAGE_SEND_FAIL.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user