유저부분 신규 dynamodb domain 방식으로변경
아이템 처리 관련 추가
This commit is contained in:
@@ -18,6 +18,7 @@ import com.caliverse.admin.dynamodb.domain.doc.LandAuctionActivityDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionHighestBidUserDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
|
||||
import com.caliverse.admin.dynamodb.entity.ELandAuctionResult;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
@@ -65,6 +66,8 @@ public class DynamoDBService {
|
||||
private final DynamoDbEnhancedClient enhancedClient;
|
||||
private final DynamoDBOperations DynamoDBOperations;
|
||||
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
|
||||
private final AdminMapper adminMapper;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
//private final HistoryService historyService;
|
||||
@@ -76,12 +79,14 @@ public class DynamoDBService {
|
||||
HistoryService historyService,
|
||||
MetaDataHandler metaDataHandler,
|
||||
DynamoDbEnhancedClient enhancedClient,
|
||||
DynamoDBOperations DynamoDBOperations) {
|
||||
DynamoDBOperations DynamoDBOperations,
|
||||
DynamodbUserService dynamodbUserService) {
|
||||
this.dynamoDbClient = dynamoDbClient;
|
||||
this.adminMapper = adminMapper;
|
||||
this.metaDataHandler = metaDataHandler;
|
||||
this.enhancedClient = enhancedClient;
|
||||
this.DynamoDBOperations = DynamoDBOperations;
|
||||
this.dynamodbUserService = dynamodbUserService;
|
||||
}
|
||||
|
||||
// guid check
|
||||
@@ -91,239 +96,6 @@ public class DynamoDBService {
|
||||
return item.isEmpty();
|
||||
}
|
||||
|
||||
// nickname > guid
|
||||
public String getNickNameByGuid(String primaryKey) {
|
||||
Map<String, Object> resMap = new HashMap<>();
|
||||
Map<String, AttributeValue> key = new HashMap<>();
|
||||
key.put("PK", AttributeValue.builder().s("user_nickname_registry#global").build());
|
||||
key.put("SK", AttributeValue.builder().s(primaryKey.toLowerCase(Locale.ENGLISH)).build());
|
||||
// GetItem 요청을 만듭니다.
|
||||
GetItemRequest getItemRequest = GetItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(key)
|
||||
.build();
|
||||
|
||||
try {
|
||||
// GetItem 요청을 실행하고 응답을 받습니다.
|
||||
GetItemResponse response = dynamoDbClient.getItem(getItemRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
AttributeValue attributeValue = response.item().get("UserNicknameRegistryAttrib");
|
||||
|
||||
if (attributeValue != null) {
|
||||
String attrJsonString = attributeValue.s();
|
||||
// JSON 문자열을 파싱합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode attrJson = objectMapper.readTree(attrJsonString);
|
||||
|
||||
// 원하는 필드를 추출합니다.
|
||||
return attrJson.get("user_guid").asText();
|
||||
|
||||
}
|
||||
return primaryKey;
|
||||
} catch (Exception e) {
|
||||
log.error("getNickNameByGuid exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// guid > nickname
|
||||
public String getGuidByName(String guid){
|
||||
Map<String, AttributeValue> item = getItem("nickname#"+guid,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("NicknameAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("nickname"));
|
||||
}
|
||||
|
||||
// guid > account_id
|
||||
public String getGuidByAccountId(String guid){
|
||||
Map<String, AttributeValue> item = getItem("user_base#"+guid,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("UserBaseAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("account_id"));
|
||||
}
|
||||
|
||||
// account_id > guid
|
||||
public String getAccountIdByGuid(Long id){
|
||||
Map<String, AttributeValue> item = getItem("account_base#"+id,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("AccountBaseAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("user_guid"));
|
||||
}
|
||||
|
||||
// 유저 언어타입
|
||||
public String getUserLanguage(String guid){
|
||||
String account_id = getGuidByAccountId(guid);
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + account_id,"empty");
|
||||
|
||||
if(item.isEmpty()) return null;
|
||||
|
||||
Map<String, Object> attrMap = CommonUtils.stringByObject(item.get("AccountBaseAttrib").s());
|
||||
|
||||
return CommonUtils.objectToString(attrMap.get("language_type"));
|
||||
}
|
||||
|
||||
// 유저조회 타입별 분기
|
||||
public Map<String,String> findUsersBykey(String searchType, String searchKey){
|
||||
Map<String, String> resultMap = new HashMap<>();
|
||||
Map<String, AttributeValue> key = new HashMap<>();
|
||||
try {
|
||||
if(searchType.equals(SEARCHTYPE.NAME.name())){
|
||||
return getUsersByName(searchKey.toLowerCase()); //nickname은 무조건 소문자
|
||||
}else if(searchType.equals(SEARCHTYPE.GUID.name())){
|
||||
return getUsersByGuid(searchKey);
|
||||
}else if(searchType.equals(SEARCHTYPE.ACCOUNT.name())){
|
||||
return getUsersByAccountId(searchKey);
|
||||
}
|
||||
//else if(searchType.equals(SEARCHTYPE.TEMP_DATA.name())){
|
||||
// return historyService.insertTempMetaData();
|
||||
//}
|
||||
|
||||
|
||||
return resultMap;
|
||||
} catch (Exception e) {
|
||||
log.error("findUsersBykey exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 유저조회 닉네임
|
||||
// return guid, 닉네임
|
||||
public Map<String, String> getUsersByName(String searchKey){
|
||||
Map<String,String> resultMap = null;
|
||||
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
// .expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("nickname#"+searchKey).build()
|
||||
// ,":skValue", AttributeValue.builder().s("nickname#").build()))
|
||||
.expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("user_nickname_registry#global").build()
|
||||
,":skValue", AttributeValue.builder().s(searchKey).build()))
|
||||
.build();
|
||||
|
||||
try{
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
// AttributeValue attrValue = item.get("Attr");
|
||||
AttributeValue attrValue = item.get("UserNicknameRegistryAttrib");
|
||||
if (attrValue != null) {
|
||||
resultMap = new HashMap<>();
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// resultMap.put("guid", (String) attrMap.get("AccountGuid"));
|
||||
// resultMap.put("nickname", (String) attrMap.get("AccountId"));
|
||||
resultMap.put("guid", (String) attrMap.get("user_guid"));
|
||||
resultMap.put("nickname", searchKey);
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
log.error("getUsersByName exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 유저조회 guid
|
||||
// return guid, account_id
|
||||
public Map<String, String> getUsersByGuid(String searchKey){
|
||||
Map<String,String> resultMap = null;
|
||||
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
.expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("user_base#"+searchKey).build()
|
||||
,":skValue", AttributeValue.builder().s("empty").build()))
|
||||
.build();
|
||||
|
||||
try{
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("UserBaseAttrib");
|
||||
if (attrValue != null) {
|
||||
resultMap = new HashMap<>();
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
resultMap.put("guid", searchKey);
|
||||
resultMap.put("nickname", (String) attrMap.get("account_id"));
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
log.error("getUsersByGuid exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//유저조회 account_id
|
||||
//return guid, account_id
|
||||
public Map<String, String> getUsersByAccountId(String searchKey){
|
||||
Map<String,String> resultMap = null;
|
||||
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
.expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("account_base#"+searchKey).build()
|
||||
,":skValue", AttributeValue.builder().s("empty").build()))
|
||||
.build();
|
||||
|
||||
try{
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("AccountBaseAttrib");
|
||||
if (attrValue != null) {
|
||||
resultMap = new HashMap<>();
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
resultMap.put("guid", (String) attrMap.get("user_guid"));
|
||||
resultMap.put("nickname", (String) attrMap.get("account_id"));
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}catch (Exception e){
|
||||
log.error("getUsersByAccountId exception: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public Map<String, Object> getAccountInfo(String guid){
|
||||
// Map<String, Object> resMap = new HashMap<>();
|
||||
@@ -371,45 +143,6 @@ public class DynamoDBService {
|
||||
// } catch (Exception e) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 유저조회 - 기본정보
|
||||
// public Map<String, Object> getCharInfo(String guid){
|
||||
// Map<String, Object> resMap = new HashMap<>();
|
||||
//
|
||||
// String key = "PK = :pkValue AND SK = :skValue";
|
||||
// Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("money#"+guid).build()
|
||||
// ,":skValue", AttributeValue.builder().s("empty").build());
|
||||
//
|
||||
// try {
|
||||
// // 쿼리 실행
|
||||
// QueryResponse response = executeQuery(key, values);
|
||||
//
|
||||
// // 응답에서 원하는 속성을 가져옵니다.
|
||||
// for (Map<String, AttributeValue> item : response.items()) {
|
||||
//
|
||||
// //캐릭터 CharInfo 조회
|
||||
// AttributeValue charValue = item.get("MoneyAttrib");
|
||||
// if (charValue != null) {
|
||||
// // "Attr" 속성의 값을 읽어옵니다.
|
||||
// Map<String, AttributeValue> attrMap = charValue.m();
|
||||
//
|
||||
// resMap.put("charInfo", UsersResponse.CharInfo.builder()
|
||||
// .characterName(getGuidByName(guid))
|
||||
// .level(CommonUtils.objectToString(null))
|
||||
// .goldCali(CommonUtils.objectToString(attrMap.get("gold").n()))
|
||||
// .redCali(CommonUtils.objectToString(attrMap.get("calium").n()))
|
||||
// .blackCali(CommonUtils.objectToString(attrMap.get("ruby").n()))
|
||||
// .blueCali(CommonUtils.objectToString(attrMap.get("sapphire").n()))
|
||||
// .build());
|
||||
// }
|
||||
// }
|
||||
// log.info("getCharInfo CharInfo: {}", resMap);
|
||||
//
|
||||
// return resMap;
|
||||
// } catch (Exception e) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// 유저조회 - 아바타
|
||||
@@ -494,67 +227,6 @@ public class DynamoDBService {
|
||||
}
|
||||
}
|
||||
|
||||
//guid 로 item 테이블 조회
|
||||
public Map<String, Object> getItemTable(String guid){
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue AND SK = :skValue") // 파티션 키와 조건식 설정
|
||||
.expressionAttributeValues(
|
||||
Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build()
|
||||
,":skValue", AttributeValue.builder().s("item#"+guid).build()))
|
||||
.build();
|
||||
|
||||
try {
|
||||
// 쿼리 실행
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("Attr");
|
||||
if (attrValue != null) {
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// JSON 문자열을 Map으로 파싱
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
return attrMap;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void insertUpdateData(String guid, String type, boolean flag) {
|
||||
|
||||
// 업데이트할 데이터 맵 생성
|
||||
Map<String, AttributeValue> key = new HashMap<>();
|
||||
key.put("PK", AttributeValue.builder().s("char#"+guid).build());
|
||||
key.put("SK", AttributeValue.builder().s("char#"+guid).build());
|
||||
|
||||
Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<>();
|
||||
|
||||
attributeUpdates.put(type, AttributeValueUpdate.builder()
|
||||
.action(AttributeAction.PUT)
|
||||
.value(AttributeValue.builder().bool(flag).build())
|
||||
.build());
|
||||
|
||||
// UpdateItem 요청 작성
|
||||
UpdateItemRequest updateItemRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(key)
|
||||
.attributeUpdates(attributeUpdates)
|
||||
.build();
|
||||
|
||||
// 데이터 업데이트 또는 인서트 요청
|
||||
dynamoDbClient.updateItem(updateItemRequest);
|
||||
}
|
||||
|
||||
// dynamoDB 쿼리 리턴
|
||||
public QueryResponse executeQuery(String key, Map<String, AttributeValue> values) {
|
||||
QueryRequest getItemRequest = QueryRequest.builder()
|
||||
@@ -634,107 +306,6 @@ public class DynamoDBService {
|
||||
|
||||
}
|
||||
|
||||
public void updateBlockUserStart(BlackList blockUser){
|
||||
try{
|
||||
String accountId = getGuidByAccountId(blockUser.getGuid());
|
||||
SANCTIONS reasonType = blockUser.getSanctions();
|
||||
// SANCTIONSTYPE policyType = blockUser.getType();
|
||||
// List<SANCTIONSTYPE> listPolicyType = new ArrayList<>();
|
||||
// listPolicyType.add(policyType);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS");
|
||||
String startTime = blockUser.getStartDt().format(formatter);
|
||||
String endTime = blockUser.getEndDt().format(formatter);
|
||||
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + accountId,"empty");
|
||||
|
||||
String InfoJson = item.get("AccountBaseAttrib").s();
|
||||
log.info("updateBlockUserStart Before AccountBaseAttrib: {}", InfoJson);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
|
||||
((ObjectNode) infoNode).put("block_start_datetime", startTime);
|
||||
((ObjectNode) infoNode).put("block_end_datetime", endTime);
|
||||
ArrayNode policyArray = objectMapper.createArrayNode();
|
||||
policyArray.add(blockUser.getType().toString());
|
||||
((ObjectNode) infoNode).set("block_policy", policyArray);
|
||||
// ((ObjectNode) infoNode).put("block_policy", listPolicyType.toString());
|
||||
((ObjectNode) infoNode).put("block_reason", reasonType.toString());
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
String nowDateTime = LocalDateTime.now().format(formatter);
|
||||
log.info("updateBlockUserStart Tobe AccountBaseAttrib: {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
expressionAttributeValues.put(":nowDate", AttributeValue.builder().s(nowDateTime).build());
|
||||
|
||||
String updateExpression = "SET AccountBaseAttrib = :newAttrib, UpdatedDateTime = :nowDate";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("account_base#" + accountId).build(),
|
||||
"SK", AttributeValue.builder().s("empty").build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}catch(Exception e){
|
||||
log.error("updateBlockUserStart: " + e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBlockUserEnd(String guid){
|
||||
try{
|
||||
String accountId = getGuidByAccountId(guid);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS");
|
||||
String endTime = LocalDateTime.of(9999, 12, 31, 23, 59, 59, 999999900).format(formatter);
|
||||
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + accountId,"empty");
|
||||
|
||||
String InfoJson = item.get("AccountBaseAttrib").s();
|
||||
log.info("updateBlockUserEnd Before AccountBaseAttrib: {}", InfoJson);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
|
||||
((ObjectNode) infoNode).put("block_start_datetime", endTime);
|
||||
((ObjectNode) infoNode).put("block_end_datetime", endTime);
|
||||
((ObjectNode) infoNode).put("block_policy", new ArrayList<>().toString());
|
||||
((ObjectNode) infoNode).put("block_reason", "");
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
String nowDateTime = LocalDateTime.now().format(formatter);
|
||||
log.info("updateBlockUserEnd Tobe AccountBaseAttrib: {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
expressionAttributeValues.put(":nowDate", AttributeValue.builder().s(nowDateTime).build());
|
||||
|
||||
String updateExpression = "SET AccountBaseAttrib = :newAttrib, UpdatedDateTime = :nowDate";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("account_base#" + accountId).build(),
|
||||
"SK", AttributeValue.builder().s("empty").build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}catch(Exception e){
|
||||
log.error("updateBlockUserEnd: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
// 닉네임 변경
|
||||
public void updateNickname(String guid,String nickname,String newNickname){
|
||||
try{
|
||||
@@ -753,49 +324,6 @@ public class DynamoDBService {
|
||||
|
||||
}
|
||||
|
||||
// GM 권한 변경
|
||||
public void updateAdminLevel(String guid, String type){
|
||||
AuthAdminLevelType adminLevel = RabbitMqUtils.getUserAdminLevelType(type);
|
||||
|
||||
try{
|
||||
String accountId = getGuidByAccountId(guid);
|
||||
Map<String, AttributeValue> item = getItem("account_base#" + accountId, "empty");
|
||||
|
||||
String InfoJson = item.get("AccountBaseAttrib").s();
|
||||
log.info("updateAdminLevel Before AccountBaseAttrib: {}", InfoJson);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
|
||||
((ObjectNode) infoNode).put("auth_amdin_level_type", adminLevel.getNumber());
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
log.info("updateAdminLevel Tobe AccountBaseAttrib: {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
|
||||
String updateExpression = "SET AccountBaseAttrib = :newAttrib";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("account_base#" + accountId).build(),
|
||||
"SK", AttributeValue.builder().s("empty").build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}catch (Exception e){
|
||||
log.error("updateAdminLevel: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateCharInfo(String guid, String newNickname) throws JsonProcessingException {
|
||||
|
||||
// 기존 CharInfo 값 가져오기
|
||||
@@ -832,6 +360,7 @@ public class DynamoDBService {
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}
|
||||
|
||||
public void createNewNickName(String guid, String newNickname) {
|
||||
String attrJson = String.format("{\"AccountGuid\":\"%s\",\"AccountId\":\"%s\"}", guid, newNickname);
|
||||
|
||||
@@ -1180,61 +709,61 @@ public class DynamoDBService {
|
||||
}
|
||||
|
||||
//아이템 내역 조회
|
||||
public List<ItemList> getItems(String guid){
|
||||
List<ItemList> list = new ArrayList<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build());
|
||||
|
||||
// QueryRequest queryRequest = QueryRequest.builder()
|
||||
// .tableName(metaTable)
|
||||
// .keyConditionExpression("PK = :pkValue") // 파티션 키와 조건식 설정
|
||||
// .expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build()))
|
||||
// .build();
|
||||
|
||||
try {
|
||||
// 쿼리 실행
|
||||
QueryResponse response = executeQuery(key, values);
|
||||
|
||||
int row = 1;
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("ItemAttrib");
|
||||
if (attrValue != null) {
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
String item_nm = metaDataHandler.getMetaItemNameData(CommonUtils.objectToInteger(attrMap.get("item_meta_id")));
|
||||
ItemList itemInfo = ItemList.builder()
|
||||
.rowNum((long) row)
|
||||
.guid(guid)
|
||||
.itemId(attrMap.get("item_meta_id").toString())
|
||||
.itemName(metaDataHandler.getTextStringData(item_nm))
|
||||
.status(ItemList.STATUS.PERMITTED)
|
||||
.restoreType("")
|
||||
.createBy(item.get("CreatedDateTime").s()).build();
|
||||
|
||||
list.add(itemInfo);
|
||||
|
||||
row++;
|
||||
}
|
||||
}
|
||||
log.info("getItems Response ItemInfo: {}", list);
|
||||
}
|
||||
catch (JsonProcessingException jpe){
|
||||
log.error("getItems JsonProcessingException: {}", jpe.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch (Exception e){
|
||||
log.error("getItems: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
// public List<ItemList> getItems(String guid){
|
||||
// List<ItemList> list = new ArrayList<>();
|
||||
//
|
||||
// String key = "PK = :pkValue";
|
||||
// Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build());
|
||||
//
|
||||
//// QueryRequest queryRequest = QueryRequest.builder()
|
||||
//// .tableName(metaTable)
|
||||
//// .keyConditionExpression("PK = :pkValue") // 파티션 키와 조건식 설정
|
||||
//// .expressionAttributeValues(Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build()))
|
||||
//// .build();
|
||||
//
|
||||
// try {
|
||||
// // 쿼리 실행
|
||||
// QueryResponse response = executeQuery(key, values);
|
||||
//
|
||||
// int row = 1;
|
||||
// // 응답에서 원하는 속성을 가져옵니다.
|
||||
// for (Map<String, AttributeValue> item : response.items()) {
|
||||
// AttributeValue attrValue = item.get("ItemAttrib");
|
||||
// if (attrValue != null) {
|
||||
// // "Attr" 속성의 값을 읽어옵니다.
|
||||
// String attrJson = attrValue.s();
|
||||
//
|
||||
// // JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
// });
|
||||
//
|
||||
// String item_nm = metaDataHandler.getMetaItemNameData(CommonUtils.objectToInteger(attrMap.get("item_meta_id")));
|
||||
// ItemList itemInfo = ItemList.builder()
|
||||
// .rowNum((long) row)
|
||||
// .guid(guid)
|
||||
// .itemId(attrMap.get("item_meta_id").toString())
|
||||
// .itemName(metaDataHandler.getTextStringData(item_nm))
|
||||
// .status(ItemList.STATUS.PERMITTED)
|
||||
// .restoreType("")
|
||||
// .createBy(item.get("CreatedDateTime").s()).build();
|
||||
//
|
||||
// list.add(itemInfo);
|
||||
//
|
||||
// row++;
|
||||
// }
|
||||
// }
|
||||
// log.info("getItems Response ItemInfo: {}", list);
|
||||
// }
|
||||
// catch (JsonProcessingException jpe){
|
||||
// log.error("getItems JsonProcessingException: {}", jpe.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }catch (Exception e){
|
||||
// log.error("getItems: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
|
||||
//아이템 - 의상 조회
|
||||
public Map<String, Object> getCloth(String guid){
|
||||
@@ -1360,9 +889,9 @@ public class DynamoDBService {
|
||||
String item_type = metaDataHandler.getMetaItemLargeTypeData(item_id);
|
||||
|
||||
UsersResponse.Item inventory = UsersResponse.Item.builder()
|
||||
.itemId(CommonUtils.objectToString(item_id))
|
||||
.itemId(item_id)
|
||||
.itemName(item_nm)
|
||||
.count(CommonUtils.objectToDouble(attrMap.get("item_stack_count")))
|
||||
.count(CommonUtils.objectToInteger(attrMap.get("item_stack_count")))
|
||||
.itemGuid(CommonUtils.objectToString(attrMap.get("item_guid")))
|
||||
.build();
|
||||
|
||||
@@ -1396,55 +925,6 @@ public class DynamoDBService {
|
||||
}
|
||||
}
|
||||
|
||||
// 유저 조회 - 메일
|
||||
public List<UsersResponse.Mail> getMail(String guid, String type){
|
||||
List<UsersResponse.Mail> resList = new ArrayList<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = null;
|
||||
if(type.equals(SEARCHTYPE.SEND.name())){
|
||||
values = Map.of(":pkValue", AttributeValue.builder().s("sent_mail#"+guid).build());
|
||||
}else{
|
||||
values = Map.of(":pkValue", AttributeValue.builder().s("recv_mail#"+guid).build());
|
||||
}
|
||||
|
||||
try {
|
||||
excuteItems(executeQuery(key, values), "MailAttrib")
|
||||
.forEach(attrMap -> {
|
||||
List<UsersResponse.MailItem> itemList = new ArrayList<>();
|
||||
for (Map<String,Object> val : (List<Map<String,Object>>)attrMap.get("item_list")){
|
||||
UsersResponse.MailItem item = new UsersResponse.MailItem();
|
||||
item.setItemId(CommonUtils.objectToString(val.get("ItemId")));
|
||||
item.setCount(CommonUtils.objectToDouble(val.get("Count")));
|
||||
String item_nm = metaDataHandler.getMetaItemNameData(CommonUtils.objectToInteger(val.get("ItemId")));
|
||||
item.setItemName(metaDataHandler.getTextStringData(item_nm));
|
||||
itemList.add(item);
|
||||
}
|
||||
|
||||
UsersResponse.Mail mail = UsersResponse.Mail.builder()
|
||||
.mailGuid(CommonUtils.objectToString(attrMap.get("mail_guid")))
|
||||
.createDt(CommonUtils.objectToString(attrMap.get("create_time")))
|
||||
.title(CommonUtils.objectToString(attrMap.get("title")))
|
||||
.content(CommonUtils.objectToString(attrMap.get("text")))
|
||||
.receiveNickname(CommonUtils.objectToString(attrMap.get("receiver_nickname")))
|
||||
.senderNickname(CommonUtils.objectToString(attrMap.get("sender_nickname")))
|
||||
.isGetItem((boolean)attrMap.get("is_get_item"))
|
||||
.status((boolean) attrMap.get("is_read"))
|
||||
.isSystemMail((boolean) attrMap.get("is_system_mail"))
|
||||
.mailItemList(itemList)
|
||||
.build();
|
||||
|
||||
resList.add(mail);
|
||||
});
|
||||
log.info("getMail Response MailInfo: {}", resList);
|
||||
|
||||
return resList;
|
||||
} catch (Exception e) {
|
||||
log.error("getMail: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 유저 조회 - 우편 삭제
|
||||
public String deleteMail(String type, String guid, String mail_guid) {
|
||||
Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
@@ -1559,78 +1039,78 @@ public class DynamoDBService {
|
||||
}
|
||||
|
||||
// 아이템 삭제
|
||||
public String deleteItem(String guid, String item_guid) {
|
||||
Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
itemAttributes.put("PK", AttributeValue.builder().s("item#" + guid).build());
|
||||
itemAttributes.put("SK", AttributeValue.builder().s(item_guid).build());
|
||||
try {
|
||||
Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
log.info("deleteItem PK: {}, SK: {}", "item#" + guid, item_guid);
|
||||
|
||||
DeleteItemRequest request = DeleteItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(itemAttributes)
|
||||
.build();
|
||||
|
||||
DeleteItemResponse response = dynamoDbClient.deleteItem(request);
|
||||
|
||||
if(response.sdkHttpResponse().isSuccessful())
|
||||
return item.toString();
|
||||
|
||||
return "";
|
||||
}catch (ConditionalCheckFailedException e) {
|
||||
log.error("deleteItem Conditional check failed: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch(Exception e){
|
||||
log.error("deleteItem: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
// public String deleteItem(String guid, String item_guid) {
|
||||
// Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
// itemAttributes.put("PK", AttributeValue.builder().s("item#" + guid).build());
|
||||
// itemAttributes.put("SK", AttributeValue.builder().s(item_guid).build());
|
||||
// try {
|
||||
// Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
// log.info("deleteItem PK: {}, SK: {}", "item#" + guid, item_guid);
|
||||
//
|
||||
// DeleteItemRequest request = DeleteItemRequest.builder()
|
||||
// .tableName(metaTable)
|
||||
// .key(itemAttributes)
|
||||
// .build();
|
||||
//
|
||||
// DeleteItemResponse response = dynamoDbClient.deleteItem(request);
|
||||
//
|
||||
// if(response.sdkHttpResponse().isSuccessful())
|
||||
// return item.toString();
|
||||
//
|
||||
// return "";
|
||||
// }catch (ConditionalCheckFailedException e) {
|
||||
// log.error("deleteItem Conditional check failed: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }catch(Exception e){
|
||||
// log.error("deleteItem: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// 아이템 정보 수정
|
||||
public JSONObject updateItem(String guid, String item_guid, int cnt) {
|
||||
try{
|
||||
|
||||
Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
|
||||
String InfoJson = item.get("ItemAttrib").s();
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
log.info("updateItem Before UpdateInfo : {}", infoNode.toString());
|
||||
|
||||
((ObjectNode) infoNode).put("item_stack_count", cnt);
|
||||
|
||||
String updatedInfoJson = infoNode.toString();
|
||||
log.info("updateItem Tobe UpdateInfo : {}", updatedInfoJson);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
|
||||
String updateExpression = "SET ItemAttrib = :newAttrib";
|
||||
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s("item#" + guid).build(),
|
||||
"SK", AttributeValue.builder().s(item_guid).build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data(before)", InfoJson);
|
||||
jsonObject.put("data(after)", updatedInfoJson);
|
||||
return jsonObject;
|
||||
}catch(Exception e){
|
||||
log.error("updateItem: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
}
|
||||
}
|
||||
// public JSONObject updateItem(String guid, String item_guid, int cnt) {
|
||||
// try{
|
||||
//
|
||||
// Map<String, AttributeValue> item = getItem("item#" + guid, item_guid);
|
||||
//
|
||||
// String InfoJson = item.get("ItemAttrib").s();
|
||||
//
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
// log.info("updateItem Before UpdateInfo : {}", infoNode.toString());
|
||||
//
|
||||
// ((ObjectNode) infoNode).put("item_stack_count", cnt);
|
||||
//
|
||||
// String updatedInfoJson = infoNode.toString();
|
||||
// log.info("updateItem Tobe UpdateInfo : {}", updatedInfoJson);
|
||||
//
|
||||
// Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
// expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
//
|
||||
// String updateExpression = "SET ItemAttrib = :newAttrib";
|
||||
//
|
||||
// UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
// .tableName(metaTable)
|
||||
// .key(Map.of(
|
||||
// "PK", AttributeValue.builder().s("item#" + guid).build(),
|
||||
// "SK", AttributeValue.builder().s(item_guid).build()))
|
||||
// .updateExpression(updateExpression)
|
||||
// .expressionAttributeValues(expressionAttributeValues)
|
||||
// .returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
// .build();
|
||||
//
|
||||
//
|
||||
// dynamoDbClient.updateItem(updateRequest);
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("data(before)", InfoJson);
|
||||
// jsonObject.put("data(after)", updatedInfoJson);
|
||||
// return jsonObject;
|
||||
// }catch(Exception e){
|
||||
// log.error("updateItem: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage() );
|
||||
// }
|
||||
// }
|
||||
|
||||
// 아이템 - 타투 죄회
|
||||
public List<UsersResponse.Tattoo> getTattoo(String guid){Map<String, Object> resultMap = new HashMap<>();
|
||||
@@ -1680,9 +1160,9 @@ public class DynamoDBService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String friend_guid = CommonUtils.objectToString(attrMap.get("friend_guid"));
|
||||
friend.setFriendGuid(friend_guid);
|
||||
friend.setFriendName(getGuidByName(friend_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(friend_guid));
|
||||
friend.setReceiveDt(CommonUtils.objectToString(attrMap.get("create_time")));
|
||||
friend.setLanguage(LANGUAGETYPE.values()[Integer.parseInt(getUserLanguage(friend_guid))].toString());
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(guid));
|
||||
resList.add(friend);
|
||||
});
|
||||
log.info("getFriendList FriendInfo: {}", resList);
|
||||
@@ -1719,9 +1199,9 @@ public class DynamoDBService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String block_guid = CommonUtils.objectToString(attrMap.get("guid"));
|
||||
friend.setFriendGuid(block_guid);
|
||||
friend.setFriendName(getGuidByName(block_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(block_guid));
|
||||
friend.setReceiveDt(CommonUtils.objectToString(item.get("CreatedDateTime").s()));
|
||||
friend.setLanguage(LANGUAGETYPE.values()[Integer.parseInt(getUserLanguage(block_guid))].toString());
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(guid));
|
||||
|
||||
resList.add(friend);
|
||||
}
|
||||
@@ -1750,12 +1230,12 @@ public class DynamoDBService {
|
||||
String second_key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> second_values = Map.of(":pkValue", AttributeValue.builder().s("item#"+myhome_guid).build());
|
||||
excuteItems(executeQuery(second_key, second_values), "ItemAttrib").forEach(attrMap2 -> {
|
||||
String item_id = CommonUtils.objectToString(attrMap2.get("item_meta_id"));
|
||||
String item_name = metaDataHandler.getMetaItemNameData(Integer.parseInt(item_id));
|
||||
int item_id = CommonUtils.objectToInteger(attrMap2.get("item_meta_id"));
|
||||
String item_name = metaDataHandler.getMetaItemNameData(item_id);
|
||||
UsersResponse.Item item = UsersResponse.Item.builder()
|
||||
.itemId(item_id)
|
||||
.itemName(metaDataHandler.getTextStringData(item_name))
|
||||
.count(CommonUtils.objectToDouble(attrMap2.get("item_stack_count")))
|
||||
.count(CommonUtils.objectToInteger(attrMap2.get("item_stack_count")))
|
||||
.itemGuid(CommonUtils.objectToString(attrMap2.get("item_guid")))
|
||||
.build();
|
||||
itemList.add(item);
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.caliverse.admin.domain.adminlog.AdminItemDeleteLog;
|
||||
import com.caliverse.admin.domain.adminlog.IAdminLog;
|
||||
import com.caliverse.admin.domain.dao.admin.HistoryMapper;
|
||||
import com.caliverse.admin.domain.entity.ItemList;
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.ITEMLARGETYPE;
|
||||
import com.caliverse.admin.domain.entity.SEARCHTYPE;
|
||||
import com.caliverse.admin.domain.response.ItemDeleteResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.caliverse.admin.domain.response.UsersResponse;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbItemService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.caliverse.admin.domain.request.ItemsRequest;
|
||||
@@ -21,33 +23,75 @@ import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ItemsService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ItemsService.class);
|
||||
|
||||
private final DynamoDBService dynamoDBService;
|
||||
private final UserGameSessionService userGameSessionService;
|
||||
private final DynamoDBQueryServiceBase dynamoDBQueryServiceBase;
|
||||
private final HistoryMapper historyMapper;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
private final DynamodbItemService dynamodbItemService;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
|
||||
public ItemsResponse findItems(ItemsRequest itemDeleteRequest){
|
||||
String guid = "";
|
||||
String searchData = itemDeleteRequest.getSearchData();
|
||||
|
||||
|
||||
// 아이템 정보 조회 GUID,item ID, item name
|
||||
public ItemsResponse findItems(Map<String,String> requestParam){
|
||||
String searchType = requestParam.get("search_type").toString();
|
||||
String search_key = requestParam.get("search_key").toString().trim();
|
||||
String guid = search_key;
|
||||
|
||||
if(searchType.equals(SEARCHTYPE.NAME.name())){
|
||||
guid = dynamoDBService.getNickNameByGuid(search_key);
|
||||
if(itemDeleteRequest.getSearchType().equals(SEARCHTYPE.NAME)){
|
||||
guid = dynamodbUserService.getNameByGuid(searchData);
|
||||
}else{
|
||||
guid = dynamodbUserService.isUser(searchData) ? searchData: "";
|
||||
}
|
||||
|
||||
List<ItemList> itemList = dynamoDBService.getItems(guid);
|
||||
if(guid.isEmpty()){
|
||||
return ItemsResponse.builder()
|
||||
.status(CommonCode.ERROR.getHttpStatus())
|
||||
.result(CommonCode.ERROR.getResult())
|
||||
.resultData(ItemsResponse.ResultData.builder()
|
||||
.message(ErrorCode.DYNAMODB_NOT_USER.name())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
PageResult<ItemDoc> itemPageResult = dynamodbItemService.getItems(guid, itemDeleteRequest.getPageKey());
|
||||
List<ItemsResponse.Item> items = new ArrayList<>();
|
||||
String finalGuid = guid;
|
||||
itemPageResult.getItems().forEach(itemDoc -> {
|
||||
ItemAttrib attrib = CommonUtils.stringByObject(itemDoc.getAttribValue(), ItemAttrib.class);
|
||||
int itemId = attrib.getItemMetaId();
|
||||
String itemType = metaDataHandler.getMetaItemLargeTypeData(itemId);
|
||||
ItemsResponse.Item item = ItemsResponse.Item.builder()
|
||||
.userGuid(finalGuid)
|
||||
.itemGuid(attrib.getItemGuid())
|
||||
.id(itemId)
|
||||
.itemId(itemId)
|
||||
.itemName(metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(itemId)))
|
||||
.count(attrib.getItemStackCount())
|
||||
.level(attrib.getLevel())
|
||||
.equipedPos(attrib.getEquipedPos())
|
||||
.equipType(attrib.getEquipedIvenType())
|
||||
.itemType(ITEMLARGETYPE.valueOf(itemType))
|
||||
.createDt(itemDoc.getCreatedDateTime())
|
||||
.build();
|
||||
items.add(item);
|
||||
});
|
||||
|
||||
return ItemsResponse.builder()
|
||||
.resultData(ItemsResponse.ResultData.builder()
|
||||
.list(itemList)
|
||||
.itemList(items)
|
||||
.pageKey(itemPageResult.getLastEvaluatedKey() == null ?
|
||||
null :
|
||||
itemPageResult.getLastEvaluatedKey().entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
entry -> entry.getValue().s()
|
||||
))
|
||||
)
|
||||
.build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -57,19 +101,20 @@ public class ItemsService {
|
||||
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public ItemDeleteResponse postItemDelete(ItemsRequest itemDeleteRequest){
|
||||
var userGuid = itemDeleteRequest.getUserGuid();
|
||||
var itemGuid = itemDeleteRequest.getItemGuid();
|
||||
var itemCount = itemDeleteRequest.getItemCount();
|
||||
String userGuid = itemDeleteRequest.getUserGuid();
|
||||
String itemGuid = itemDeleteRequest.getItemGuid();
|
||||
int itemCount = itemDeleteRequest.getItemCount();
|
||||
int deleteCount = itemDeleteRequest.getDeleteCount();
|
||||
|
||||
//UserKick
|
||||
userGameSessionService.kickUserSession(userGuid, "item delete");
|
||||
//ItemDelete
|
||||
dynamoDBQueryServiceBase.deleteUserItem(userGuid, itemGuid);
|
||||
|
||||
//로그 기록
|
||||
IAdminLog adminLog = new AdminItemDeleteLog(userGuid, itemGuid, itemCount);
|
||||
adminLog.saveLogToDB();
|
||||
|
||||
if(deleteCount >= itemCount){
|
||||
dynamodbItemService.deleteItem(userGuid, itemGuid);
|
||||
}else{
|
||||
int cnt = itemCount - deleteCount;
|
||||
dynamodbItemService.updateItemStack(userGuid, itemGuid, cnt);
|
||||
}
|
||||
|
||||
return ItemDeleteResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.caliverse.admin.domain.entity.*;
|
||||
import com.caliverse.admin.domain.request.MailRequest;
|
||||
import com.caliverse.admin.domain.response.MailResponse;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbCaliumService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.code.SuccessCode;
|
||||
@@ -38,6 +39,7 @@ import java.util.*;
|
||||
public class MailService {
|
||||
private final DynamoDBService dynamoDBService;
|
||||
private final WalletUserMapper walletUserMapper;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
|
||||
@Value("${excel.file-path}")
|
||||
private String excelPath;
|
||||
@@ -323,7 +325,7 @@ public class MailService {
|
||||
if (mailRequest.getGuid() != null) {
|
||||
String guid = mailRequest.getGuid();
|
||||
// 닉네임이면 guid로 바꾼다
|
||||
if(mailRequest.getUserType().equals(Mail.USERTYPE.NICKNAME)) guid = dynamoDBService.getNickNameByGuid(guid);
|
||||
if(mailRequest.getUserType().equals(Mail.USERTYPE.NICKNAME)) guid = dynamodbUserService.getNameByGuid(guid);
|
||||
mailRequest.setReceiveType(Mail.RECEIVETYPE.SINGLE);
|
||||
mailRequest.setTarget(guid);
|
||||
} else {
|
||||
@@ -486,9 +488,9 @@ public class MailService {
|
||||
public String getGuid(String target, String type){
|
||||
if(Mail.USERTYPE.EMAIL.name().equals(type)){
|
||||
WalletUser user = walletUserMapper.getUser(target);
|
||||
return dynamoDBService.getAccountIdByGuid(user.getAccount_id());
|
||||
return dynamodbUserService.getAccountIdByGuid(String.valueOf(user.getAccount_id()));
|
||||
}else if(Mail.USERTYPE.NICKNAME.name().equals(type)){
|
||||
return dynamoDBService.getNickNameByGuid(target);
|
||||
return dynamodbUserService.getNameByGuid(target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -8,6 +9,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import com.caliverse.admin.domain.entity.FriendRequest;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPE;
|
||||
import com.caliverse.admin.domain.entity.SEARCHTYPE;
|
||||
import com.caliverse.admin.domain.request.MailRequest;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.AccountBaseAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MailAttrib;
|
||||
@@ -15,6 +17,7 @@ import com.caliverse.admin.dynamodb.domain.atrrib.MailJsonAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MoneyAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MailDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbItemService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbUserService;
|
||||
import com.caliverse.admin.global.common.utils.DynamodbUtil;
|
||||
@@ -50,15 +53,12 @@ public class UsersService {
|
||||
private final HistoryService historyService;
|
||||
private final UserGameSessionService userGameSessionService;
|
||||
private final RedisUserInfoService redisUserInfoService;
|
||||
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
private final DynamodbItemService dynamodbItemService;
|
||||
|
||||
//metadataHandler 어떻게 가져와야 되는가
|
||||
@Autowired
|
||||
private MetaDataHandler metaDataHandler;
|
||||
@Qualifier("objectMapper")
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
@Autowired
|
||||
private DynamodbUserService dynamodbUserService;
|
||||
|
||||
// 닉네임 변경
|
||||
public UsersResponse changeNickname(UsersRequest usersRequest){
|
||||
@@ -72,8 +72,9 @@ public class UsersService {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), check.getMessage() );
|
||||
}
|
||||
|
||||
Map<String, String> serachNickname = dynamoDBService.getUsersByName(newNickname);
|
||||
if(serachNickname != null){
|
||||
String isGuid = dynamodbUserService.getNameByGuid(newNickname);
|
||||
|
||||
if(!isGuid.isEmpty()){
|
||||
//변경 닉네임이 존재합니다. 다시 시도해주세요.
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NICKNAME_EXIT_ERROR.getMessage() );
|
||||
}else{
|
||||
@@ -93,9 +94,8 @@ public class UsersService {
|
||||
// GM 권한 변경
|
||||
public UsersResponse changeAdminLevel(UsersRequest usersRequest){
|
||||
String guid = usersRequest.getGuid();
|
||||
String type = usersRequest.getAdminLevel();
|
||||
|
||||
dynamoDBService.updateAdminLevel(guid, type);
|
||||
dynamodbUserService.updateAdminLevel(guid, usersRequest.getAdminLevel());
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(UsersResponse.ResultData.builder()
|
||||
@@ -130,11 +130,22 @@ public class UsersService {
|
||||
String searchType = requestParam.get("search_type").toString();
|
||||
String searchKey = requestParam.get("search_key").toString();
|
||||
|
||||
Map<String,String> res = dynamoDBService.findUsersBykey(searchType, searchKey);
|
||||
// Map<String,String> res = dynamoDBService.findUsersBykey(searchType, searchKey);
|
||||
Map<String,String> resultMap = new HashMap<>();
|
||||
if(searchType.equals(SEARCHTYPE.NAME.name())){
|
||||
resultMap.put("guid", dynamodbUserService.getNameByGuid(searchKey.toLowerCase())); //nickname은 무조건 소문자
|
||||
resultMap.put("nickname", searchKey);
|
||||
}else if(searchType.equals(SEARCHTYPE.GUID.name())){
|
||||
resultMap.put("guid", searchKey);
|
||||
resultMap.put("nickname", dynamodbUserService.getGuidByName(searchKey));
|
||||
}else if(searchType.equals(SEARCHTYPE.ACCOUNT.name())){
|
||||
resultMap.put("guid", dynamodbUserService.getAccountIdByGuid(searchKey));
|
||||
resultMap.put("nickname", dynamodbUserService.getAccountIdByName(searchKey));
|
||||
}
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(UsersResponse.ResultData.builder()
|
||||
.result(res)
|
||||
.result(resultMap)
|
||||
.build())
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -156,7 +167,7 @@ public class UsersService {
|
||||
.accessDt(accountBaseAttrib.getLoginDateTime())
|
||||
.endDt(accountBaseAttrib.getLogoutDateTime())
|
||||
.walletUrl("")
|
||||
.adminLevel(accountBaseAttrib.getAuthAdminLevelType().name())
|
||||
.adminLevel(accountBaseAttrib.getAuthAdminLevelType())
|
||||
.spareSlot("")
|
||||
.build();
|
||||
|
||||
@@ -265,7 +276,8 @@ public class UsersService {
|
||||
// inventoryList.add(innerList);
|
||||
// }
|
||||
// }
|
||||
UsersResponse.InventoryInfo inventoryInfo = dynamoDBService.getInvenItems(guid);
|
||||
// UsersResponse.InventoryInfo inventoryInfo = dynamoDBService.getInvenItems(guid);
|
||||
UsersResponse.InventoryInfo inventoryInfo = dynamodbItemService.getInvenItems(guid);
|
||||
logger.info("getInventoryInfo Inventory Items: {}", inventoryInfo);
|
||||
|
||||
return UsersResponse.builder()
|
||||
@@ -288,12 +300,13 @@ public class UsersService {
|
||||
|
||||
userGameSessionService.kickUserSession(guid, "Item delete");
|
||||
if(update_cnt >= current_cnt){
|
||||
String attrib = dynamoDBService.deleteItem(guid, item_guid);
|
||||
if(!attrib.isEmpty()){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data",attrib);
|
||||
historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_DELETE, jsonObject);
|
||||
}
|
||||
// String attrib = dynamoDBService.deleteItem(guid, item_guid);
|
||||
// if(!attrib.isEmpty()){
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("data",attrib);
|
||||
// historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_DELETE, jsonObject);
|
||||
// }
|
||||
dynamodbItemService.deleteItem(guid, item_guid);
|
||||
return UsersResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -303,10 +316,11 @@ public class UsersService {
|
||||
.build();
|
||||
}else{
|
||||
int cnt = current_cnt - update_cnt;
|
||||
JSONObject json = dynamoDBService.updateItem(guid, item_guid, cnt);
|
||||
if(!json.isEmpty()){
|
||||
historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_UPDATE, json);
|
||||
}
|
||||
dynamodbItemService.updateItemStack(guid, item_guid, cnt);
|
||||
// JSONObject json = dynamoDBService.updateItem(guid, item_guid, cnt);
|
||||
// if(!json.isEmpty()){
|
||||
// historyService.setLog(HISTORYTYPE.INVENTORY_ITEM_UPDATE, json);
|
||||
// }
|
||||
return UsersResponse.builder()
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
@@ -319,7 +333,7 @@ public class UsersService {
|
||||
|
||||
public UsersResponse getMail(UsersRequest usersRequest){
|
||||
// List<UsersResponse.Mail> mailList = dynamoDBService.getMail(guid, type);
|
||||
PageResult<MailDoc> mailPageResult = dynamodbService.getMail(usersRequest.getMailType(), usersRequest.getGuid(), "", "", "", usersRequest.getPageKey(), false);
|
||||
PageResult<MailDoc> mailPageResult = dynamodbService.getMail(usersRequest.getMailType(), usersRequest.getGuid(), "", usersRequest.getPageKey());
|
||||
List<UsersResponse.Mail> mailList = new ArrayList<>();
|
||||
|
||||
mailPageResult.getItems().forEach(doc -> {
|
||||
@@ -377,7 +391,7 @@ public class UsersService {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return;
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), e.getMessage());
|
||||
}
|
||||
});
|
||||
return UsersResponse.builder()
|
||||
@@ -469,9 +483,9 @@ public class UsersService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String receive_guid = friendReq.getReceiverGuid();
|
||||
friend.setFriendGuid(receive_guid);
|
||||
friend.setFriendName(dynamoDBService.getGuidByName(receive_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(receive_guid));
|
||||
friend.setReceiveDt(friendReq.getRequestTime());
|
||||
friend.setLanguage(dynamoDBService.getUserLanguage(receive_guid));
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(receive_guid));
|
||||
|
||||
friendSendList.add(friend);
|
||||
}
|
||||
@@ -481,9 +495,9 @@ public class UsersService {
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String send_guid = friendReq.getSenderGuid();
|
||||
friend.setFriendGuid(send_guid);
|
||||
friend.setFriendName(dynamoDBService.getGuidByName(send_guid));
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(send_guid));
|
||||
friend.setReceiveDt(friendReq.getRequestTime());
|
||||
friend.setLanguage(dynamoDBService.getUserLanguage(send_guid));
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(send_guid));
|
||||
|
||||
friendReceiveList.add(friend);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user