게임로그 유저생성 로그 조회, 엑셀
게임로그 유저로그인 로그 조회, 엑셀
This commit is contained in:
@@ -7,6 +7,8 @@ import org.springframework.data.mongodb.core.index.CompoundIndexes;
|
|||||||
import org.springframework.data.mongodb.core.index.Indexed;
|
import org.springframework.data.mongodb.core.index.Indexed;
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Document(collection = "userCreate")
|
@Document(collection = "userCreate")
|
||||||
@@ -20,9 +22,9 @@ public class UserCreateLogInfo extends LogInfoBase{
|
|||||||
@Indexed
|
@Indexed
|
||||||
private String userGuid;
|
private String userGuid;
|
||||||
private String userNickname;
|
private String userNickname;
|
||||||
private String createdTime;
|
private LocalDateTime createdTime;
|
||||||
|
|
||||||
public UserCreateLogInfo(String logDay, String accountId, String userGuid, String userNickname, String createdTime) {
|
public UserCreateLogInfo(String logDay, String accountId, String userGuid, String userNickname, LocalDateTime createdTime) {
|
||||||
super(StatisticsType.USER_CREATE);
|
super(StatisticsType.USER_CREATE);
|
||||||
|
|
||||||
this.logDay = logDay;
|
this.logDay = logDay;
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.caliverse.admin.Indicators.entity;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class UserLoginDetailLogInfo extends LogInfoBase{
|
||||||
|
private String logDay;
|
||||||
|
private String accountId;
|
||||||
|
private String userGuid;
|
||||||
|
private String userNickname;
|
||||||
|
private String tranId;
|
||||||
|
private LocalDateTime loginTime;
|
||||||
|
private LocalDateTime logoutTime;
|
||||||
|
private String serverType;
|
||||||
|
private String languageType;
|
||||||
|
private Double playtime;
|
||||||
|
|
||||||
|
public UserLoginDetailLogInfo(String logDay,
|
||||||
|
String accountId,
|
||||||
|
String userGuid,
|
||||||
|
String userNickname,
|
||||||
|
String tranId,
|
||||||
|
LocalDateTime loginTime,
|
||||||
|
LocalDateTime logoutTime,
|
||||||
|
String serverType,
|
||||||
|
String languageType,
|
||||||
|
Double playtime
|
||||||
|
) {
|
||||||
|
super(StatisticsType.USER_LOGIN);
|
||||||
|
|
||||||
|
this.logDay = logDay;
|
||||||
|
this.accountId = accountId;
|
||||||
|
this.userGuid = userGuid;
|
||||||
|
this.userNickname = userNickname;
|
||||||
|
this.tranId = tranId;
|
||||||
|
this.loginTime = loginTime;
|
||||||
|
this.logoutTime = logoutTime;
|
||||||
|
this.serverType = serverType;
|
||||||
|
this.languageType = languageType;
|
||||||
|
this.playtime = playtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -84,4 +84,28 @@ public class LogController {
|
|||||||
@RequestBody LogGameRequest logGameRequest){
|
@RequestBody LogGameRequest logGameRequest){
|
||||||
logService.currencyItemExcelExport(response, logGameRequest);
|
logService.currencyItemExcelExport(response, logGameRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/user/create/list")
|
||||||
|
public ResponseEntity<LogResponse> userCreateList(
|
||||||
|
@RequestParam Map<String, String> requestParams){
|
||||||
|
return ResponseEntity.ok().body( logService.getUserCreateLogList(requestParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/create/excel-export")
|
||||||
|
public void userCreateExcelExport(HttpServletResponse response,
|
||||||
|
@RequestBody LogGameRequest logGameRequest){
|
||||||
|
logService.userCreateExcelExport(response, logGameRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/user/login/list")
|
||||||
|
public ResponseEntity<LogResponse> userLoginList(
|
||||||
|
@RequestParam Map<String, String> requestParams){
|
||||||
|
return ResponseEntity.ok().body( logService.getUserLoginDetailLogList(requestParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/login/excel-export")
|
||||||
|
public void userLoginExcelExport(HttpServletResponse response,
|
||||||
|
@RequestBody LogGameRequest logGameRequest){
|
||||||
|
logService.userLoginExcelExport(response, logGameRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +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.Indicators.entity.*;
|
||||||
import com.caliverse.admin.Indicators.entity.CurrencyItemLogInfo;
|
|
||||||
import com.caliverse.admin.Indicators.entity.ItemDetailLogInfo;
|
|
||||||
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;
|
||||||
@@ -41,6 +39,10 @@ public class LogResponse {
|
|||||||
private List<currencyLog> currencyList;
|
private List<currencyLog> currencyList;
|
||||||
@JsonProperty("currency_detail_list")
|
@JsonProperty("currency_detail_list")
|
||||||
private List<CurrencyDetailLogInfo> currencyDetailList;
|
private List<CurrencyDetailLogInfo> currencyDetailList;
|
||||||
|
@JsonProperty("user_create_list")
|
||||||
|
private List<UserCreateLogInfo> userCreateList;
|
||||||
|
@JsonProperty("user_login_list")
|
||||||
|
private List<UserLoginDetailLogInfo> userLoginList;
|
||||||
@JsonProperty("item_detail_list")
|
@JsonProperty("item_detail_list")
|
||||||
private List<ItemDetailLogInfo> itemDetailList;
|
private List<ItemDetailLogInfo> itemDetailList;
|
||||||
@JsonProperty("currency_item_list")
|
@JsonProperty("currency_item_list")
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ 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.logs.logservice.indicators.IndicatorsCurrencyService;
|
||||||
import com.caliverse.admin.logs.logservice.indicators.IndicatorsItemService;
|
import com.caliverse.admin.logs.logservice.indicators.IndicatorsItemService;
|
||||||
|
import com.caliverse.admin.logs.logservice.indicators.IndicatorsUserCreateService;
|
||||||
|
import com.caliverse.admin.logs.logservice.indicators.IndicatorsUserLoginService;
|
||||||
import com.caliverse.admin.mongodb.dto.MongoPageResult;
|
import com.caliverse.admin.mongodb.dto.MongoPageResult;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -46,6 +48,8 @@ public class LogService {
|
|||||||
private final ExcelProgressTracker progressTracker;
|
private final ExcelProgressTracker progressTracker;
|
||||||
private final IndicatorsCurrencyService indicatorsCurrencyService;
|
private final IndicatorsCurrencyService indicatorsCurrencyService;
|
||||||
private final IndicatorsItemService indicatorsItemService;
|
private final IndicatorsItemService indicatorsItemService;
|
||||||
|
private final IndicatorsUserLoginService indicatorsUserLoginService;
|
||||||
|
private final IndicatorsUserCreateService indicatorsUserCreateService;
|
||||||
|
|
||||||
public LogResponse genericLogList(LogGenericRequest logGenericRequest){
|
public LogResponse genericLogList(LogGenericRequest logGenericRequest){
|
||||||
int page = logGenericRequest.getPageNo();
|
int page = logGenericRequest.getPageNo();
|
||||||
@@ -735,4 +739,189 @@ public class LogService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LogResponse getUserCreateLogList(Map<String, String> requestParams){
|
||||||
|
String searchType = requestParams.get("search_type");
|
||||||
|
String searchData = requestParams.get("search_data");
|
||||||
|
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<UserCreateLogInfo> result = indicatorsUserCreateService.getUserCreateLogData(
|
||||||
|
searchType,
|
||||||
|
searchData,
|
||||||
|
startDt.toString().substring(0, 10),
|
||||||
|
endDt.toString().substring(0, 10),
|
||||||
|
orderBy,
|
||||||
|
pageNo,
|
||||||
|
pageSize,
|
||||||
|
UserCreateLogInfo.class
|
||||||
|
);
|
||||||
|
|
||||||
|
List<UserCreateLogInfo> userCreateLogList = result.getItems();
|
||||||
|
int totalCount = result.getTotalCount();
|
||||||
|
|
||||||
|
return LogResponse.builder()
|
||||||
|
.resultData(LogResponse.ResultData.builder()
|
||||||
|
.userCreateList(userCreateLogList)
|
||||||
|
.total(userCreateLogList.size())
|
||||||
|
.totalAll(totalCount)
|
||||||
|
.pageNo(pageNo)
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void userCreateExcelExport(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<UserCreateLogInfo> result = null;
|
||||||
|
try{
|
||||||
|
result = indicatorsUserCreateService.getUserCreateLogData(
|
||||||
|
logGameRequest.getSearchType().toString(),
|
||||||
|
logGameRequest.getSearchData(),
|
||||||
|
startDt.toString().substring(0, 10),
|
||||||
|
endDt.toString().substring(0, 10),
|
||||||
|
logGameRequest.getOrderBy(),
|
||||||
|
logGameRequest.getPageNo(),
|
||||||
|
logGameRequest.getPageSize(),
|
||||||
|
UserCreateLogInfo.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("userCreateExcelExport ExcelExport Data Search Error", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UserCreateLogInfo> logList = result.getItems();
|
||||||
|
progressTracker.updateProgress(taskId, 30, 100, "데이터 파싱 완료...");
|
||||||
|
|
||||||
|
try{
|
||||||
|
excelService.generateExcelToResponse(
|
||||||
|
response,
|
||||||
|
logList,
|
||||||
|
"유저 생성 로그 데이터",
|
||||||
|
"sheet1",
|
||||||
|
taskId
|
||||||
|
);
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("userCreateExcelExport Excel Export Create Error", e);
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_EXCEL_DOWN.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public LogResponse getUserLoginDetailLogList(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<UserLoginDetailLogInfo> result = indicatorsUserLoginService.getLoginDetailLogData(
|
||||||
|
searchType,
|
||||||
|
searchData,
|
||||||
|
tranId,
|
||||||
|
startDt.toString().substring(0, 10),
|
||||||
|
endDt.toString().substring(0, 10),
|
||||||
|
orderBy,
|
||||||
|
pageNo,
|
||||||
|
pageSize,
|
||||||
|
UserLoginDetailLogInfo.class
|
||||||
|
);
|
||||||
|
|
||||||
|
List<UserLoginDetailLogInfo> userLoginLogList = result.getItems();
|
||||||
|
int totalCount = result.getTotalCount();
|
||||||
|
|
||||||
|
return LogResponse.builder()
|
||||||
|
.resultData(LogResponse.ResultData.builder()
|
||||||
|
.userLoginList(userLoginLogList)
|
||||||
|
.total(userLoginLogList.size())
|
||||||
|
.totalAll(totalCount)
|
||||||
|
.pageNo(pageNo)
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void userLoginExcelExport(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<UserLoginDetailLogInfo> result = null;
|
||||||
|
try{
|
||||||
|
result = indicatorsUserLoginService.getLoginDetailLogData(
|
||||||
|
logGameRequest.getSearchType().toString(),
|
||||||
|
logGameRequest.getSearchData(),
|
||||||
|
logGameRequest.getTranId(),
|
||||||
|
startDt.toString().substring(0, 10),
|
||||||
|
endDt.toString().substring(0, 10),
|
||||||
|
logGameRequest.getOrderBy(),
|
||||||
|
logGameRequest.getPageNo(),
|
||||||
|
logGameRequest.getPageSize(),
|
||||||
|
UserLoginDetailLogInfo.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("userLoginExcelExport ExcelExport Data Search Error", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UserLoginDetailLogInfo> logList = result.getItems();
|
||||||
|
progressTracker.updateProgress(taskId, 30, 100, "데이터 파싱 완료...");
|
||||||
|
|
||||||
|
try{
|
||||||
|
excelService.generateExcelToResponse(
|
||||||
|
response,
|
||||||
|
logList,
|
||||||
|
"유저 로그인 로그 데이터",
|
||||||
|
"sheet1",
|
||||||
|
taskId
|
||||||
|
);
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("userLoginExcelExport Excel Export Create Error", e);
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_EXCEL_DOWN.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class UserCreateMongoLog extends MongoLogSearchBase{
|
public class UserCreateMongoLog extends MongoLogSearchBase{
|
||||||
private String createdTime;
|
private LocalDateTime createdTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class BusinessLogUserCreateService extends BusinessLogServiceBase {
|
|||||||
.append(AdminConstants.MONGO_DB_KEY_LOGDAY, "$_id.logDay")
|
.append(AdminConstants.MONGO_DB_KEY_LOGDAY, "$_id.logDay")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID, "$_id.accountId")
|
.append(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID, "$_id.accountId")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_USER_GUID, "$userGuid")
|
.append(AdminConstants.MONGO_DB_KEY_USER_GUID, "$userGuid")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_USER_NICKNAME, "$nickname")
|
.append(AdminConstants.MONGO_DB_KEY_USER_NICKNAME, "$userNickname")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_CREATE_TIME, "$createdTime")
|
.append(AdminConstants.MONGO_DB_KEY_CREATE_TIME, "$createdTime")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ public class BusinessLogUserLoginMultiService extends BusinessLogServiceBase {
|
|||||||
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$logoutTime")
|
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$logoutTime")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_IP, "$ip")
|
.append(AdminConstants.MONGO_DB_KEY_IP, "$ip")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$languageType")
|
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$languageType")
|
||||||
|
.append(AdminConstants.MONGO_DB_KEY_TRAN_ID, "$tranId")
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -154,6 +155,7 @@ public class BusinessLogUserLoginMultiService extends BusinessLogServiceBase {
|
|||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
new Document(AdminConstants.MONGO_DB_KEY_LOGIN_TIME, "$$state.currentLogin.loginTime")
|
new Document(AdminConstants.MONGO_DB_KEY_LOGIN_TIME, "$$state.currentLogin.loginTime")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$$currentAction.logoutTime")
|
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$$currentAction.logoutTime")
|
||||||
|
.append(AdminConstants.MONGO_DB_KEY_TRAN_ID, "$$currentAction.tranId")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE, "$$state.currentLogin.serverType")
|
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE, "$$state.currentLogin.serverType")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_IP, "$$state.currentLogin.ip")
|
.append(AdminConstants.MONGO_DB_KEY_IP, "$$state.currentLogin.ip")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$$state.currentLogin.languageType")
|
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$$state.currentLogin.languageType")
|
||||||
@@ -177,6 +179,7 @@ public class BusinessLogUserLoginMultiService extends BusinessLogServiceBase {
|
|||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
new Document(AdminConstants.MONGO_DB_KEY_LOGIN_TIME, "$$currentAction.loginTime")
|
new Document(AdminConstants.MONGO_DB_KEY_LOGIN_TIME, "$$currentAction.loginTime")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$$currentAction.logoutTime")
|
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$$currentAction.logoutTime")
|
||||||
|
.append(AdminConstants.MONGO_DB_KEY_TRAN_ID, "$$currentAction.tranId")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE, "$$currentAction.serverType")
|
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE, "$$currentAction.serverType")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_IP, "$$currentAction.ip")
|
.append(AdminConstants.MONGO_DB_KEY_IP, "$$currentAction.ip")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$$currentAction.languageType")
|
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$$currentAction.languageType")
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ public class BusinessLogUserLoginService extends BusinessLogServiceBase {
|
|||||||
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE, "$serverType")
|
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE, "$serverType")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LOGIN_TIME, "$loginTimeDate")
|
.append(AdminConstants.MONGO_DB_KEY_LOGIN_TIME, "$loginTimeDate")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$logoutTimeDate")
|
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$logoutTimeDate")
|
||||||
|
.append(AdminConstants.MONGO_DB_KEY_TRAN_ID, "$tranId")
|
||||||
.append(AdminConstants.MONGO_DB_COLLECTION_PLAYTIME, "$playTimeInSeconds")
|
.append(AdminConstants.MONGO_DB_COLLECTION_PLAYTIME, "$playTimeInSeconds")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_IP, "$ip")
|
.append(AdminConstants.MONGO_DB_KEY_IP, "$ip")
|
||||||
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$languageType")
|
.append(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, "$languageType")
|
||||||
|
|||||||
@@ -1,23 +1,37 @@
|
|||||||
package com.caliverse.admin.logs.logservice.indicators;
|
package com.caliverse.admin.logs.logservice.indicators;
|
||||||
|
|
||||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||||
|
import com.caliverse.admin.Indicators.Indicatorsservice.base.IndicatorsLogLoadServiceBase;
|
||||||
import com.caliverse.admin.Indicators.entity.UserCreateLogInfo;
|
import com.caliverse.admin.Indicators.entity.UserCreateLogInfo;
|
||||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorUserCreateRepository;
|
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorUserCreateRepository;
|
||||||
|
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||||
import com.caliverse.admin.logs.Indicatordomain.UserCreateMongoLog;
|
import com.caliverse.admin.logs.Indicatordomain.UserCreateMongoLog;
|
||||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogUserCreateService;
|
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogUserCreateService;
|
||||||
|
import com.caliverse.admin.mongodb.dto.MongoPageResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.bson.Document;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.aggregation.*;
|
||||||
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class IndicatorsUserCreateService {
|
public class IndicatorsUserCreateService extends IndicatorsLogLoadServiceBase {
|
||||||
|
|
||||||
@Autowired private IndicatorUserCreateRepository indicatorUserCreateRepository;
|
@Autowired private IndicatorUserCreateRepository indicatorUserCreateRepository;
|
||||||
@Autowired private BusinessLogUserCreateService userCreateService;
|
@Autowired private BusinessLogUserCreateService userCreateService;
|
||||||
|
|
||||||
|
public IndicatorsUserCreateService(@Qualifier("mongoIndicatorTemplate") MongoTemplate mongoTemplate) {
|
||||||
|
super(mongoTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
public void collectUserCreate(String startTime, String endTime){
|
public void collectUserCreate(String startTime, String endTime){
|
||||||
String logTimeStr = startTime.substring(0, 10);
|
String logTimeStr = startTime.substring(0, 10);
|
||||||
List<UserCreateMongoLog> indicatorsLog = userCreateService.loadBusinessLogData(startTime, endTime, UserCreateMongoLog.class);
|
List<UserCreateMongoLog> indicatorsLog = userCreateService.loadBusinessLogData(startTime, endTime, UserCreateMongoLog.class);
|
||||||
@@ -48,4 +62,83 @@ public class IndicatorsUserCreateService {
|
|||||||
log.error("Not instanceof UserCreateLogInfo");
|
log.error("Not instanceof UserCreateLogInfo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends IndicatorsLog> List<T> getIndicatorsLogData(String startTime, String endTime, Class<T> clazz) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends IndicatorsLog> MongoPageResult<T> getUserCreateLogData(
|
||||||
|
String searchType,
|
||||||
|
String searchData,
|
||||||
|
String startTime,
|
||||||
|
String endTime,
|
||||||
|
String orderBy,
|
||||||
|
Integer page,
|
||||||
|
Integer size,
|
||||||
|
Class<T> clazz
|
||||||
|
) {
|
||||||
|
Criteria criteria = makeCriteria(startTime, endTime, AdminConstants.MONGO_DB_KEY_LOGDAY);
|
||||||
|
|
||||||
|
if(searchData != null && !searchData.isEmpty()){
|
||||||
|
switch (searchType){
|
||||||
|
case "GUID":
|
||||||
|
criteria.and("userGuid").is(searchData);
|
||||||
|
break;
|
||||||
|
case "NICKNAME":
|
||||||
|
criteria.and("userNickname").is(searchData);
|
||||||
|
break;
|
||||||
|
case "ACCOUNT":
|
||||||
|
criteria.and("accountId").is(searchData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.error("searchType: {} not support", searchType);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectionOperation projection = Aggregation.project()
|
||||||
|
.andExclude("_id")
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).as(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID)
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_USER_GUID).as("userGuid")
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_USER_NICKNAME).as("userNickname")
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_CREATE_TIME).as(AdminConstants.MONGO_DB_KEY_CREATE_TIME);
|
||||||
|
|
||||||
|
List<AggregationOperation> baseOperations = new ArrayList<>(List.of(
|
||||||
|
Aggregation.match(criteria),
|
||||||
|
projection,
|
||||||
|
Aggregation.sort(orderBy.equals("DESC") ? Sort.Direction.DESC : Sort.Direction.ASC, AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||||
|
));
|
||||||
|
|
||||||
|
int totalCount = 0;
|
||||||
|
if(page != null && page != 0) {
|
||||||
|
List<AggregationOperation> countOperations = new ArrayList<>(baseOperations);
|
||||||
|
countOperations.add(Aggregation.count().as("total"));
|
||||||
|
|
||||||
|
Aggregation countAggregation = Aggregation.newAggregation(countOperations);
|
||||||
|
Document countResult = mongoTemplate.aggregate(
|
||||||
|
countAggregation.withOptions(AggregationOptions.builder().allowDiskUse(true).build()),
|
||||||
|
AdminConstants.MONGO_DB_COLLECTION_CREATE,
|
||||||
|
Document.class
|
||||||
|
).getUniqueMappedResult();
|
||||||
|
totalCount = countResult != null ? countResult.getInteger("total") : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AggregationOperation> dataOperations = new ArrayList<>(baseOperations);
|
||||||
|
if(page != null && page != 0) {
|
||||||
|
int skip = (page - 1) * size;
|
||||||
|
dataOperations.add(Aggregation.skip((long) skip));
|
||||||
|
dataOperations.add(Aggregation.limit(size));
|
||||||
|
}
|
||||||
|
|
||||||
|
Aggregation aggregation = Aggregation.newAggregation(dataOperations);
|
||||||
|
List<T> items = mongoTemplate.aggregate(
|
||||||
|
aggregation.withOptions(AggregationOptions.builder().allowDiskUse(true).build()),
|
||||||
|
AdminConstants.MONGO_DB_COLLECTION_CREATE,
|
||||||
|
clazz
|
||||||
|
).getMappedResults();
|
||||||
|
|
||||||
|
return new MongoPageResult<>(items, totalCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,39 @@
|
|||||||
package com.caliverse.admin.logs.logservice.indicators;
|
package com.caliverse.admin.logs.logservice.indicators;
|
||||||
|
|
||||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||||
|
import com.caliverse.admin.Indicators.Indicatorsservice.base.IndicatorsLogLoadServiceBase;
|
||||||
import com.caliverse.admin.Indicators.entity.UserLoginLogInfo;
|
import com.caliverse.admin.Indicators.entity.UserLoginLogInfo;
|
||||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorUserLoginRepository;
|
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorUserLoginRepository;
|
||||||
|
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||||
import com.caliverse.admin.logs.Indicatordomain.UserLoginMongoLog;
|
import com.caliverse.admin.logs.Indicatordomain.UserLoginMongoLog;
|
||||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogUserLoginMultiService;
|
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogUserLoginMultiService;
|
||||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogUserLoginService;
|
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogUserLoginService;
|
||||||
|
import com.caliverse.admin.mongodb.dto.MongoPageResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.bson.Document;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.aggregation.*;
|
||||||
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class IndicatorsUserLoginService {
|
public class IndicatorsUserLoginService extends IndicatorsLogLoadServiceBase {
|
||||||
|
|
||||||
@Autowired private IndicatorUserLoginRepository indicatorUserLoginRepository;
|
@Autowired private IndicatorUserLoginRepository indicatorUserLoginRepository;
|
||||||
@Autowired private BusinessLogUserLoginService userLoginService;
|
@Autowired private BusinessLogUserLoginService userLoginService;
|
||||||
@Autowired private BusinessLogUserLoginMultiService userLoginMultiService;
|
@Autowired private BusinessLogUserLoginMultiService userLoginMultiService;
|
||||||
|
|
||||||
|
public IndicatorsUserLoginService(@Qualifier("mongoIndicatorTemplate") MongoTemplate mongoTemplate) {
|
||||||
|
super(mongoTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
public void collectUserLogin(String startTime, String endTime){
|
public void collectUserLogin(String startTime, String endTime){
|
||||||
String logTimeStr = startTime.substring(0, 10);
|
String logTimeStr = startTime.substring(0, 10);
|
||||||
|
|
||||||
@@ -65,4 +79,97 @@ public class IndicatorsUserLoginService {
|
|||||||
log.error("Not instanceof UserLoginLogInfo");
|
log.error("Not instanceof UserLoginLogInfo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends IndicatorsLog> List<T> getIndicatorsLogData(String startTime, String endTime, Class<T> clazz) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends IndicatorsLog> MongoPageResult<T> getLoginDetailLogData(
|
||||||
|
String searchType,
|
||||||
|
String searchData,
|
||||||
|
String tranId,
|
||||||
|
String startTime,
|
||||||
|
String endTime,
|
||||||
|
String orderBy,
|
||||||
|
Integer page,
|
||||||
|
Integer size,
|
||||||
|
Class<T> clazz
|
||||||
|
) {
|
||||||
|
Criteria criteria = makeCriteria(startTime, endTime, AdminConstants.MONGO_DB_KEY_LOGDAY);
|
||||||
|
|
||||||
|
UnwindOperation unwindOperation = Aggregation.unwind("sessions");
|
||||||
|
|
||||||
|
if(tranId != null && !tranId.isEmpty()){
|
||||||
|
criteria.and("sessions.tranId").is(tranId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(searchData != null && !searchData.isEmpty()){
|
||||||
|
switch (searchType){
|
||||||
|
case "GUID":
|
||||||
|
criteria.and("userGuid").is(searchData);
|
||||||
|
break;
|
||||||
|
case "NICKNAME":
|
||||||
|
criteria.and("userNickname").is(searchData);
|
||||||
|
break;
|
||||||
|
case "ACCOUNT":
|
||||||
|
criteria.and("accountId").is(searchData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.error("searchType: {} not support", searchType);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectionOperation projection = Aggregation.project()
|
||||||
|
.andExclude("_id")
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as("logDay")
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).as("accountId")
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_USER_GUID).as("userGuid")
|
||||||
|
.and(AdminConstants.MONGO_DB_KEY_USER_NICKNAME).as("userNickname")
|
||||||
|
.and("sessions.tranId").as("tranId")
|
||||||
|
.and("sessions.loginTime").as("loginTime")
|
||||||
|
.and("sessions.logoutTime").as("logoutTime")
|
||||||
|
.and("sessions.serverType").as("serverType")
|
||||||
|
.and("sessions.ip").as("ip")
|
||||||
|
.and("sessions.languageType").as("languageType")
|
||||||
|
.and("sessions.playtime").as("playtime");
|
||||||
|
|
||||||
|
List<AggregationOperation> baseOperations = new ArrayList<>(List.of(
|
||||||
|
unwindOperation,
|
||||||
|
Aggregation.match(criteria),
|
||||||
|
projection,
|
||||||
|
Aggregation.sort(orderBy.equals("DESC") ? Sort.Direction.DESC : Sort.Direction.ASC, "loginTime")
|
||||||
|
));
|
||||||
|
|
||||||
|
int totalCount = 0;
|
||||||
|
if(page != null && page != 0) {
|
||||||
|
List<AggregationOperation> countOperations = new ArrayList<>(baseOperations);
|
||||||
|
countOperations.add(Aggregation.count().as("total"));
|
||||||
|
|
||||||
|
Aggregation countAggregation = Aggregation.newAggregation(countOperations);
|
||||||
|
Document countResult = mongoTemplate.aggregate(
|
||||||
|
countAggregation.withOptions(AggregationOptions.builder().allowDiskUse(true).build()),
|
||||||
|
AdminConstants.MONGO_DB_COLLECTION_LOGIN,
|
||||||
|
Document.class
|
||||||
|
).getUniqueMappedResult();
|
||||||
|
totalCount = countResult != null ? countResult.getInteger("total") : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AggregationOperation> dataOperations = new ArrayList<>(baseOperations);
|
||||||
|
if(page != null && page != 0) {
|
||||||
|
int skip = (page - 1) * size;
|
||||||
|
dataOperations.add(Aggregation.skip((long) skip));
|
||||||
|
dataOperations.add(Aggregation.limit(size));
|
||||||
|
}
|
||||||
|
|
||||||
|
Aggregation aggregation = Aggregation.newAggregation(dataOperations);
|
||||||
|
List<T> items = mongoTemplate.aggregate(
|
||||||
|
aggregation.withOptions(AggregationOptions.builder().allowDiskUse(true).build()),
|
||||||
|
AdminConstants.MONGO_DB_COLLECTION_LOGIN,
|
||||||
|
clazz
|
||||||
|
).getMappedResults();
|
||||||
|
|
||||||
|
return new MongoPageResult<>(items, totalCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user