user block 처리 수정

dynamodb UserBase 변경부분으로 교체
This commit is contained in:
2025-02-15 02:21:19 +09:00
parent 62ba0c760e
commit d31778293a
5 changed files with 48 additions and 31 deletions

View File

@@ -47,8 +47,8 @@ public class BlackList {
public enum STATUSTYPE { public enum STATUSTYPE {
WAIT, WAIT,
EXPIRATION, EXPIRATION, // 제재 종료
INPROGRESS, INPROGRESS, // 제재 중
FAIL FAIL
; ;
} }

View File

@@ -6,6 +6,7 @@ import com.caliverse.admin.domain.entity.BlackList;
import com.caliverse.admin.domain.entity.HISTORYTYPE; import com.caliverse.admin.domain.entity.HISTORYTYPE;
import com.caliverse.admin.domain.request.BlackListRequest; import com.caliverse.admin.domain.request.BlackListRequest;
import com.caliverse.admin.domain.response.BlackListResponse; import com.caliverse.admin.domain.response.BlackListResponse;
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
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.code.SuccessCode; import com.caliverse.admin.global.common.code.SuccessCode;
@@ -37,6 +38,7 @@ public class BlackListService {
private final HistoryMapper historyMapper; private final HistoryMapper historyMapper;
private final HistoryService historyService; private final HistoryService historyService;
private final DynamoDBService dynamoDBService; private final DynamoDBService dynamoDBService;
private final DynamodbUserService dynamodbUserService;
@Value("${caliverse.file}") @Value("${caliverse.file}")
private String excelPath; private String excelPath;
private final ResourceLoader resourceLoader; private final ResourceLoader resourceLoader;
@@ -104,7 +106,8 @@ public class BlackListService {
//adminDB 에 데이터 있는지 체크 //adminDB 에 데이터 있는지 체크
int cnt = blackListMapper.getCountByGuid(item); int cnt = blackListMapper.getCountByGuid(item);
//gameDB isWhiteUser 값 체크 //gameDB isWhiteUser 값 체크
boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(item); // boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(item);
boolean isBlackUser = dynamodbUserService.isBlockUser(item);
boolean isGuid = dynamoDBService.isGuidChecked(item); boolean isGuid = dynamoDBService.isGuidChecked(item);
// //guid 검증 // //guid 검증
@@ -157,7 +160,8 @@ public class BlackListService {
if(dynamoDBService.isGuidChecked(guid)){ if(dynamoDBService.isGuidChecked(guid)){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage()); throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage());
} }
boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(guid); // boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(guid);
boolean isBlackUser = dynamodbUserService.isBlockUser(guid);
if(isBlackUser){ if(isBlackUser){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage()); throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage());
} }
@@ -181,7 +185,8 @@ public class BlackListService {
if(dynamoDBService.isGuidChecked(item.getGuid())){ if(dynamoDBService.isGuidChecked(item.getGuid())){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage()); throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.GUID_CHECK.getMessage());
} }
boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(item.getGuid()); // boolean isBlackUser = dynamoDBService.isWhiteOrBlackUser(item.getGuid());
boolean isBlackUser = dynamodbUserService.isBlockUser(item.getGuid());
if(isBlackUser){ if(isBlackUser){
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage()); throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_EXIT_ERROR.getMessage());
} }
@@ -256,11 +261,12 @@ public class BlackListService {
return blackListMapper.getScheduleBlackList(); return blackListMapper.getScheduleBlackList();
} }
public void updateScheduleBlockUser(BlackList blockUser, String type){ public void updateScheduleBlockUser(BlackList blockUser, BlackList.STATUSTYPE status){
if(type.equals("start")){ // if(status.equals(BlackList.STATUSTYPE.INPROGRESS)){
dynamoDBService.updateBlockUserStart(blockUser); // dynamoDBService.updateBlockUserStart(blockUser);
}else{ // }else{
dynamoDBService.updateBlockUserEnd(blockUser.getGuid()); // dynamoDBService.updateBlockUserEnd(blockUser.getGuid());
} // }
dynamodbUserService.updateBlockUser(status, blockUser);
} }
} }

View File

@@ -1,34 +1,22 @@
package com.caliverse.admin.dynamodb.service; package com.caliverse.admin.dynamodb.service;
import com.caliverse.admin.Indicators.entity.MoneyLogInfo;
import com.caliverse.admin.domain.entity.BlackList; import com.caliverse.admin.domain.entity.BlackList;
import com.caliverse.admin.domain.entity.Event; import com.caliverse.admin.dynamodb.domain.atrrib.UserBaseAttrib;
import com.caliverse.admin.dynamodb.domain.atrrib.MoneyAttrib; import com.caliverse.admin.dynamodb.repository.*;
import com.caliverse.admin.dynamodb.domain.atrrib.UserNicknameRegistryAttrib;
import com.caliverse.admin.dynamodb.repository.AccountBaseRepository;
import com.caliverse.admin.dynamodb.repository.MoneyRepository;
import com.caliverse.admin.dynamodb.repository.SystemMetaMailRepository;
import com.caliverse.admin.dynamodb.repository.UserNicknameRegistryRepository;
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction; import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
import com.caliverse.admin.global.common.constants.AdminConstants; import com.fasterxml.jackson.core.JsonProcessingException;
import com.caliverse.admin.logs.Indicatordomain.StartEndTime;
import com.caliverse.admin.logs.logservice.LogServiceHelper;
import com.caliverse.admin.logs.logservice.indicators.IndicatorsMoneyService;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class DynamodbUserService { public class DynamodbUserService {
private final DynamoDBOperations DynamoDBOperations;
private final AccountBaseRepository accountBaseRepository; private final AccountBaseRepository accountBaseRepository;
private final UserBaseRepository userBaseRepository;
private final IndicatorsMoneyService moneyService;
private final ObjectMapper mapper = new ObjectMapper(); private final ObjectMapper mapper = new ObjectMapper();
@@ -36,4 +24,27 @@ public class DynamodbUserService {
return accountBaseRepository.isBlockUser(account_id); return accountBaseRepository.isBlockUser(account_id);
} }
@DynamoDBTransaction
public void updateBlockUser(BlackList.STATUSTYPE status, BlackList blackList){
String guid = blackList.getGuid();
UserBaseAttrib userBaseAttrib = userBaseRepository.findUser(guid);
if(userBaseAttrib == null){
try {
log.error("updateBlockUser UserBase Null blackList: {}", mapper.writeValueAsString(blackList));
}catch (JsonProcessingException e){
log.error("updateBlockUser BlackList JsonProcessingException");
}
return;
}
String account_id = userBaseAttrib.getAccountId();
if(status.equals(BlackList.STATUSTYPE.INPROGRESS)){
accountBaseRepository.updateBlockUserStart(account_id, blackList);
}
else{
accountBaseRepository.updateBlockUserEnd(account_id);
}
}
} }

View File

@@ -195,13 +195,13 @@ public class DynamicScheduler {
if(!nowDate.isBefore(startTime) && blockUser.getStatus().equals(BlackList.STATUSTYPE.WAIT)){ if(!nowDate.isBefore(startTime) && blockUser.getStatus().equals(BlackList.STATUSTYPE.WAIT)){
// user kick 처리 // user kick 처리
userGameSessionService.kickUserSession(blockUser.getGuid()); userGameSessionService.kickUserSession(blockUser.getGuid());
blackListService.updateScheduleBlockUser(blockUser, "start"); blackListService.updateScheduleBlockUser(blockUser, BlackList.STATUSTYPE.INPROGRESS);
blackListService.updateBlackListStatus(blockUser.getId(), BlackList.STATUSTYPE.INPROGRESS); blackListService.updateBlackListStatus(blockUser.getId(), BlackList.STATUSTYPE.INPROGRESS);
log.info("blackListJob blackListSchedule block start : {}", blockUser); log.info("blackListJob blackListSchedule block start : {}", blockUser);
} }
if(!nowDate.isBefore(endTime) && blockUser.getStatus().equals(BlackList.STATUSTYPE.INPROGRESS)){ if(!nowDate.isBefore(endTime) && blockUser.getStatus().equals(BlackList.STATUSTYPE.INPROGRESS)){
blackListService.updateScheduleBlockUser(blockUser, "end"); blackListService.updateScheduleBlockUser(blockUser, BlackList.STATUSTYPE.EXPIRATION);
blackListService.updateBlackListStatus(blockUser.getId(), BlackList.STATUSTYPE.EXPIRATION); blackListService.updateBlackListStatus(blockUser.getId(), BlackList.STATUSTYPE.EXPIRATION);
log.info("blackListJob blackListSchedule block end : {}", blockUser); log.info("blackListJob blackListSchedule block end : {}", blockUser);
} }

View File

@@ -69,14 +69,14 @@ public class BlackListScheduler implements Scheduler {
if(!nowDate.isBefore(startTime) && blackList.getStatus().equals(BlackList.STATUSTYPE.WAIT)) { if(!nowDate.isBefore(startTime) && blackList.getStatus().equals(BlackList.STATUSTYPE.WAIT)) {
// user kick 처리 // user kick 처리
userGameSessionService.kickUserSession(blackList.getGuid()); userGameSessionService.kickUserSession(blackList.getGuid());
blackListService.updateScheduleBlockUser(blackList, "start"); blackListService.updateScheduleBlockUser(blackList, BlackList.STATUSTYPE.INPROGRESS);
blackListService.updateBlackListStatus(blackList.getId(), BlackList.STATUSTYPE.INPROGRESS); blackListService.updateBlackListStatus(blackList.getId(), BlackList.STATUSTYPE.INPROGRESS);
log.info("blackListJob blackListSchedule block start : {}", blackList); log.info("blackListJob blackListSchedule block start : {}", blackList);
} }
// 종료시간 지났으면 만료 처리 // 종료시간 지났으면 만료 처리
if(!nowDate.isBefore(endTime) && blackList.getStatus().equals(BlackList.STATUSTYPE.INPROGRESS)) { if(!nowDate.isBefore(endTime) && blackList.getStatus().equals(BlackList.STATUSTYPE.INPROGRESS)) {
blackListService.updateScheduleBlockUser(blackList, "end"); blackListService.updateScheduleBlockUser(blackList, BlackList.STATUSTYPE.EXPIRATION);
blackListService.updateBlackListStatus(blackList.getId(), BlackList.STATUSTYPE.EXPIRATION); blackListService.updateBlackListStatus(blackList.getId(), BlackList.STATUSTYPE.EXPIRATION);
log.info("blackListJob blackListSchedule block end : {}", blackList); log.info("blackListJob blackListSchedule block end : {}", blackList);
} }