dynamodb accountBase 관련 처리
This commit is contained in:
@@ -22,6 +22,7 @@ public enum HISTORYTYPE {
|
||||
MAIL_ITEM_DELETE("우편 아이템 삭제"),
|
||||
MAIL_ITEM_UPDATE("우편 아이템 수정"),
|
||||
WHITELIST_DELETE("화이트리스트 삭제"),
|
||||
BLACKLIST_UPDATE("유저 제재 수정"),
|
||||
BLACKLIST_DELETE("유저 제재 삭제"),
|
||||
REPORT_DELETE("신고내역 삭제"),
|
||||
USER_ITEM_DELETE("유저 아이템 삭제"),
|
||||
|
||||
@@ -1,23 +1,10 @@
|
||||
package com.caliverse.admin.domain.entity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum LANGUAGETYPE {
|
||||
NONE,
|
||||
KO, // 한국어(기본값)
|
||||
EN, // 영어
|
||||
TH, // 태국
|
||||
//LanguageType_zh, // 중국어
|
||||
JA, // 일본어
|
||||
//LanguageType_fr, // 프랑스어
|
||||
//LanguageType_de, // 독일어
|
||||
//LanguageType_es, // 스페인어
|
||||
//LanguageType_ru, // 러시아어
|
||||
//LanguageType_ar // 아랍어
|
||||
JA // 일본어
|
||||
;
|
||||
|
||||
public static List<LANGUAGETYPE> getAllLanguages() {
|
||||
return Arrays.asList(LANGUAGETYPE.values());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.caliverse.admin.domain.entity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public enum Language {
|
||||
All,
|
||||
Ko,
|
||||
En,
|
||||
Ja,
|
||||
;
|
||||
|
||||
|
||||
public static List<Language> getAllLanguages() {
|
||||
return Arrays.asList(Language.values());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.caliverse.admin.domain.entity.common;
|
||||
|
||||
public enum EAccountType {
|
||||
|
||||
None,
|
||||
Google,
|
||||
Apple
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.caliverse.admin.domain.entity.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public interface ValueEnum {
|
||||
@JsonValue
|
||||
int getValue();
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.caliverse.admin.dynamodb.domain.atrrib;
|
||||
|
||||
import com.caliverse.admin.dynamodb.entity.EAccountCreationType;
|
||||
import com.caliverse.admin.dynamodb.entity.EAccountType;
|
||||
import com.caliverse.admin.dynamodb.entity.EAuthAdminLevelType;
|
||||
import com.caliverse.admin.dynamodb.entity.ELanguageType;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import lombok.*;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@@ -20,9 +26,31 @@ public class AccountBaseAttrib extends DynamoDBAttribBase {
|
||||
private String userGuid;
|
||||
private String password;
|
||||
@JsonProperty("account_type")
|
||||
private String AccountType;
|
||||
private EAccountType AccountType;
|
||||
@JsonProperty("language_type")
|
||||
private String languageType;
|
||||
private ELanguageType languageType;
|
||||
@JsonProperty("auth_amdin_level_type")
|
||||
private String authAdminLevelType;
|
||||
private EAuthAdminLevelType authAdminLevelType;
|
||||
@JsonProperty("account_creation_type")
|
||||
private EAccountCreationType accountCreationType;
|
||||
@JsonProperty("account_creation_meta_id")
|
||||
private Integer accountCreationMetaId;
|
||||
@JsonProperty("login_datetime")
|
||||
private String loginDateTime;
|
||||
@JsonProperty("logout_datetime")
|
||||
private String logoutDateTime;
|
||||
@JsonProperty("created_datetime")
|
||||
private String createdDateTime;
|
||||
@JsonProperty("block_start_datetime")
|
||||
private String blockStartDateTime;
|
||||
@JsonProperty("block_end_datetime")
|
||||
private String blockEndDateTime;
|
||||
@JsonProperty("block_policy")
|
||||
private List<String> blockPolicy;
|
||||
@JsonProperty("block_reason")
|
||||
private String blockReason;
|
||||
@JsonProperty("access_token")
|
||||
private Long accessToken;
|
||||
@JsonProperty("sso_account_auth_jwt")
|
||||
private String ssoAccountAuthJWT;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.caliverse.admin.dynamodb.domain.doc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbAttribute;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@DynamoDbBean
|
||||
public class AccountBaseDoc extends DynamoDBDocBase {
|
||||
private String accountBaseAttrib;
|
||||
|
||||
public String getAttribFieldName() {
|
||||
return "AccountBaseAttrib";
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("AccountBaseAttrib")
|
||||
@JsonProperty("AccountBaseAttrib")
|
||||
public String getAttribValue() {
|
||||
return accountBaseAttrib;
|
||||
}
|
||||
|
||||
public void setAttribValue(String value) {
|
||||
this.accountBaseAttrib = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
|
||||
import com.caliverse.admin.domain.entity.common.ValueEnum;
|
||||
|
||||
public enum EAccountCreationType implements ValueEnum {
|
||||
None(0),
|
||||
Normal(1),
|
||||
Test(2),
|
||||
Bot(3),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
||||
EAccountCreationType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
|
||||
import com.caliverse.admin.domain.entity.common.ValueEnum;
|
||||
|
||||
public enum EAccountType implements ValueEnum {
|
||||
None(0),
|
||||
Google(1),
|
||||
Apple(2),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
||||
EAccountType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
|
||||
import com.caliverse.admin.domain.entity.common.ValueEnum;
|
||||
|
||||
public enum EAuthAdminLevelType implements ValueEnum {
|
||||
None(0),
|
||||
GmNormal(1),
|
||||
GmSuper(2),
|
||||
Developer(3),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
||||
EAuthAdminLevelType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum EDayOfWeekType {
|
||||
|
||||
Sunday(0), // 일요일
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
|
||||
import com.caliverse.admin.domain.entity.common.ValueEnum;
|
||||
|
||||
public enum ELanguageType implements ValueEnum {
|
||||
All(0),
|
||||
Ko(1),
|
||||
En(2),
|
||||
Ja(4),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
||||
ELanguageType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.caliverse.admin.dynamodb.entity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum EOncePeriodRangeType {
|
||||
|
||||
NONE(0),
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.entity.BlackList;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.AccountBaseDoc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AccountBaseRepository extends DynamoDBRepository<AccountBaseDoc> {
|
||||
boolean isBlockUser(String account_id);
|
||||
void updateBlockUserStart(String account_id, BlackList blackList);
|
||||
void updateBlockUserEnd(String account_id);
|
||||
AccountBaseAttrib findUser(Long account_id);
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.BlackList;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.UserNicknameRegistryAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.AccountBaseDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.UserNicknameRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.repository.AccountBaseRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.UserNicknameRegistryRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.constants.CommonConstants;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.history.service.DynamodbHistoryLogService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.caliverse.admin.global.common.utils.DateUtils.getDynamodbDateFormat;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AccountBaseRepositoryImpl extends BaseDynamoDBRepository<AccountBaseDoc> implements AccountBaseRepository {
|
||||
public AccountBaseRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
|
||||
super(operations, AccountBaseDoc.class, dynamodbHistoryLogService, objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockUser(String account_id) {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_ACCOUNT_BASE + account_id)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
AccountBaseDoc doc = findById(key);
|
||||
|
||||
try {
|
||||
AccountBaseAttrib attrib = objectMapper.readValue(doc.getAttribValue(), AccountBaseAttrib.class);
|
||||
List<String> block_policy = attrib.getBlockPolicy();
|
||||
return !block_policy.isEmpty();
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBlockUserStart(String account_id, BlackList blackList) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_ACCOUNT_BASE + account_id)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
AccountBaseDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
AccountBaseDoc afterDoc = deepCopy(beforeDoc, AccountBaseDoc.class);
|
||||
|
||||
List<String> block_policy = new ArrayList<>();
|
||||
block_policy.add(blackList.getType().toString());
|
||||
|
||||
AccountBaseAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), AccountBaseAttrib.class);
|
||||
attrib.setBlockStartDateTime(getDynamodbDateFormat(blackList.getStartDt()));
|
||||
attrib.setBlockEndDateTime(getDynamodbDateFormat(blackList.getEndDt()));
|
||||
attrib.setBlockPolicy(block_policy);
|
||||
attrib.setBlockReason(blackList.getSanctions().toString());
|
||||
|
||||
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(LocalDateTime.now()));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("updateBlockUserStart Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.BLACKLIST_UPDATE,
|
||||
HISTORYTYPE.BLACKLIST_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonConstants.SCHEDULE,
|
||||
""
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBlockUserEnd(String account_id) {
|
||||
try {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_ACCOUNT_BASE + account_id)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
AccountBaseDoc beforeDoc = findById(key);
|
||||
|
||||
if (beforeDoc != null) {
|
||||
AccountBaseDoc afterDoc = deepCopy(beforeDoc, AccountBaseDoc.class);
|
||||
|
||||
String max_date = getDynamodbDateFormat(LocalDateTime.of(9999, 12, 31, 23, 59, 59, 999999900));
|
||||
|
||||
AccountBaseAttrib attrib = objectMapper.readValue(afterDoc.getAttribValue(), AccountBaseAttrib.class);
|
||||
attrib.setBlockStartDateTime(max_date);
|
||||
attrib.setBlockEndDateTime(max_date);
|
||||
attrib.setBlockPolicy(new ArrayList<>());
|
||||
attrib.setBlockReason("");
|
||||
|
||||
afterDoc.setAttribValue(objectMapper.writeValueAsString(attrib));
|
||||
afterDoc.setUpdatedDateTime(CommonUtils.convertUTCDate(LocalDateTime.now()));
|
||||
|
||||
update(afterDoc);
|
||||
|
||||
log.info("updateBlockUserEnd Update Success: {}", objectMapper.writeValueAsString(afterDoc));
|
||||
|
||||
dynamodbHistoryLogService.updateHistoryLog(
|
||||
HISTORYTYPE.BLACKLIST_UPDATE,
|
||||
HISTORYTYPE.BLACKLIST_UPDATE.name(),
|
||||
beforeDoc,
|
||||
afterDoc,
|
||||
CommonConstants.SCHEDULE,
|
||||
""
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountBaseAttrib findUser(Long account_id) {
|
||||
Key key = Key.builder()
|
||||
.partitionValue(DynamoDBConstants.PK_KEY_ACCOUNT_BASE + account_id)
|
||||
.sortValue(DynamoDBConstants.EMPTY)
|
||||
.build();
|
||||
|
||||
AccountBaseDoc doc = findById(key);
|
||||
|
||||
try {
|
||||
return objectMapper.readValue(doc.getAttribValue(), AccountBaseAttrib.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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.Event;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MoneyAttrib;
|
||||
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.constants.AdminConstants;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DynamodbUserService {
|
||||
private final DynamoDBOperations DynamoDBOperations;
|
||||
private final AccountBaseRepository accountBaseRepository;
|
||||
|
||||
private final IndicatorsMoneyService moneyService;
|
||||
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
public boolean isBlockUser(String account_id){
|
||||
return accountBaseRepository.isBlockUser(account_id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class DynamoDBConstants {
|
||||
public static final String PK_KEY_BUILDING = "building#";
|
||||
public static final String PK_KEY_OWNED_BUILDING = "owned_building#";
|
||||
public static final String PK_KEY_BATTLE_EVENT = "management_battle_event#global";
|
||||
public static final String PK_KEY_ACCOUNT_BASE = "account_base#";
|
||||
|
||||
//SK
|
||||
|
||||
|
||||
@@ -26,4 +26,9 @@ public class DateUtils {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return stringToDateTime(now);
|
||||
}
|
||||
|
||||
public static String getDynamodbDateFormat(LocalDateTime date){
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS");
|
||||
return date.format(formatter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.caliverse.admin.domain.entity.LANGUAGETYPE;
|
||||
import com.caliverse.admin.logs.Indicatordomain.AuMongoLog;
|
||||
|
||||
|
||||
public class IndicatorsLogHelper {
|
||||
|
||||
public static Map<String, AuMongoLog> createLanguageMap()
|
||||
{
|
||||
Map<String, AuMongoLog> map = new HashMap<String, AuMongoLog>();
|
||||
|
||||
for(LANGUAGETYPE lang : LANGUAGETYPE.getAllLanguages()){
|
||||
map.put(lang.toString(), new AuMongoLog());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// public static Class getClassByAuDayNumber(int dayNumber){
|
||||
// switch(dayNumber){
|
||||
// case AdmiinConstants.STAT_DAY_NUM:
|
||||
// return DauLogInfo.class;
|
||||
// case AdmiinConstants.STAT_WEEK_NUM:
|
||||
// return WauLogInfo.class;
|
||||
// case AdmiinConstants.STAT_MONTH_NUM:
|
||||
// return MauLogInfo.class;
|
||||
// default:
|
||||
// return DauLogInfo.class;
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user