currency api 추가
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.caliverse.admin.domain.api;
|
package com.caliverse.admin.domain.api;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.request.LogGameRequest;
|
||||||
import com.caliverse.admin.domain.request.LogGenericRequest;
|
import com.caliverse.admin.domain.request.LogGenericRequest;
|
||||||
|
import com.caliverse.admin.domain.response.IndicatorsResponse;
|
||||||
import com.caliverse.admin.domain.response.LogResponse;
|
import com.caliverse.admin.domain.response.LogResponse;
|
||||||
import com.caliverse.admin.domain.service.LogService;
|
import com.caliverse.admin.domain.service.LogService;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@@ -27,11 +29,29 @@ public class LogController {
|
|||||||
@PostMapping("/generic/excel-export")
|
@PostMapping("/generic/excel-export")
|
||||||
public void excelExport(HttpServletResponse response,
|
public void excelExport(HttpServletResponse response,
|
||||||
@RequestBody LogGenericRequest logGenericRequest){
|
@RequestBody LogGenericRequest logGenericRequest){
|
||||||
logService.excelExport(response, logGenericRequest);
|
logService.genericExcelExport(response, logGenericRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/progress/{taskId}")
|
@GetMapping("/progress/{taskId}")
|
||||||
public ResponseEntity<Map<String, Object>> getProgress(@PathVariable String taskId) {
|
public ResponseEntity<Map<String, Object>> getProgress(@PathVariable String taskId) {
|
||||||
return ResponseEntity.ok().body(logService.getProgress(taskId));
|
return ResponseEntity.ok().body(logService.getProgress(taskId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/currency/list")
|
||||||
|
public ResponseEntity<LogResponse> currencyList(
|
||||||
|
@RequestParam Map<String, String> requestParams){
|
||||||
|
return ResponseEntity.ok().body( logService.getCurrencyLogList(requestParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/currency/detail/list")
|
||||||
|
public ResponseEntity<LogResponse> currencyDetailList(
|
||||||
|
@RequestParam Map<String, String> requestParams){
|
||||||
|
return ResponseEntity.ok().body( logService.getCurrencyDetailLogList(requestParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/currency/detail/excel-export")
|
||||||
|
public void currencyDetailExcelExport(HttpServletResponse response,
|
||||||
|
@RequestBody LogGameRequest logGameRequest){
|
||||||
|
logService.currencyDetailExcelExport(response, logGameRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public enum ITEMLARGETYPE {
|
|||||||
TATTOO,
|
TATTOO,
|
||||||
BEAUTY,
|
BEAUTY,
|
||||||
CURRENCY,
|
CURRENCY,
|
||||||
PRODUCT
|
PRODUCT,
|
||||||
|
SET_BOX
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.caliverse.admin.domain.request;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.common.SearchUserType;
|
||||||
|
import com.caliverse.admin.logs.entity.LogAction;
|
||||||
|
import com.caliverse.admin.logs.entity.LogDomain;
|
||||||
|
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 LogGameRequest {
|
||||||
|
@JsonProperty("search_type")
|
||||||
|
private SearchUserType searchType;
|
||||||
|
@JsonProperty("search_data")
|
||||||
|
private String searchData;
|
||||||
|
@JsonProperty("log_action")
|
||||||
|
private LogAction logAction;
|
||||||
|
@JsonProperty("log_domain")
|
||||||
|
private LogDomain logDomain;
|
||||||
|
@JsonProperty("tran_id")
|
||||||
|
private String tranId;
|
||||||
|
@JsonProperty("start_dt")
|
||||||
|
private LocalDateTime startDt;
|
||||||
|
@JsonProperty("end_dt")
|
||||||
|
private LocalDateTime endDt;
|
||||||
|
@JsonProperty("page_no")
|
||||||
|
private Integer pageNo;
|
||||||
|
@JsonProperty("page_size")
|
||||||
|
private Integer pageSize;
|
||||||
|
@JsonProperty("order_by")
|
||||||
|
private String orderBy;
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.caliverse.admin.domain.response;
|
package com.caliverse.admin.domain.response;
|
||||||
|
|
||||||
|
import com.caliverse.admin.Indicators.entity.CurrencyDetailLogInfo;
|
||||||
import com.caliverse.admin.domain.entity.log.GenericLog;
|
import com.caliverse.admin.domain.entity.log.GenericLog;
|
||||||
import com.caliverse.admin.logs.Indicatordomain.GenericMongoLog;
|
import com.caliverse.admin.logs.Indicatordomain.GenericMongoLog;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
@@ -34,6 +35,10 @@ public class LogResponse {
|
|||||||
@JsonProperty("generic_list")
|
@JsonProperty("generic_list")
|
||||||
// private List<Map<String, Object>> genericList;
|
// private List<Map<String, Object>> genericList;
|
||||||
private List<GenericLog> genericList;
|
private List<GenericLog> genericList;
|
||||||
|
@JsonProperty("currency_list")
|
||||||
|
private List<currencyLog> currencyList;
|
||||||
|
@JsonProperty("currency_detail_list")
|
||||||
|
private List<CurrencyDetailLogInfo> currencyDetailList;
|
||||||
|
|
||||||
private int total;
|
private int total;
|
||||||
@JsonProperty("total_all")
|
@JsonProperty("total_all")
|
||||||
@@ -42,5 +47,29 @@ public class LogResponse {
|
|||||||
private int pageNo;
|
private int pageNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public static class currencyLog {
|
||||||
|
private String logDay;
|
||||||
|
private String accountId;
|
||||||
|
private String userGuid;
|
||||||
|
private String userNickname;
|
||||||
|
private Double sapphireAcquired;
|
||||||
|
private Double sapphireConsumed;
|
||||||
|
private Double sapphireNet;
|
||||||
|
private Double goldAcquired;
|
||||||
|
private Double goldConsumed;
|
||||||
|
private Double goldNet;
|
||||||
|
private Double caliumAcquired;
|
||||||
|
private Double caliumConsumed;
|
||||||
|
private Double caliumNet;
|
||||||
|
private Double beamAcquired;
|
||||||
|
private Double beamConsumed;
|
||||||
|
private Double beamNet;
|
||||||
|
private Double rubyAcquired;
|
||||||
|
private Double rubyConsumed;
|
||||||
|
private Double rubyNet;
|
||||||
|
private Integer totalCurrencies;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
package com.caliverse.admin.domain.service;
|
package com.caliverse.admin.domain.service;
|
||||||
|
|
||||||
|
import com.caliverse.admin.Indicators.entity.CurrencyDetailLogInfo;
|
||||||
|
import com.caliverse.admin.Indicators.entity.CurrencyLogInfo;
|
||||||
|
import com.caliverse.admin.Indicators.entity.DauLogInfo;
|
||||||
import com.caliverse.admin.domain.cache.CommonCacheHandler;
|
import com.caliverse.admin.domain.cache.CommonCacheHandler;
|
||||||
import com.caliverse.admin.domain.entity.excel.ExcelBusinessLog;
|
import com.caliverse.admin.domain.entity.excel.ExcelBusinessLog;
|
||||||
import com.caliverse.admin.domain.entity.log.GenericLog;
|
import com.caliverse.admin.domain.entity.log.GenericLog;
|
||||||
|
import com.caliverse.admin.domain.request.LogGameRequest;
|
||||||
import com.caliverse.admin.domain.request.LogGenericRequest;
|
import com.caliverse.admin.domain.request.LogGenericRequest;
|
||||||
|
import com.caliverse.admin.domain.response.IndicatorsResponse;
|
||||||
import com.caliverse.admin.domain.response.LogResponse;
|
import com.caliverse.admin.domain.response.LogResponse;
|
||||||
import com.caliverse.admin.global.common.code.CommonCode;
|
import com.caliverse.admin.global.common.code.CommonCode;
|
||||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||||
|
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||||
|
import com.caliverse.admin.global.common.utils.DateUtils;
|
||||||
import com.caliverse.admin.global.component.tracker.ExcelProgressTracker;
|
import com.caliverse.admin.global.component.tracker.ExcelProgressTracker;
|
||||||
import com.caliverse.admin.logs.Indicatordomain.GenericMongoLog;
|
import com.caliverse.admin.logs.Indicatordomain.GenericMongoLog;
|
||||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogGenericService;
|
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogGenericService;
|
||||||
|
import com.caliverse.admin.logs.logservice.indicators.IndicatorsCurrencyService;
|
||||||
|
import com.caliverse.admin.mongodb.dto.MongoPageResult;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -20,6 +29,7 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -35,6 +45,7 @@ public class LogService {
|
|||||||
private final ExcelService excelService;
|
private final ExcelService excelService;
|
||||||
private final CommonCacheHandler commonCacheHandler;
|
private final CommonCacheHandler commonCacheHandler;
|
||||||
private final ExcelProgressTracker progressTracker;
|
private final ExcelProgressTracker progressTracker;
|
||||||
|
private final IndicatorsCurrencyService indicatorsCurrencyService;
|
||||||
|
|
||||||
public LogResponse genericLogList(LogGenericRequest logGenericRequest){
|
public LogResponse genericLogList(LogGenericRequest logGenericRequest){
|
||||||
int page = logGenericRequest.getPageNo();
|
int page = logGenericRequest.getPageNo();
|
||||||
@@ -197,7 +208,7 @@ public class LogService {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void excelExport(HttpServletResponse response, LogGenericRequest logGenericRequest){
|
public void genericExcelExport(HttpServletResponse response, LogGenericRequest logGenericRequest){
|
||||||
String taskId = logGenericRequest.getTaskId();
|
String taskId = logGenericRequest.getTaskId();
|
||||||
LocalDateTime startDt = logGenericRequest.getStartDt().plusHours(9);
|
LocalDateTime startDt = logGenericRequest.getStartDt().plusHours(9);
|
||||||
LocalDateTime endDt = logGenericRequest.getEndDt().plusHours(9).plusDays(1);
|
LocalDateTime endDt = logGenericRequest.getEndDt().plusHours(9).plusDays(1);
|
||||||
@@ -291,4 +302,140 @@ public class LogService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LogResponse getCurrencyLogList(Map<String, String> requestParams){
|
||||||
|
String startDt = requestParams.get("start_dt");
|
||||||
|
String endDt = requestParams.get("end_dt");
|
||||||
|
List<CurrencyLogInfo> currencyLogList = indicatorsCurrencyService.getIndicatorsLogData(startDt, endDt, CurrencyLogInfo.class);
|
||||||
|
|
||||||
|
List<LogResponse.currencyLog> currencyList = new ArrayList<>();
|
||||||
|
for (CurrencyLogInfo info : currencyLogList){
|
||||||
|
LogResponse.currencyLog build = LogResponse.currencyLog.builder()
|
||||||
|
.logDay(info.getLogDay())
|
||||||
|
.accountId(info.getAccountId())
|
||||||
|
.userGuid(info.getUserGuid())
|
||||||
|
.userNickname(info.getUserNickname())
|
||||||
|
.goldAcquired(info.getGoldAcquired())
|
||||||
|
.goldConsumed(info.getGoldConsumed())
|
||||||
|
.goldNet(info.getGoldNet())
|
||||||
|
.sapphireAcquired(info.getSapphireAcquired())
|
||||||
|
.sapphireConsumed(info.getSapphireConsumed())
|
||||||
|
.sapphireNet(info.getSapphireNet())
|
||||||
|
.beamAcquired(info.getBeamAcquired())
|
||||||
|
.beamConsumed(info.getBeamConsumed())
|
||||||
|
.beamNet(info.getBeamNet())
|
||||||
|
.caliumAcquired(info.getCaliumAcquired())
|
||||||
|
.caliumConsumed(info.getCaliumConsumed())
|
||||||
|
.caliumNet(info.getCaliumNet())
|
||||||
|
.rubyAcquired(info.getRubyAcquired())
|
||||||
|
.rubyConsumed(info.getRubyConsumed())
|
||||||
|
.rubyNet(info.getRubyNet())
|
||||||
|
.totalCurrencies(info.getTotalCurrencies())
|
||||||
|
.build();
|
||||||
|
currencyList.add(build);
|
||||||
|
}
|
||||||
|
|
||||||
|
return LogResponse.builder()
|
||||||
|
.resultData(LogResponse.ResultData.builder()
|
||||||
|
.currencyList(currencyList)
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LogResponse getCurrencyDetailLogList(Map<String, String> requestParams){
|
||||||
|
String searchType = requestParams.get("search_type");
|
||||||
|
String searchData = requestParams.get("search_data");
|
||||||
|
String tranId = requestParams.get("tran_id");
|
||||||
|
LocalDateTime startDt = DateUtils.stringISOToLocalDateTime(requestParams.get("start_dt"));
|
||||||
|
LocalDateTime endDt = DateUtils.stringISOToLocalDateTime(requestParams.get("end_dt"));
|
||||||
|
String orderBy = requestParams.get("orderby");
|
||||||
|
int pageNo = Integer.parseInt(requestParams.get("page_no"));
|
||||||
|
int pageSize = Integer.parseInt(requestParams.get("page_size"));
|
||||||
|
MongoPageResult<CurrencyDetailLogInfo> result = indicatorsCurrencyService.getCurrencyDetailLogData(
|
||||||
|
searchType,
|
||||||
|
searchData,
|
||||||
|
tranId,
|
||||||
|
startDt.toString().substring(0, 10),
|
||||||
|
endDt.toString().substring(0, 10),
|
||||||
|
orderBy,
|
||||||
|
pageNo,
|
||||||
|
pageSize,
|
||||||
|
CurrencyDetailLogInfo.class
|
||||||
|
);
|
||||||
|
|
||||||
|
List<CurrencyDetailLogInfo> currencyLogList = result.getItems();
|
||||||
|
int totalCount = result.getTotalCount();
|
||||||
|
|
||||||
|
return LogResponse.builder()
|
||||||
|
.resultData(LogResponse.ResultData.builder()
|
||||||
|
.currencyDetailList(currencyLogList)
|
||||||
|
.total(currencyLogList.size())
|
||||||
|
.totalAll(totalCount)
|
||||||
|
.pageNo(pageNo)
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void currencyDetailExcelExport(HttpServletResponse response, LogGameRequest logGameRequest){
|
||||||
|
String taskId = logGameRequest.getTaskId();
|
||||||
|
LocalDateTime startDt = logGameRequest.getStartDt().plusHours(9);
|
||||||
|
LocalDateTime endDt = logGameRequest.getEndDt().plusHours(9).plusDays(1);
|
||||||
|
logGameRequest.setStartDt(startDt);
|
||||||
|
logGameRequest.setEndDt(endDt);
|
||||||
|
logGameRequest.setPageNo(null);
|
||||||
|
logGameRequest.setPageSize(null);
|
||||||
|
progressTracker.updateProgress(taskId, 5, 100, "엑셀 생성 준비 중...");
|
||||||
|
|
||||||
|
|
||||||
|
MongoPageResult<CurrencyDetailLogInfo> result = null;
|
||||||
|
try{
|
||||||
|
result = indicatorsCurrencyService.getCurrencyDetailLogData(
|
||||||
|
logGameRequest.getSearchType().toString(),
|
||||||
|
logGameRequest.getSearchData(),
|
||||||
|
logGameRequest.getTranId(),
|
||||||
|
startDt.toString().substring(0, 10),
|
||||||
|
endDt.toString().substring(0, 10),
|
||||||
|
logGameRequest.getOrderBy(),
|
||||||
|
logGameRequest.getPageNo(),
|
||||||
|
logGameRequest.getPageSize(),
|
||||||
|
CurrencyDetailLogInfo.class
|
||||||
|
);
|
||||||
|
progressTracker.updateProgress(taskId, 20, 100, "데이터 생성완료");
|
||||||
|
}catch(UncategorizedMongoDbException e){
|
||||||
|
if (e.getMessage().contains("Sort exceeded memory limit")) {
|
||||||
|
log.error("MongoDB Query memory limit error: {}", e.getMessage());
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_LOG_MEMORY_LIMIT.toString());
|
||||||
|
} else if (e.getMessage().contains("time limit")) {
|
||||||
|
log.error("MongoDB Query operation exceeded time limit: {}", e.getMessage());
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_LOG_MEMORY_LIMIT.toString());
|
||||||
|
}else {
|
||||||
|
log.error("MongoDB Query error", e);
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_MONGODB_QUERY.toString());
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("currencyDetailExcelExport ExcelExport Data Search Error", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CurrencyDetailLogInfo> currencyLogList = result.getItems();
|
||||||
|
progressTracker.updateProgress(taskId, 30, 100, "데이터 파싱 완료...");
|
||||||
|
|
||||||
|
try{
|
||||||
|
excelService.generateExcelToResponse(
|
||||||
|
response,
|
||||||
|
currencyLogList,
|
||||||
|
"게임 재화 로그 데이터",
|
||||||
|
"sheet1",
|
||||||
|
taskId
|
||||||
|
);
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("currencyDetailExcelExport Excel Export Create Error", e);
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_EXCEL_DOWN.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user