dynamodb 마이홈, 친구목록 구성
예전버전 dynamodb 정리
This commit is contained in:
@@ -49,9 +49,4 @@ public class UserReportController {
|
||||
@RequestBody UserReportRequest userReportRequest){
|
||||
return ResponseEntity.ok().body( userReportService.reportReply(userReportRequest));
|
||||
}
|
||||
@PostMapping("/dummy")
|
||||
public void dummy(
|
||||
@RequestBody Map<String, String> map){
|
||||
userReportService.dummy(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.caliverse.admin.domain.datacomponent;
|
||||
import com.caliverse.admin.domain.service.DynamoDBService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
@EnableCaching
|
||||
public class DynamoDBDataHandler {
|
||||
|
||||
@Autowired
|
||||
private DynamoDBService dynamoDBService;
|
||||
|
||||
/**
|
||||
* nickname에 대한 guid 정보 캐싱
|
||||
* @param nickname
|
||||
* @return guid
|
||||
*/
|
||||
@Cacheable(value = "nickNameByGuidData", key = "#p0", unless = "#result == null")
|
||||
public String getNicknameByGuidData(String nickname) {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class UsersResponse {
|
||||
@JsonProperty("mail_list")
|
||||
private List<Mail> mailList;
|
||||
@JsonProperty("myhome_info")
|
||||
private Myhome myhomeInfo;
|
||||
private List<Myhome> myhomeInfo;
|
||||
@JsonProperty("friend_list")
|
||||
private List<Friend> friendList;
|
||||
@JsonProperty("friend_send_list")
|
||||
@@ -141,7 +141,7 @@ public class UsersResponse {
|
||||
@Data
|
||||
@Builder
|
||||
public static class ClothItem {
|
||||
private String cloth;
|
||||
private Integer cloth;
|
||||
private String clothName;
|
||||
@JsonProperty("EquipSlotType")
|
||||
private String slotType;
|
||||
@@ -267,7 +267,7 @@ public class UsersResponse {
|
||||
@JsonProperty("item_guid")
|
||||
private String itemGuid;
|
||||
@JsonProperty("item_id")
|
||||
private Long itemId;
|
||||
private Integer itemId;
|
||||
@JsonProperty("item_name")
|
||||
private String itemName;
|
||||
private Double count;
|
||||
@@ -289,7 +289,7 @@ public class UsersResponse {
|
||||
@Builder
|
||||
public static class ToolItem{
|
||||
@JsonProperty("tool_id")
|
||||
private String toolId;
|
||||
private Integer toolId;
|
||||
@JsonProperty("tool_name")
|
||||
private String toolName;
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class DynamoDBAttributeCreateService {
|
||||
|
||||
|
||||
public Map<String, AttributeValue> makeItemAttributeKey(String userGuid, String itemGuid){
|
||||
Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
itemAttributes.put("PK", AttributeValue.builder().s("item#" + userGuid).build());
|
||||
itemAttributes.put("SK", AttributeValue.builder().s(itemGuid).build());
|
||||
return itemAttributes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
|
||||
import software.amazon.awssdk.services.dynamodb.model.DeleteItemRequest;
|
||||
import software.amazon.awssdk.services.dynamodb.model.DeleteItemResponse;
|
||||
|
||||
|
||||
/*
|
||||
* 추후에 일반화 처리 필요
|
||||
* */
|
||||
@Service
|
||||
public class DynamoDBQueryServiceBase {
|
||||
|
||||
@Value("${amazon.dynamodb.metaTable}")
|
||||
private String metaTable;
|
||||
|
||||
private final DynamoDbClient dynamoDbClient;
|
||||
private final DynamoDBAttributeCreateService dynamoDBAttributeCreateService;
|
||||
|
||||
public DynamoDBQueryServiceBase(DynamoDbClient dynamoDbClient
|
||||
, DynamoDBAttributeCreateService dynamoDBAttributeCreateService
|
||||
) {
|
||||
this.dynamoDBAttributeCreateService = dynamoDBAttributeCreateService;
|
||||
this.dynamoDbClient = dynamoDbClient;
|
||||
}
|
||||
|
||||
|
||||
public void deleteUserItem(String userGuid, String itemGuid) {
|
||||
|
||||
|
||||
var itemAttributes = dynamoDBAttributeCreateService.makeItemAttributeKey(userGuid, itemGuid);
|
||||
|
||||
DeleteItemRequest request = DeleteItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(itemAttributes)
|
||||
.build();
|
||||
|
||||
DeleteItemResponse response = dynamoDbClient.deleteItem(request);
|
||||
|
||||
if (!response.sdkHttpResponse().isSuccessful()) {
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_ITEM_DELETE_FAIL.getMessage() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,946 +0,0 @@
|
||||
package com.caliverse.admin.domain.service;
|
||||
|
||||
import com.caliverse.admin.domain.RabbitMq.RabbitMqUtils;
|
||||
import com.caliverse.admin.domain.RabbitMq.message.AuthAdminLevelType;
|
||||
import com.caliverse.admin.domain.dao.admin.AdminMapper;
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.metadata.MetaQuestData;
|
||||
import com.caliverse.admin.domain.entity.*;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.domain.request.UserReportRequest;
|
||||
import com.caliverse.admin.domain.response.UserReportResponse;
|
||||
import com.caliverse.admin.domain.response.UsersResponse;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionActivityAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionHighestBidUserAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.LandAuctionRegistryAttrib;
|
||||
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;
|
||||
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.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
|
||||
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
|
||||
import software.amazon.awssdk.services.dynamodb.model.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DynamoDBService {
|
||||
@Value("${amazon.dynamodb.metaTable}")
|
||||
private String metaTable;
|
||||
|
||||
private final DynamoDbClient dynamoDbClient;
|
||||
private final DynamoDbEnhancedClient enhancedClient;
|
||||
private final DynamoDBOperations DynamoDBOperations;
|
||||
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
|
||||
private final AdminMapper adminMapper;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
//private final HistoryService historyService;
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@Autowired
|
||||
public DynamoDBService(DynamoDbClient dynamoDbClient,
|
||||
AdminMapper adminMapper,
|
||||
HistoryService historyService,
|
||||
MetaDataHandler metaDataHandler,
|
||||
DynamoDbEnhancedClient enhancedClient,
|
||||
DynamoDBOperations DynamoDBOperations,
|
||||
DynamodbUserService dynamodbUserService) {
|
||||
this.dynamoDbClient = dynamoDbClient;
|
||||
this.adminMapper = adminMapper;
|
||||
this.metaDataHandler = metaDataHandler;
|
||||
this.enhancedClient = enhancedClient;
|
||||
this.DynamoDBOperations = DynamoDBOperations;
|
||||
this.dynamodbUserService = dynamodbUserService;
|
||||
}
|
||||
|
||||
// guid check
|
||||
// public boolean isGuidChecked(String guid) {
|
||||
// Map<String, AttributeValue> item = getItem("user_base#"+guid,"empty");
|
||||
//
|
||||
// return item.isEmpty();
|
||||
// }
|
||||
|
||||
|
||||
// public Map<String, Object> getAccountInfo(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("account_base#"+guid).build()
|
||||
// ,":skValue", AttributeValue.builder().s("empty").build());
|
||||
//
|
||||
// try {
|
||||
// // 쿼리 실행
|
||||
// QueryResponse response = executeQuery(key, values);
|
||||
//
|
||||
// // 응답에서 원하는 속성을 가져옵니다.
|
||||
// for (Map<String, AttributeValue> item : response.items()) {
|
||||
// AttributeValue attrValue = item.get("AccountBaseAttrib");
|
||||
// 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>>() {});
|
||||
//
|
||||
// resMap.put("userInfo", UsersResponse.UserInfo.builder()
|
||||
// .aid(CommonUtils.objectToString(attrMap.get("user_guid")))
|
||||
// .userId(CommonUtils.objectToString(attrMap.get("account_id")))
|
||||
// .nation(LANGUAGETYPE.values()[CommonUtils.objectToInteger(attrMap.get("language_type"))])
|
||||
// //
|
||||
// .membership(CommonUtils.objectToString(null))
|
||||
// //todo 친구 추천 코드 임시 null 값으로 셋팅 23.09.20
|
||||
// .friendCode(CommonUtils.objectToString(null))
|
||||
// .createDt(CommonUtils.objectToString(attrMap.get("created_datetime")))
|
||||
// .accessDt(CommonUtils.objectToString(attrMap.get("login_datetime")))
|
||||
// .endDt(CommonUtils.objectToString(attrMap.get("logout_datetime")))
|
||||
// .walletUrl(CommonUtils.objectToString(attrMap.get("connect_facewallet")))
|
||||
// .adminLevel(CommonUtils.objectToString(attrMap.get("auth_amdin_level_type")))
|
||||
// //todo 예비슬롯 임시 null 값으로 셋팅 23.09.20
|
||||
// .spareSlot(CommonUtils.objectToString(null))
|
||||
// .build());
|
||||
// }
|
||||
// }
|
||||
// log.info("getAccountInfo UserInfo: {}", resMap);
|
||||
//
|
||||
// return resMap;
|
||||
// } catch (Exception e) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// 유저조회 - 아바타
|
||||
// public Map<String, Object> getAvatarInfo(String guid){
|
||||
// Map<String, Object> resMap = new HashMap<>();
|
||||
//
|
||||
// String key = "PK = :pkValue";
|
||||
// Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("character_base#"+guid).build());
|
||||
//
|
||||
// try {
|
||||
// excuteItems(executeQuery(key, values), "CharacterBaseAttrib")
|
||||
// .forEach(attrMap -> {
|
||||
// Map<String, Object> profile = (Map<String, Object>) attrMap.get("appearance_profile");
|
||||
//
|
||||
// //Object customValue = attrMap.get("CustomValue");
|
||||
// resMap.put("avatarInfo", UsersResponse.AvatarInfo.builder()
|
||||
// .characterId(CommonUtils.objectToString(attrMap.get("character_guid")))
|
||||
// .basicstyle(CommonUtils.objectToString(profile.get("basic_style")))
|
||||
// .hairstyle(CommonUtils.objectToString(profile.get("hair_style")))
|
||||
// .facesCustomizing(CommonUtils.objectToIntArray(profile.get("custom_values")))
|
||||
// .bodyshape(CommonUtils.objectToString(profile.get("body_shape")))
|
||||
// .build());
|
||||
// });
|
||||
// log.info("getAvatarInfo AvatarInfo: {}", resMap);
|
||||
//
|
||||
// return resMap;
|
||||
// } catch (Exception e) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
//퀘스트 조회
|
||||
// public List<UsersResponse.QuestInfo> getQuest(String guid){
|
||||
// List<UsersResponse.QuestInfo> res = new ArrayList<>();
|
||||
// String key = "PK = :pkValue";
|
||||
// Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("quest#"+guid).build());
|
||||
//
|
||||
// try {
|
||||
// excuteItems(executeQuery(key, values), "QuestAttrib")
|
||||
// .forEach(attrMap -> {
|
||||
// Integer questId = (Integer) attrMap.get("quest_id");
|
||||
// Integer current_task_no = (Integer)attrMap.get("current_task_num");
|
||||
// List<MetaQuestData> metaQuests = metaDataHandler.getMetaQuestData(questId);
|
||||
// // 상세보기 퀘스트 전체 리스트
|
||||
//
|
||||
// List<UsersResponse.Quest> detailQuests = metaQuests.stream()
|
||||
// .map(metaData -> UsersResponse.Quest.builder()
|
||||
// .questId(metaData.getQuestId())
|
||||
// .taskNo(metaData.getTaskNum())
|
||||
// .questName(metaDataHandler.getTextStringData(metaData.getTaskName()))
|
||||
// .counter(metaData.getCounter())
|
||||
// .status(current_task_no > metaData.getTaskNum() ? "완료" : "미완료" )
|
||||
// .build())
|
||||
// .toList();
|
||||
//
|
||||
// //퀘스트 명칭
|
||||
// String taskName = metaQuests.stream()
|
||||
// .filter(attr -> attr.getTaskNum().equals(current_task_no))
|
||||
// .map(MetaQuestData::getTaskName)
|
||||
// .findFirst().orElse(null);
|
||||
//
|
||||
// UsersResponse.QuestInfo questInfo = UsersResponse.QuestInfo.builder()
|
||||
// .questId(questId)
|
||||
// .questName(metaDataHandler.getTextStringData(taskName))
|
||||
// .status(CommonUtils.objectToString(attrMap.get("is_complete")))
|
||||
// .assignTime((String) attrMap.get("quest_assign_time"))
|
||||
// .type((String) attrMap.get("quest_type"))
|
||||
// .startTime((String) attrMap.get("task_start_time"))
|
||||
// .completeTime((String) attrMap.get("quest_complete_time"))
|
||||
// .currentTaskNum((Integer) attrMap.get("current_task_num"))
|
||||
// .detailQuest(detailQuests)
|
||||
// .build();
|
||||
//
|
||||
// res.add(questInfo);
|
||||
// });
|
||||
// log.info("getQuest QuestInfo: {}", res);
|
||||
//
|
||||
// return res;
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// dynamoDB 쿼리 리턴
|
||||
public QueryResponse executeQuery(String key, Map<String, AttributeValue> values) {
|
||||
QueryRequest getItemRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression(key)
|
||||
.expressionAttributeValues(values)
|
||||
.build();
|
||||
|
||||
return dynamoDbClient.query(getItemRequest);
|
||||
}
|
||||
|
||||
public Map<String, AttributeValue> getItem(String partitionKey, String sortKey) {
|
||||
Map<String, AttributeValue> keyMap = new HashMap<>();
|
||||
keyMap.put("PK", AttributeValue.builder().s(partitionKey).build());
|
||||
keyMap.put("SK", AttributeValue.builder().s(sortKey).build());
|
||||
try{
|
||||
// GetItem 요청 작성
|
||||
GetItemRequest getItemRequest = GetItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(keyMap)
|
||||
.build();
|
||||
|
||||
// 아이템 가져오기
|
||||
GetItemResponse getItemResponse = dynamoDbClient.getItem(getItemRequest);
|
||||
return getItemResponse.item();
|
||||
}catch (Exception e){
|
||||
log.error("getItem Fail: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Stream<Map<String, Object>> excuteItems (QueryResponse response, String attrip){
|
||||
return response.items().stream()
|
||||
.map(item -> item.get(attrip))
|
||||
.filter(Objects::nonNull)
|
||||
.map(AttributeValue::s)
|
||||
.map(attrJson -> {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
return objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {});
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException("JSON parsing error", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//신고 내역 조회
|
||||
public List<UserReportResponse.Report> getUserReportList(Map<String,String> requestParam) {
|
||||
|
||||
List<UserReportResponse.Report> list = new ArrayList<>();
|
||||
String startTime = CommonUtils.objectToString(requestParam.get("start_dt"));
|
||||
String endTime = CommonUtils.objectToString(requestParam.get("end_dt"));
|
||||
|
||||
String expression = "PK = :pkValue and SK BETWEEN :skStartDt AND :skEndDt";
|
||||
|
||||
/*
|
||||
LocalDateTime startDt =CommonUtils.stringToTime(startTime);
|
||||
LocalDateTime endDt = CommonUtils.stringToTime(endTime);
|
||||
|
||||
int months = CommonUtils.calculateMonths(startDt, endDt);
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
for (int i = 0 ; i < months; i++){
|
||||
expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":pkValue", AttributeValue.builder().s("userReport#" + startDt.getYear()
|
||||
+String.format("%02d", startDt.plusMonths(i).getMonthValue())).build());
|
||||
expressionAttributeValues.put(":skStartDt", AttributeValue.builder().s("report#" + startDt).build());
|
||||
expressionAttributeValues.put(":skEndDt", AttributeValue.builder().s("report#" + endDt).build());
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression(expression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.build();
|
||||
try {
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("ReportInfo");
|
||||
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>>() {});
|
||||
//담당자 검색
|
||||
Map<String, Object> replyInfoMap = null;
|
||||
if(item.get("ReplyInfo")!= null){
|
||||
//담당자 검색
|
||||
String replyInfo = item.get("ReplyInfo").s();
|
||||
replyInfoMap = objectMapper.readValue(replyInfo, new TypeReference<Map<String, Object>>() {});
|
||||
};
|
||||
|
||||
Map createTime = (Map)attrMap.get("CreateTime");
|
||||
Map reTime = (Map)attrMap.get("ResolutionTime");
|
||||
// "Seconds" 값을 Instant으로 변환하고 "Nanos" 값을 더함
|
||||
Instant createInstant = Instant.ofEpochSecond(
|
||||
Long.valueOf(CommonUtils.objectToString(createTime.get("Seconds")))
|
||||
).plusNanos(
|
||||
Integer.valueOf(CommonUtils.objectToString(createTime.get("Nanos")))
|
||||
);
|
||||
Instant reInstant = Instant.ofEpochSecond(
|
||||
Long.valueOf(CommonUtils.objectToString(reTime.get("Seconds")))
|
||||
).plusNanos(
|
||||
Integer.valueOf(CommonUtils.objectToString(reTime.get("Nanos")))
|
||||
);
|
||||
UserReportResponse.Report report = UserReportResponse.Report.builder()
|
||||
.pk(item.get("PK").s())
|
||||
.sk(item.get("SK").s())
|
||||
.reporterGuid(attrMap.get("ReporterGuid").toString())
|
||||
.reporterNickName(attrMap.get("ReporterNickName").toString())
|
||||
.targetGuid(attrMap.get("TargetGuid").toString())
|
||||
.targetNickName(attrMap.get("TargetNickName").toString())
|
||||
.reportType(Arrays.stream(REPORTTYPE.values())
|
||||
.filter(r->r.getName().equals(attrMap.get("Reason").toString()))
|
||||
.findFirst().orElse(null))
|
||||
.title(attrMap.get("Title").toString())
|
||||
.detail(attrMap.get("Detail").toString())
|
||||
.state(attrMap.get("State").toString().equals("1")? STATUS.UNRESOLVED:STATUS.RESOLVED)
|
||||
.createTime(createInstant.atZone(ZoneOffset.UTC).toLocalDateTime())
|
||||
.resolutionTime(Integer.valueOf(reTime.get("Seconds").toString()) == 0?null:
|
||||
reInstant.atZone(ZoneOffset.UTC).toLocalDateTime())
|
||||
.managerEmail(item.get("ReplyInfo")!= null?
|
||||
CommonUtils.objectToString(replyInfoMap.get("ManagerEmail")):""
|
||||
)
|
||||
.build();
|
||||
|
||||
list.add(report);
|
||||
}
|
||||
}
|
||||
}catch (JsonProcessingException jpe){
|
||||
log.error("getUserReportList JsonProcessingException: {}", jpe.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch (Exception e){
|
||||
log.error("getUserReportList: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}*/
|
||||
return list;
|
||||
}
|
||||
|
||||
//신고내역 상세보기
|
||||
public UserReportResponse.ResultData getUserReportDetail(Map<String,String> requestParam){
|
||||
UserReportResponse.ResultData resultData = UserReportResponse.ResultData.builder().build();
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":pkValue", AttributeValue.builder().s(requestParam.get("pk")).build());
|
||||
expressionAttributeValues.put(":skValue", AttributeValue.builder().s(requestParam.get("sk")).build());
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue and SK = :skValue")
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.build();
|
||||
try{
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue ReportInfo = item.get("ReportInfo");
|
||||
if (ReportInfo != null) {
|
||||
// "Attr" 속성의 값을 읽어옵니다.
|
||||
String attrJson = ReportInfo.s();
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
Map createTime = (Map)attrMap.get("CreateTime");
|
||||
Map reTime = (Map)attrMap.get("ResolutionTime");
|
||||
// "Seconds" 값을 Instant으로 변환하고 "Nanos" 값을 더함
|
||||
Instant createInstant = Instant.ofEpochSecond(
|
||||
Long.valueOf(CommonUtils.objectToString(createTime.get("Seconds")))
|
||||
).plusNanos(
|
||||
Integer.valueOf(CommonUtils.objectToString(createTime.get("Nanos")))
|
||||
);
|
||||
Instant reInstant = Instant.ofEpochSecond(
|
||||
Long.valueOf(CommonUtils.objectToString(reTime.get("Seconds")))
|
||||
).plusNanos(
|
||||
Integer.valueOf(CommonUtils.objectToString(reTime.get("Nanos")))
|
||||
);
|
||||
resultData.setReport(UserReportResponse.Report.builder()
|
||||
.reporterGuid(attrMap.get("ReporterGuid").toString())
|
||||
.reporterNickName(attrMap.get("ReporterNickName").toString())
|
||||
.targetGuid(attrMap.get("TargetGuid").toString())
|
||||
.targetNickName(attrMap.get("TargetNickName").toString())
|
||||
.reportType(Arrays.stream(REPORTTYPE.values())
|
||||
.filter(r -> r.getName().equals(attrMap.get("Reason").toString()))
|
||||
.findFirst().orElse(null))
|
||||
.title(attrMap.get("Title").toString())
|
||||
.detail(attrMap.get("Detail").toString())
|
||||
.state(attrMap.get("State").toString().equals("1") ? STATUS.UNRESOLVED : STATUS.RESOLVED)
|
||||
.createTime(createInstant.atZone(ZoneOffset.UTC).toLocalDateTime())
|
||||
.resolutionTime(Integer.valueOf(reTime.get("Seconds").toString()) == 0 ? null :
|
||||
reInstant.atZone(ZoneOffset.UTC).toLocalDateTime())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
return resultData;
|
||||
}catch (JsonProcessingException jpe){
|
||||
log.error("getUserReportDetail JsonProcessingException: {}", jpe.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch (Exception e){
|
||||
log.error("getUserReportDetail: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
public UserReportResponse.ResultData getUserReplyDetail(Map<String,String> requestParam){
|
||||
UserReportResponse.ResultData resultData = UserReportResponse.ResultData.builder().build();
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":pkValue", AttributeValue.builder().s(requestParam.get("pk")).build());
|
||||
expressionAttributeValues.put(":skValue", AttributeValue.builder().s(requestParam.get("sk")).build());
|
||||
QueryRequest queryRequest = QueryRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.keyConditionExpression("PK = :pkValue and SK = :skValue")
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.build();
|
||||
try{
|
||||
QueryResponse response = dynamoDbClient.query(queryRequest);
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue ReplyInfo = item.get("ReplyInfo");
|
||||
if(ReplyInfo != null){
|
||||
//담당자 검색
|
||||
String replyInfo = item.get("ReplyInfo").s();
|
||||
// JSON 문자열을 파싱하여 Map 또는 다른 객체로 변환합니다.
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> replyInfoMap = objectMapper.readValue(replyInfo, new TypeReference<Map<String, Object>>() {});
|
||||
resultData.setReply(
|
||||
UserReportResponse.Reply.builder()
|
||||
.title(replyInfoMap.get("Title").toString())
|
||||
.detail(replyInfoMap.get("Detail").toString())
|
||||
.managerEmail(replyInfoMap.get("ManagerEmail").toString())
|
||||
.managerNickName(replyInfoMap.get("ManagerNickName").toString())
|
||||
.reporterNickName(replyInfoMap.get("ReporterNickName").toString())
|
||||
.build()
|
||||
);
|
||||
};
|
||||
}
|
||||
return resultData;
|
||||
}catch (JsonProcessingException jpe){
|
||||
log.error("getUserReplyDetail JsonProcessingException: {}", jpe.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch (Exception e){
|
||||
log.error("getUserReplyDetail: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
//신고 내역 답장
|
||||
public void reportReply(UserReportRequest userReportRequest){
|
||||
|
||||
String replyInfo = String.format("{\"Title\":\"%s\",\"Detail\":\"%s\"" +
|
||||
",\"ManagerEmail\":\"%s\",\"ManagerNickName\":\"%s\"" +
|
||||
",\"ReporterNickName\":\"%s\"}"
|
||||
, userReportRequest.getTitle(), userReportRequest.getDetail()
|
||||
, CommonUtils.getAdmin().getEmail(), adminMapper.findByEmail(CommonUtils.getAdmin().getEmail()).get().getName()
|
||||
, userReportRequest.getReporterNickName());
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newValue", AttributeValue.builder().s(replyInfo).build());
|
||||
|
||||
// 업데이트 표현식을 정의
|
||||
String updateExpression = "SET ReplyInfo = :newValue";
|
||||
|
||||
UpdateItemRequest item = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s(userReportRequest.getPk()).build(),
|
||||
"SK", AttributeValue.builder().s(userReportRequest.getSk()).build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
dynamoDbClient.updateItem(item);
|
||||
|
||||
}
|
||||
|
||||
public void changeReportStatus(UserReportRequest userReportRequest){
|
||||
try {
|
||||
|
||||
// 기존 CharInfo 값 가져오기
|
||||
Map<String, AttributeValue> item = getItem(userReportRequest.getPk(), userReportRequest.getSk());
|
||||
String reportInfoJson = item.get("ReportInfo").s();
|
||||
|
||||
// ReportInfo JSON 문자열을 파싱
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode reportInfoNode = objectMapper.readTree(reportInfoJson);
|
||||
|
||||
Instant now = Instant.now();
|
||||
long seconds = now.getEpochSecond();
|
||||
int nanos = now.getNano();
|
||||
|
||||
// 원하는 속성 변경
|
||||
((ObjectNode) reportInfoNode).put("State", 2);
|
||||
((ObjectNode) reportInfoNode.get("ResolutionTime")).put("Seconds", seconds);
|
||||
((ObjectNode) reportInfoNode.get("ResolutionTime")).put("Nanos", nanos);
|
||||
|
||||
// 변경된 ReportInfo JSON 문자열
|
||||
String updatedInfoJson = reportInfoNode.toString();
|
||||
|
||||
// 업데이트할 내용을 정의
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newValue", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
|
||||
// 업데이트 표현식을 정의
|
||||
String updateExpression = "SET ReportInfo = :newValue";
|
||||
// 업데이트 요청 생성
|
||||
UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s(userReportRequest.getPk()).build(),
|
||||
"SK", AttributeValue.builder().s(userReportRequest.getSk()).build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
|
||||
dynamoDbClient.updateItem(updateRequest);
|
||||
}catch (JsonProcessingException jpe){
|
||||
log.error("changeReportStatus JsonProcessingException: {}", jpe.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}catch (Exception e){
|
||||
log.error("changeReportStatus: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
public void dummy(Map<String, String> map){
|
||||
Instant now = Instant.now(); // 현재 시간을 얻습니다.
|
||||
LocalDateTime createTime = LocalDateTime.parse(map.get("CreateTime"), DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'"));
|
||||
Instant instant = createTime.atZone(ZoneId.of("UTC")).toInstant(); // 현재 시간을 초로 얻습니다.
|
||||
String replyInfo = String.format("{\"ReporterGuid\":\"%s\",\"ReporterNickName\":\"%s\"" +
|
||||
",\"TargetGuid\":\"%s\",\"TargetNickName\":\"%s\"" +
|
||||
",\"Reason\":\"%s\",\"Title\":\"%s\"" +
|
||||
",\"Detail\":\"%s\",\"State\":\"%s\"" +
|
||||
",\"CreateTime\":{\"Seconds\":%s,\"Nanos\":%s}" +
|
||||
",\"ResolutionTime\":{\"Seconds\":%s,\"Nanos\":%s}}"
|
||||
, map.get("ReporterGuid"), map.get("ReporterNickName")
|
||||
, map.get("TargetGuid"), map.get("TargetNickName")
|
||||
, map.get("Reason"), map.get("Title")
|
||||
, map.get("Detail"), map.get("State")
|
||||
, instant.getEpochSecond(), instant.getNano()
|
||||
, 0, 0);
|
||||
|
||||
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
expressionAttributeValues.put(":newValue", AttributeValue.builder().s(replyInfo).build());
|
||||
|
||||
// 업데이트 표현식을 정의
|
||||
String updateExpression = "SET ReportInfo = :newValue";
|
||||
|
||||
UpdateItemRequest item = UpdateItemRequest.builder()
|
||||
.tableName(metaTable)
|
||||
.key(Map.of(
|
||||
"PK", AttributeValue.builder().s(map.get("pk")).build(),
|
||||
"SK", AttributeValue.builder().s(map.get("sk")).build()))
|
||||
.updateExpression(updateExpression)
|
||||
.expressionAttributeValues(expressionAttributeValues)
|
||||
.returnValues(ReturnValue.ALL_NEW) // 업데이트 후의 값을 반환하려면 지정
|
||||
.build();
|
||||
|
||||
dynamoDbClient.updateItem(item);
|
||||
}
|
||||
|
||||
//아이템 - 의상 조회
|
||||
public Map<String, Object> getCloth(String guid){
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build());
|
||||
|
||||
UsersResponse.ClothInfo.ClothInfoBuilder clothInfo = UsersResponse.ClothInfo.builder();
|
||||
|
||||
Map<CLOTHSMALLTYPE, BiConsumer<UsersResponse.ClothInfo.ClothInfoBuilder, UsersResponse.ClothItem>> setterMap = new HashMap<>();
|
||||
setterMap.put(CLOTHSMALLTYPE.SHIRT, UsersResponse.ClothInfo.ClothInfoBuilder::clothShirt);
|
||||
setterMap.put(CLOTHSMALLTYPE.DRESS, UsersResponse.ClothInfo.ClothInfoBuilder::clothDress);
|
||||
setterMap.put(CLOTHSMALLTYPE.OUTER, UsersResponse.ClothInfo.ClothInfoBuilder::clothOuter);
|
||||
setterMap.put(CLOTHSMALLTYPE.PANTS, UsersResponse.ClothInfo.ClothInfoBuilder::clothPants);
|
||||
setterMap.put(CLOTHSMALLTYPE.GLOVES, UsersResponse.ClothInfo.ClothInfoBuilder::clothGloves);
|
||||
setterMap.put(CLOTHSMALLTYPE.RING, UsersResponse.ClothInfo.ClothInfoBuilder::clothRing);
|
||||
setterMap.put(CLOTHSMALLTYPE.BRACELET, UsersResponse.ClothInfo.ClothInfoBuilder::clothBracelet);
|
||||
setterMap.put(CLOTHSMALLTYPE.BAG, UsersResponse.ClothInfo.ClothInfoBuilder::clothBag);
|
||||
setterMap.put(CLOTHSMALLTYPE.BACKPACK, UsersResponse.ClothInfo.ClothInfoBuilder::clothBackpack);
|
||||
setterMap.put(CLOTHSMALLTYPE.CAP, UsersResponse.ClothInfo.ClothInfoBuilder::clothCap);
|
||||
setterMap.put(CLOTHSMALLTYPE.MASK, UsersResponse.ClothInfo.ClothInfoBuilder::clothMask);
|
||||
setterMap.put(CLOTHSMALLTYPE.GLASSES, UsersResponse.ClothInfo.ClothInfoBuilder::clothGlasses);
|
||||
setterMap.put(CLOTHSMALLTYPE.EARRING, UsersResponse.ClothInfo.ClothInfoBuilder::clothEarring);
|
||||
setterMap.put(CLOTHSMALLTYPE.NECKLACE, UsersResponse.ClothInfo.ClothInfoBuilder::clothNecklace);
|
||||
setterMap.put(CLOTHSMALLTYPE.SHOES, UsersResponse.ClothInfo.ClothInfoBuilder::clothShoes);
|
||||
setterMap.put(CLOTHSMALLTYPE.SOCKS, UsersResponse.ClothInfo.ClothInfoBuilder::clothSocks);
|
||||
setterMap.put(CLOTHSMALLTYPE.ANKLET, UsersResponse.ClothInfo.ClothInfoBuilder::clothAnklet);
|
||||
|
||||
try {
|
||||
excuteItems(executeQuery(key, values), "ItemAttrib")
|
||||
.filter(attrMap -> attrMap.containsKey("equiped_inven_type") && (int) attrMap.get("equiped_inven_type") == 1)
|
||||
.forEach(attrMap -> {
|
||||
int pos = (int) attrMap.get("equiped_pos");
|
||||
String smallType = metaDataHandler.getMetaClothSmallTypeData(pos);
|
||||
int item_id = CommonUtils.objectToInteger(attrMap.get("item_meta_id"));
|
||||
|
||||
UsersResponse.ClothItem clothItem = UsersResponse.ClothItem.builder()
|
||||
.cloth(CommonUtils.objectToString(attrMap.get("item_meta_id")))
|
||||
.clothName(metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id)))
|
||||
.slotType(metaDataHandler.getMetaClothSlotTypeData(pos))
|
||||
.smallType(smallType)
|
||||
.build();
|
||||
|
||||
// ClothItem을 CLOTHSMALLTYPE 위치에 넣어 준다
|
||||
setterMap.getOrDefault(CLOTHSMALLTYPE.valueOf(smallType), (builder, item) -> {})
|
||||
.accept(clothInfo, clothItem);
|
||||
});
|
||||
|
||||
resultMap.put("clothInfo", clothInfo.build());
|
||||
log.info("getCloth Response clothInfo: {}", clothInfo);
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("getCloth: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
//아이템 - 도구 조회
|
||||
public Map<String, Object> getTools(String guid){
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build());
|
||||
|
||||
UsersResponse.SlotInfo.SlotInfoBuilder slotInfo = UsersResponse.SlotInfo.builder();
|
||||
|
||||
Map<Integer, BiConsumer<UsersResponse.SlotInfo.SlotInfoBuilder, UsersResponse.ToolItem>> setterMap = Map.of(
|
||||
1, UsersResponse.SlotInfo.SlotInfoBuilder::Slot1,
|
||||
2, UsersResponse.SlotInfo.SlotInfoBuilder::Slot2,
|
||||
3, UsersResponse.SlotInfo.SlotInfoBuilder::Slot3,
|
||||
4, UsersResponse.SlotInfo.SlotInfoBuilder::Slot4
|
||||
);
|
||||
|
||||
try {
|
||||
excuteItems(executeQuery(key, values), "ItemAttrib")
|
||||
.filter(attrMap -> attrMap.containsKey("equiped_inven_type") && (int) attrMap.get("equiped_inven_type") == 2)
|
||||
.forEach(attrMap -> {
|
||||
int pos = (int) attrMap.get("equiped_pos");
|
||||
// String smallType = metaDataHandler.getMetaClothSmallTypeData(pos);
|
||||
int item_id = CommonUtils.objectToInteger(attrMap.get("item_meta_id"));
|
||||
String item_nm = metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id));
|
||||
UsersResponse.ToolItem toolItem = UsersResponse.ToolItem.builder()
|
||||
.toolId(CommonUtils.objectToString(attrMap.get("item_meta_id")))
|
||||
// .toolName(metaDataHandler.getMetaToolData(CommonUtils.objectToInteger(attrMap.get("item_meta_id"))).getToolName())
|
||||
.toolName(item_nm)
|
||||
.build();
|
||||
|
||||
// ClothItem을 CLOTHSMALLTYPE 위치에 넣어 준다
|
||||
setterMap.getOrDefault(pos, (builder, item) -> {})
|
||||
.accept(slotInfo, toolItem);
|
||||
});
|
||||
|
||||
resultMap.put("toolSlotInfo", slotInfo.build());
|
||||
log.info("getTools Response toolSlotInfo: {}", slotInfo);
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("getTools: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
// 유저 조회 - 우편 삭제
|
||||
// public String deleteMail(String type, String guid, String mail_guid) {
|
||||
// Map<String, AttributeValue> itemAttributes = new HashMap<>();
|
||||
// if(type.equals("SEND")){
|
||||
// itemAttributes.put("PK", AttributeValue.builder().s("sent_mail#" + guid).build());
|
||||
// }else{
|
||||
// itemAttributes.put("PK", AttributeValue.builder().s("recv_mail#" + guid).build());
|
||||
// }
|
||||
// itemAttributes.put("SK", AttributeValue.builder().s(mail_guid).build());
|
||||
// try {
|
||||
// Map<String, AttributeValue> item = null;
|
||||
// if(type.equals("SEND")){
|
||||
// item = getItem("sent_mail#" + guid, mail_guid);
|
||||
// log.info("deleteMail PK: {}, SK: {}", "sent_mail#" + guid, mail_guid);
|
||||
// }else{
|
||||
// item = getItem("recv_mail#" + guid, mail_guid);
|
||||
// log.info("deleteMail PK: {}, SK: {}", "recv_mail#" + guid, mail_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("deleteUsersMail Conditional check failed: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }catch(Exception e){
|
||||
// log.error("deleteUsersMail: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// 유저 조회 - 우편 아이템 삭제
|
||||
// public JSONObject updateMailItem(String type, String guid, String mail_guid, Long itemId, double count, double newCount) {
|
||||
// try {
|
||||
// Map<String, AttributeValue> item = null;
|
||||
// Map<String, AttributeValue> key = new HashMap<>();
|
||||
// if(type.equals("SEND")){
|
||||
// item = getItem("sent_mail#" + guid, mail_guid);
|
||||
// key = Map.of("PK", AttributeValue.builder().s("sent_mail#" + guid).build(),"SK", AttributeValue.builder().s(mail_guid).build());
|
||||
// }else{
|
||||
// item = getItem("recv_mail#" + guid, mail_guid);
|
||||
// key = Map.of("PK", AttributeValue.builder().s("recv_mail#" + guid).build(),"SK", AttributeValue.builder().s(mail_guid).build());
|
||||
// }
|
||||
//
|
||||
// String InfoJson = item.get("MailAttrib").s();
|
||||
//
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// JsonNode infoNode = objectMapper.readTree(InfoJson);
|
||||
// log.info("updateMailItem Before updatedInfoJson: {}", infoNode.toString());
|
||||
//
|
||||
// ArrayNode itemListNode = (ArrayNode) infoNode.get("item_list");
|
||||
//
|
||||
// // Java 17 스타일의 IntStream을 사용하여 itemId를 찾고 처리
|
||||
// OptionalInt indexOpt = IntStream.range(0, itemListNode.size())
|
||||
// .filter(i -> itemListNode.get(i).get("ItemId").asInt() == itemId)
|
||||
// .findFirst();
|
||||
//
|
||||
// if (indexOpt.isEmpty()) {
|
||||
// log.error("updateMailItem mail item not found");
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }
|
||||
//
|
||||
// int index = indexOpt.getAsInt();
|
||||
// JsonNode itemNode = itemListNode.get(index);
|
||||
//
|
||||
// if (count > newCount) {
|
||||
// // count 수정
|
||||
// ((ObjectNode) itemNode).put("Count", count - newCount);
|
||||
// } else {
|
||||
// // item 삭제
|
||||
// itemListNode.remove(index);
|
||||
// }
|
||||
//
|
||||
// String updatedInfoJson = infoNode.toString();
|
||||
// log.info("updateMailItem Tobe updatedInfoJson: {}", updatedInfoJson);
|
||||
//
|
||||
// Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
|
||||
// expressionAttributeValues.put(":newAttrib", AttributeValue.builder().s(updatedInfoJson).build());
|
||||
//
|
||||
// String updateExpression = "SET MailAttrib = :newAttrib";
|
||||
//
|
||||
// UpdateItemRequest updateRequest = UpdateItemRequest.builder()
|
||||
// .tableName(metaTable)
|
||||
// .key(key)
|
||||
// .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 (ConditionalCheckFailedException e) {
|
||||
// log.error("deleteUsersMail Conditional check failed: {}", e.getMessage());
|
||||
// throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
// }catch(Exception e){
|
||||
// log.error("deleteUsersMail: {}", 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<>();
|
||||
List<UsersResponse.Tattoo> resTatto = new ArrayList<>();
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("item#"+guid).build());
|
||||
|
||||
try {
|
||||
excuteItems(executeQuery(key, values), "ItemAttrib")
|
||||
.filter(attrMap -> attrMap.containsKey("equiped_inven_type") && (int) attrMap.get("equiped_inven_type") == 3)
|
||||
.forEach(attrMap -> {
|
||||
int pos = CommonUtils.objectToInteger(attrMap.get("equiped_pos"));
|
||||
if(pos == 0) return;
|
||||
|
||||
UsersResponse.Tattoo tattoo = new UsersResponse.Tattoo();
|
||||
Long item_id = CommonUtils.objectToLong(attrMap.get("item_meta_id"));
|
||||
tattoo.setItemId(item_id);
|
||||
tattoo.setItemGuid(CommonUtils.objectToString(attrMap.get("Item_guid")));
|
||||
tattoo.setLevel(Integer.valueOf(CommonUtils.objectToString(attrMap.get("level"))));
|
||||
tattoo.setItemName(metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id.intValue())));
|
||||
tattoo.setSlot(pos);
|
||||
resTatto.add(tattoo);
|
||||
});
|
||||
log.info("getTattoo Response TattoInfo: {}", resTatto);
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("getTattoo: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
|
||||
return resTatto;
|
||||
}
|
||||
|
||||
// 친구 목록
|
||||
public List<UsersResponse.Friend> getFriendList(String guid){
|
||||
List<UsersResponse.Friend> resList = new ArrayList<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("friend#"+guid).build());
|
||||
|
||||
AtomicInteger idx = new AtomicInteger(1);
|
||||
|
||||
try {
|
||||
excuteItems(executeQuery(key, values), "FriendAttrib")
|
||||
.forEach(attrMap -> {
|
||||
UsersResponse.Friend friend = new UsersResponse.Friend();
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String friend_guid = CommonUtils.objectToString(attrMap.get("friend_guid"));
|
||||
friend.setFriendGuid(friend_guid);
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(friend_guid));
|
||||
friend.setReceiveDt(CommonUtils.objectToString(attrMap.get("create_time")));
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(guid));
|
||||
resList.add(friend);
|
||||
});
|
||||
log.info("getFriendList FriendInfo: {}", resList);
|
||||
}catch (Exception e){
|
||||
log.error("getFriendList: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
// 유저 차단 목록
|
||||
public List<UsersResponse.Friend> getUserBlockList(String guid){
|
||||
List<UsersResponse.Friend> resList = new ArrayList<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("block#"+guid).build());
|
||||
|
||||
AtomicInteger idx = new AtomicInteger(1);
|
||||
|
||||
try {
|
||||
QueryResponse response = executeQuery(key, values);
|
||||
|
||||
// 응답에서 원하는 속성을 가져옵니다.
|
||||
for (Map<String, AttributeValue> item : response.items()) {
|
||||
AttributeValue attrValue = item.get("BlockUserAttrib");
|
||||
if (attrValue != null) {
|
||||
String attrJson = attrValue.s();
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> attrMap = objectMapper.readValue(attrJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
UsersResponse.Friend friend = new UsersResponse.Friend();
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String block_guid = CommonUtils.objectToString(attrMap.get("guid"));
|
||||
friend.setFriendGuid(block_guid);
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(block_guid));
|
||||
friend.setReceiveDt(CommonUtils.objectToString(item.get("CreatedDateTime").s()));
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(guid));
|
||||
|
||||
resList.add(friend);
|
||||
}
|
||||
}
|
||||
log.info("getUserBlockList FriendInfo: {}", resList);
|
||||
}catch (Exception e){
|
||||
log.error("getUserBlockList: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
//마이홈
|
||||
public UsersResponse.Myhome getMyhome(String guid){
|
||||
UsersResponse.Myhome myhome = new UsersResponse.Myhome();
|
||||
List<UsersResponse.Item> itemList = new ArrayList<>();
|
||||
|
||||
String key = "PK = :pkValue";
|
||||
Map<String, AttributeValue> values = Map.of(":pkValue", AttributeValue.builder().s("my_home#" + guid).build());
|
||||
try {
|
||||
excuteItems(executeQuery(key, values), "MyHomeAttrib")
|
||||
.forEach(attrMap -> {
|
||||
String myhome_guid = CommonUtils.objectToString(attrMap.get("myhome_guid"));
|
||||
myhome.setMyhomeGuid(myhome_guid);
|
||||
myhome.setMyhomeName(CommonUtils.objectToString(attrMap.get("myhome_name")));
|
||||
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 -> {
|
||||
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.objectToInteger(attrMap2.get("item_stack_count")))
|
||||
.itemGuid(CommonUtils.objectToString(attrMap2.get("item_guid")))
|
||||
.build();
|
||||
itemList.add(item);
|
||||
});
|
||||
myhome.setPropList(itemList);
|
||||
});
|
||||
log.info("getMyhome myhomedInfo: {}", myhome);
|
||||
}catch (Exception e){
|
||||
log.error("getMyhome: {}", e.getMessage());
|
||||
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
|
||||
}
|
||||
return myhome;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class EventService {
|
||||
private final DynamoDBService dynamoDBService;
|
||||
private final DynamodbService dynamodbService;
|
||||
private final DynamodbMailService dynamodbMailService;
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import java.util.*;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MailService {
|
||||
private final DynamoDBService dynamoDBService;
|
||||
private final WalletUserMapper walletUserMapper;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
|
||||
|
||||
@@ -30,14 +30,13 @@ import java.util.stream.Collectors;
|
||||
public class UserReportService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserReportService.class);
|
||||
|
||||
private final DynamoDBService dynamoDBService;
|
||||
public UserReportResponse totalCnt(Map<String,String> requestParam){
|
||||
|
||||
int resolved = 0;
|
||||
int unResolved = 0;
|
||||
List<UserReportResponse.Report> userReportList = new ArrayList<>();
|
||||
|
||||
userReportList = dynamoDBService.getUserReportList(requestParam);
|
||||
// userReportList = dynamoDBService.getUserReportList(requestParam);
|
||||
Map<Boolean, Long> result = userReportList.stream()
|
||||
.collect(Collectors.partitioningBy(
|
||||
val -> val.getState() == STATUS.RESOLVED,
|
||||
@@ -62,7 +61,7 @@ public class UserReportService {
|
||||
}
|
||||
public UserReportResponse list(Map<String,String> requestParam){
|
||||
List<UserReportResponse.Report> userReportList = new ArrayList<>();
|
||||
userReportList = dynamoDBService.getUserReportList(requestParam);
|
||||
// userReportList = dynamoDBService.getUserReportList(requestParam);
|
||||
|
||||
String reportTypeFilter = CommonUtils.objectToString(requestParam.get("report_type"));
|
||||
String statusFilter = CommonUtils.objectToString(requestParam.get("status"));
|
||||
@@ -142,10 +141,10 @@ public class UserReportService {
|
||||
}
|
||||
public UserReportResponse reportDetail(Map<String,String> requestParam){
|
||||
|
||||
UserReportResponse.ResultData userReportDetail = dynamoDBService.getUserReportDetail(requestParam);
|
||||
// UserReportResponse.ResultData userReportDetail = dynamoDBService.getUserReportDetail(requestParam);
|
||||
|
||||
return UserReportResponse.builder()
|
||||
.resultData(userReportDetail)
|
||||
.resultData(null)
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
@@ -153,10 +152,10 @@ public class UserReportService {
|
||||
}
|
||||
public UserReportResponse replyDetail(Map<String,String> requestParam){
|
||||
|
||||
UserReportResponse.ResultData userReportDetail = dynamoDBService.getUserReplyDetail(requestParam);
|
||||
// UserReportResponse.ResultData userReportDetail = dynamoDBService.getUserReplyDetail(requestParam);
|
||||
|
||||
return UserReportResponse.builder()
|
||||
.resultData(userReportDetail)
|
||||
.resultData(null)
|
||||
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||
.result(CommonCode.SUCCESS.getResult())
|
||||
.build();
|
||||
@@ -167,10 +166,10 @@ public class UserReportService {
|
||||
public UserReportResponse reportReply(UserReportRequest userReportRequest){
|
||||
|
||||
userReportRequest.setManagerEmail(CommonUtils.getAdmin().getEmail());
|
||||
dynamoDBService.reportReply(userReportRequest);
|
||||
// dynamoDBService.reportReply(userReportRequest);
|
||||
|
||||
//신고 내역 상태 및 해결일자 변경
|
||||
dynamoDBService.changeReportStatus(userReportRequest);
|
||||
// dynamoDBService.changeReportStatus(userReportRequest);
|
||||
|
||||
|
||||
return UserReportResponse.builder()
|
||||
@@ -182,7 +181,4 @@ public class UserReportService {
|
||||
.build();
|
||||
|
||||
}
|
||||
public void dummy(Map<String, String> map){
|
||||
dynamoDBService.dummy(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,17 +39,16 @@ import lombok.RequiredArgsConstructor;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class UsersService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(UsersService.class);
|
||||
|
||||
private final DynamoDBService dynamoDBService;
|
||||
private final DynamodbService dynamodbService;
|
||||
private final HistoryService historyService;
|
||||
private final UserGameSessionService userGameSessionService;
|
||||
private final RedisUserInfoService redisUserInfoService;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
private final DynamodbItemService dynamodbItemService;
|
||||
private final DynamodbMailService dynamodbMailService;
|
||||
private final DynamodbQuestService dynamodbQuestService;
|
||||
private final DynamodbMyHomeService dynamodbMyHomeService;
|
||||
private final DynamodbFriendService dynamodbFriendService;
|
||||
|
||||
@Autowired
|
||||
private MetaDataHandler metaDataHandler;
|
||||
@@ -118,7 +117,6 @@ 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> resultMap = new HashMap<>();
|
||||
if(searchType.equals(SEARCHTYPE.NAME.name())){
|
||||
String name_guid = dynamodbUserService.getNameByGuid(searchKey.toLowerCase());
|
||||
@@ -200,7 +198,6 @@ public class UsersService {
|
||||
public UsersResponse getAvatarInfo(String guid){
|
||||
|
||||
//avatarInfo
|
||||
// Map<String, Object> charInfo = dynamoDBService.getAvatarInfo(guid);
|
||||
Map<String, Object> charInfo = dynamodbUserService.getAvatarInfo(guid);
|
||||
|
||||
return UsersResponse.builder()
|
||||
@@ -217,7 +214,7 @@ public class UsersService {
|
||||
|
||||
//의상 정보
|
||||
public UsersResponse getClothInfo(String guid){
|
||||
Map<String, Object> charInfo = dynamoDBService.getCloth(guid);
|
||||
Map<String, Object> charInfo = dynamodbItemService.getClothItems(guid);
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(
|
||||
@@ -233,7 +230,7 @@ public class UsersService {
|
||||
|
||||
//도구 정보
|
||||
public UsersResponse getToolSlotInfo(String guid){
|
||||
Map<String, Object> toolSlot = dynamoDBService.getTools(guid);
|
||||
Map<String, Object> toolSlot = dynamodbItemService.getTools(guid);
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(
|
||||
@@ -250,7 +247,7 @@ public class UsersService {
|
||||
//인벤토리 정보
|
||||
public UsersResponse getInventoryInfo(String guid){
|
||||
UsersResponse.InventoryInfo inventoryInfo = dynamodbItemService.getInvenItems(guid);
|
||||
logger.info("getInventoryInfo Inventory Items: {}", inventoryInfo);
|
||||
log.info("getInventoryInfo Inventory Items: {}", inventoryInfo);
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(
|
||||
@@ -411,8 +408,7 @@ public class UsersService {
|
||||
|
||||
//마이홈 정보
|
||||
public UsersResponse getMyhome(String guid){
|
||||
|
||||
UsersResponse.Myhome myhome = dynamoDBService.getMyhome(guid);
|
||||
List<UsersResponse.Myhome> myhome = dynamodbMyHomeService.getMyHome(guid);
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(
|
||||
@@ -429,8 +425,8 @@ public class UsersService {
|
||||
//친구 목록
|
||||
public UsersResponse getFriendList(String guid){
|
||||
|
||||
List<UsersResponse.Friend> friendList = dynamoDBService.getFriendList(guid);
|
||||
List<UsersResponse.Friend> friendBlockList = dynamoDBService.getUserBlockList(guid);
|
||||
List<UsersResponse.Friend> friendList = dynamodbFriendService.getFriend(guid);
|
||||
List<UsersResponse.Friend> friendBlockList = dynamodbFriendService.getBlockUser(guid);
|
||||
List<UsersResponse.Friend> friendSendList = new ArrayList<>();
|
||||
List<UsersResponse.Friend> friendReceiveList = new ArrayList<>();
|
||||
|
||||
@@ -477,7 +473,7 @@ public class UsersService {
|
||||
|
||||
//타투 정보
|
||||
public UsersResponse getTattoo(String guid){
|
||||
List<UsersResponse.Tattoo> resTatto = dynamoDBService.getTattoo(guid);
|
||||
List<UsersResponse.Tattoo> resTatto = dynamodbItemService.getTattoo(guid);
|
||||
|
||||
return UsersResponse.builder()
|
||||
.resultData(
|
||||
@@ -493,8 +489,6 @@ public class UsersService {
|
||||
|
||||
//퀘스트 정보
|
||||
public UsersResponse getQuest(String guid){
|
||||
|
||||
// List<UsersResponse.QuestInfo> questList = dynamoDBService.getQuest(guid);
|
||||
List<UsersResponse.QuestInfo> questList = dynamodbQuestService.getQuestItems(guid);
|
||||
|
||||
return UsersResponse.builder()
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.caliverse.admin.dynamodb.domain.atrrib;
|
||||
|
||||
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;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@DynamoDbBean
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||
public class BlockUserAttrib extends DynamoDBAttribBase {
|
||||
@JsonProperty("guid")
|
||||
private String blockGuid;
|
||||
@JsonProperty("is_new")
|
||||
private Integer isNew;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.caliverse.admin.dynamodb.domain.atrrib;
|
||||
|
||||
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;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@DynamoDbBean
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||
public class FriendAttrib extends DynamoDBAttribBase {
|
||||
@JsonProperty("friend_guid")
|
||||
private String friendGuid;
|
||||
@JsonProperty("folder_name")
|
||||
private String folderName;
|
||||
@JsonProperty("is_new")
|
||||
private Integer isNew;
|
||||
@JsonProperty("create_time")
|
||||
private String createTime;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.caliverse.admin.dynamodb.domain.atrrib;
|
||||
|
||||
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;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@DynamoDbBean
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
|
||||
public class MyHomeAttrib extends DynamoDBAttribBase {
|
||||
@JsonProperty("myhome_guid")
|
||||
private String myhomeGuid;
|
||||
@JsonProperty("myhome_meta_id")
|
||||
private Integer myHomeMetaId;
|
||||
@JsonProperty("myhome_name")
|
||||
private String myhomeName;
|
||||
@JsonProperty("selected_flag")
|
||||
private Integer selectedFlag;
|
||||
@JsonProperty("myhome_ugc_info_s3_key")
|
||||
private String myhomeUgcInfoS3FileName;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.caliverse.admin.dynamodb.domain.doc;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
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 BlockUserDoc extends DynamoDBDocBase {
|
||||
private String blockUserAttrib;
|
||||
|
||||
public String getAttribFieldName() {
|
||||
return DynamoDBConstants.ATTRIB_BLOCK_USER;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute(DynamoDBConstants.ATTRIB_BLOCK_USER)
|
||||
@JsonProperty(DynamoDBConstants.ATTRIB_BLOCK_USER)
|
||||
public String getAttribValue() {
|
||||
return blockUserAttrib;
|
||||
}
|
||||
|
||||
public void setAttribValue(String value) {
|
||||
this.blockUserAttrib = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.caliverse.admin.dynamodb.domain.doc;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
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 FriendDoc extends DynamoDBDocBase {
|
||||
private String friendAttrib;
|
||||
|
||||
public String getAttribFieldName() {
|
||||
return DynamoDBConstants.ATTRIB_FRIEND;
|
||||
}
|
||||
|
||||
@DynamoDbAttribute(DynamoDBConstants.ATTRIB_FRIEND)
|
||||
@JsonProperty(DynamoDBConstants.ATTRIB_FRIEND)
|
||||
public String getAttribValue() {
|
||||
return friendAttrib;
|
||||
}
|
||||
|
||||
public void setAttribValue(String value) {
|
||||
this.friendAttrib = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 MyhomeDoc extends DynamoDBDocBase {
|
||||
private String myHomeAttrib;
|
||||
|
||||
public String getAttribFieldName() {
|
||||
return "MyHomeAttrib";
|
||||
}
|
||||
|
||||
@DynamoDbAttribute("MyHomeAttrib")
|
||||
@JsonProperty("MyHomeAttrib")
|
||||
public String getAttribValue() {
|
||||
return myHomeAttrib;
|
||||
}
|
||||
|
||||
public void setAttribValue(String value) {
|
||||
this.myHomeAttrib = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.BlockUserDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface BlockUserRepository extends DynamoDBRepository<BlockUserDoc> {
|
||||
PageResult<BlockUserDoc> getBlockUserListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.FriendDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface FriendRepository extends DynamoDBRepository<FriendDoc> {
|
||||
PageResult<FriendDoc> getFriendListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.BlockUserDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.BlockUserRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.mongodb.service.DynamodbHistoryLogService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BlockUserRepositoryImpl extends BaseDynamoDBRepository<BlockUserDoc> implements BlockUserRepository {
|
||||
public BlockUserRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
|
||||
super(operations, BlockUserDoc.class, dynamodbHistoryLogService, objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BlockUserDoc> getBlockUserListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
) {
|
||||
|
||||
String pk = DynamoDBConstants.PK_KEY_BLOCK_USER + userGuid;;
|
||||
|
||||
return findByPaging(
|
||||
pk,
|
||||
sortKeyPrefix,
|
||||
filterAttributeName,
|
||||
filterOperator,
|
||||
filterAttributeValue,
|
||||
exclusiveStartKey,
|
||||
sortIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.FriendDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.FriendRepository;
|
||||
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.mongodb.service.DynamodbHistoryLogService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FriendRepositoryImpl extends BaseDynamoDBRepository<FriendDoc> implements FriendRepository {
|
||||
public FriendRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
|
||||
super(operations, FriendDoc.class, dynamodbHistoryLogService, objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<FriendDoc> getFriendListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
) {
|
||||
|
||||
String pk = DynamoDBConstants.PK_KEY_FRIEND + userGuid;;
|
||||
|
||||
return findByPaging(
|
||||
pk,
|
||||
sortKeyPrefix,
|
||||
filterAttributeName,
|
||||
filterOperator,
|
||||
filterAttributeValue,
|
||||
exclusiveStartKey,
|
||||
sortIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.caliverse.admin.dynamodb.repository.Impl;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.domain.entity.HISTORYTYPEDETAIL;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MyhomeDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.ItemRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.MyHomeRepository;
|
||||
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.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import com.caliverse.admin.mongodb.service.DynamodbHistoryLogService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import software.amazon.awssdk.enhanced.dynamodb.Key;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MyHomeRepositoryImpl extends BaseDynamoDBRepository<MyhomeDoc> implements MyHomeRepository {
|
||||
public MyHomeRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
|
||||
super(operations, MyhomeDoc.class, dynamodbHistoryLogService, objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MyhomeDoc> getMyHomeListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
) {
|
||||
|
||||
String pk = DynamoDBConstants.PK_KEY_MY_HOME + userGuid;;
|
||||
|
||||
return findByPaging(
|
||||
pk,
|
||||
sortKeyPrefix,
|
||||
filterAttributeName,
|
||||
filterOperator,
|
||||
filterAttributeValue,
|
||||
exclusiveStartKey,
|
||||
sortIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.caliverse.admin.dynamodb.repository;
|
||||
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MyhomeDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface MyHomeRepository extends DynamoDBRepository<MyhomeDoc> {
|
||||
PageResult<MyhomeDoc> getMyHomeListWithPaging(
|
||||
String userGuid,
|
||||
String sortKeyPrefix,
|
||||
String filterAttributeName,
|
||||
EFilterOperator filterOperator,
|
||||
String filterAttributeValue,
|
||||
Map<String, AttributeValue> exclusiveStartKey,
|
||||
boolean sortIndex
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.response.UsersResponse;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.BlockUserAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.FriendAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MyHomeAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.BlockUserDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.FriendDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MyhomeDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.repository.BlockUserRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.FriendRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.ItemRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.MyHomeRepository;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DynamodbFriendService {
|
||||
private final FriendRepository friendRepository;
|
||||
private final BlockUserRepository blockUserRepository;
|
||||
private final DynamodbUserService dynamodbUserService;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
|
||||
public List<UsersResponse.Friend> getFriend(String guid){
|
||||
List<UsersResponse.Friend> resList = new ArrayList<>();
|
||||
AtomicInteger idx = new AtomicInteger(1);
|
||||
|
||||
Map<String, AttributeValue> pageKey = null;
|
||||
do {
|
||||
PageResult<FriendDoc> friendDocList = friendRepository.getFriendListWithPaging(guid, "", DynamoDBConstants.ATTRIB_FRIEND, null,"", pageKey, false);
|
||||
|
||||
friendDocList.getItems().forEach(doc -> {
|
||||
UsersResponse.Friend friend = new UsersResponse.Friend();
|
||||
|
||||
FriendAttrib attrib = CommonUtils.stringByObject(doc.getAttribValue(), FriendAttrib.class);
|
||||
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String friend_guid = attrib.getFriendGuid();
|
||||
friend.setFriendGuid(friend_guid);
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(friend_guid));
|
||||
friend.setReceiveDt(attrib.getCreateTime());
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(friend_guid));
|
||||
resList.add(friend);
|
||||
});
|
||||
|
||||
pageKey = friendDocList.getLastEvaluatedKey();
|
||||
} while (pageKey != null);
|
||||
|
||||
return resList;
|
||||
}
|
||||
|
||||
public List<UsersResponse.Friend> getBlockUser(String guid){
|
||||
List<UsersResponse.Friend> resList = new ArrayList<>();
|
||||
AtomicInteger idx = new AtomicInteger(1);
|
||||
|
||||
Map<String, AttributeValue> pageKey = null;
|
||||
do {
|
||||
PageResult<BlockUserDoc> friendDocList = blockUserRepository.getBlockUserListWithPaging(guid, "", DynamoDBConstants.ATTRIB_BLOCK_USER, null,"", pageKey, false);
|
||||
|
||||
friendDocList.getItems().forEach(doc -> {
|
||||
UsersResponse.Friend friend = new UsersResponse.Friend();
|
||||
|
||||
BlockUserAttrib attrib = CommonUtils.stringByObject(doc.getAttribValue(), BlockUserAttrib.class);
|
||||
|
||||
friend.setRowNum(idx.getAndIncrement());
|
||||
String block_guid = attrib.getBlockGuid();
|
||||
friend.setFriendGuid(block_guid);
|
||||
friend.setFriendName(dynamodbUserService.getGuidByName(block_guid));
|
||||
friend.setReceiveDt(doc.getCreatedDateTime());
|
||||
friend.setLanguage(dynamodbUserService.getUserLanguage(block_guid));
|
||||
|
||||
resList.add(friend);
|
||||
});
|
||||
|
||||
pageKey = friendDocList.getLastEvaluatedKey();
|
||||
} while (pageKey != null);
|
||||
|
||||
return resList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.CLOTHSMALLTYPE;
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.domain.entity.ITEMLARGETYPE;
|
||||
import com.caliverse.admin.domain.response.LandResponse;
|
||||
import com.caliverse.admin.domain.response.UsersResponse;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
@@ -17,11 +19,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -168,55 +168,130 @@ public class DynamodbItemService {
|
||||
.build();
|
||||
}
|
||||
|
||||
public UsersResponse.InventoryInfo getClothItems(String guid){
|
||||
List<UsersResponse.Item> clothList = new ArrayList<>();
|
||||
List<UsersResponse.Item> propList = new ArrayList<>();
|
||||
List<UsersResponse.Item> beautyList = new ArrayList<>();
|
||||
List<UsersResponse.Item> tattooList = new ArrayList<>();
|
||||
List<UsersResponse.Item> currencyList = new ArrayList<>();
|
||||
List<UsersResponse.Item> etcList = new ArrayList<>();
|
||||
public Map<String, Object> getClothItems(String guid){
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
UsersResponse.ClothInfo.ClothInfoBuilder clothInfo = UsersResponse.ClothInfo.builder();
|
||||
|
||||
Map<CLOTHSMALLTYPE, BiConsumer<UsersResponse.ClothInfo.ClothInfoBuilder, UsersResponse.ClothItem>> setterMap = new HashMap<>();
|
||||
setterMap.put(CLOTHSMALLTYPE.SHIRT, UsersResponse.ClothInfo.ClothInfoBuilder::clothShirt);
|
||||
setterMap.put(CLOTHSMALLTYPE.DRESS, UsersResponse.ClothInfo.ClothInfoBuilder::clothDress);
|
||||
setterMap.put(CLOTHSMALLTYPE.OUTER, UsersResponse.ClothInfo.ClothInfoBuilder::clothOuter);
|
||||
setterMap.put(CLOTHSMALLTYPE.PANTS, UsersResponse.ClothInfo.ClothInfoBuilder::clothPants);
|
||||
setterMap.put(CLOTHSMALLTYPE.GLOVES, UsersResponse.ClothInfo.ClothInfoBuilder::clothGloves);
|
||||
setterMap.put(CLOTHSMALLTYPE.RING, UsersResponse.ClothInfo.ClothInfoBuilder::clothRing);
|
||||
setterMap.put(CLOTHSMALLTYPE.BRACELET, UsersResponse.ClothInfo.ClothInfoBuilder::clothBracelet);
|
||||
setterMap.put(CLOTHSMALLTYPE.BAG, UsersResponse.ClothInfo.ClothInfoBuilder::clothBag);
|
||||
setterMap.put(CLOTHSMALLTYPE.BACKPACK, UsersResponse.ClothInfo.ClothInfoBuilder::clothBackpack);
|
||||
setterMap.put(CLOTHSMALLTYPE.CAP, UsersResponse.ClothInfo.ClothInfoBuilder::clothCap);
|
||||
setterMap.put(CLOTHSMALLTYPE.MASK, UsersResponse.ClothInfo.ClothInfoBuilder::clothMask);
|
||||
setterMap.put(CLOTHSMALLTYPE.GLASSES, UsersResponse.ClothInfo.ClothInfoBuilder::clothGlasses);
|
||||
setterMap.put(CLOTHSMALLTYPE.EARRING, UsersResponse.ClothInfo.ClothInfoBuilder::clothEarring);
|
||||
setterMap.put(CLOTHSMALLTYPE.NECKLACE, UsersResponse.ClothInfo.ClothInfoBuilder::clothNecklace);
|
||||
setterMap.put(CLOTHSMALLTYPE.SHOES, UsersResponse.ClothInfo.ClothInfoBuilder::clothShoes);
|
||||
setterMap.put(CLOTHSMALLTYPE.SOCKS, UsersResponse.ClothInfo.ClothInfoBuilder::clothSocks);
|
||||
setterMap.put(CLOTHSMALLTYPE.ANKLET, UsersResponse.ClothInfo.ClothInfoBuilder::clothAnklet);
|
||||
|
||||
Map<String, AttributeValue> pageKey = null;
|
||||
do {
|
||||
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(guid, "", DynamoDBConstants.ATTRIB_ITEM, EFilterOperator.CONTAINS,"\"equiped_inven_type\":0", pageKey, false);
|
||||
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(guid, "", DynamoDBConstants.ATTRIB_ITEM, EFilterOperator.CONTAINS,"\"equiped_inven_type\":1", pageKey, false);
|
||||
|
||||
itemList.getItems().forEach(item -> {
|
||||
ItemAttrib attrib = CommonUtils.stringByObject(item.getAttribValue(), ItemAttrib.class);
|
||||
int item_id = attrib.getItemMetaId();
|
||||
String item_name = metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id));
|
||||
String item_type = metaDataHandler.getMetaItemLargeTypeData(item_id);
|
||||
|
||||
UsersResponse.Item inventory = UsersResponse.Item.builder()
|
||||
.itemId(item_id)
|
||||
.itemName(item_name)
|
||||
.count(attrib.getItemStackCount())
|
||||
.itemGuid(attrib.getItemGuid())
|
||||
int pos = attrib.getEquipedPos();
|
||||
String smallType = metaDataHandler.getMetaClothSmallTypeData(pos);
|
||||
|
||||
UsersResponse.ClothItem clothItem = UsersResponse.ClothItem.builder()
|
||||
.cloth(item_id)
|
||||
.clothName(item_name)
|
||||
.slotType(metaDataHandler.getMetaClothSlotTypeData(pos))
|
||||
.smallType(smallType)
|
||||
.build();
|
||||
|
||||
if(item_type.isEmpty()) {
|
||||
etcList.add(inventory);
|
||||
}else{
|
||||
switch (ITEMLARGETYPE.valueOf(item_type)){
|
||||
case CLOTH -> clothList.add(inventory);
|
||||
case PROP -> propList.add(inventory);
|
||||
case BEAUTY -> beautyList.add(inventory);
|
||||
case TATTOO -> tattooList.add(inventory);
|
||||
case CURRENCY -> currencyList.add(inventory);
|
||||
default -> etcList.add(inventory);
|
||||
}}
|
||||
// ClothItem을 CLOTHSMALLTYPE 위치에 넣어 준다
|
||||
setterMap.getOrDefault(CLOTHSMALLTYPE.valueOf(smallType), (builder, smallItem) -> {})
|
||||
.accept(clothInfo, clothItem);
|
||||
});
|
||||
|
||||
resultMap.put("clothInfo", clothInfo.build());
|
||||
|
||||
pageKey = itemList.getLastEvaluatedKey();
|
||||
} while (pageKey != null);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public Map<String, Object> getTools(String guid){
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
UsersResponse.SlotInfo.SlotInfoBuilder slotInfo = UsersResponse.SlotInfo.builder();
|
||||
|
||||
Map<Integer, BiConsumer<UsersResponse.SlotInfo.SlotInfoBuilder, UsersResponse.ToolItem>> setterMap = Map.of(
|
||||
0, UsersResponse.SlotInfo.SlotInfoBuilder::Slot1,
|
||||
1, UsersResponse.SlotInfo.SlotInfoBuilder::Slot2,
|
||||
2, UsersResponse.SlotInfo.SlotInfoBuilder::Slot3,
|
||||
3, UsersResponse.SlotInfo.SlotInfoBuilder::Slot4
|
||||
);
|
||||
|
||||
Map<String, AttributeValue> pageKey = null;
|
||||
do {
|
||||
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(guid, "", DynamoDBConstants.ATTRIB_ITEM, EFilterOperator.CONTAINS,"\"equiped_inven_type\":2", pageKey, false);
|
||||
|
||||
itemList.getItems().forEach(item -> {
|
||||
ItemAttrib attrib = CommonUtils.stringByObject(item.getAttribValue(), ItemAttrib.class);
|
||||
int item_id = attrib.getItemMetaId();
|
||||
String item_name = metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id));
|
||||
|
||||
int pos = attrib.getEquipedPos();
|
||||
|
||||
UsersResponse.ToolItem toolItem = UsersResponse.ToolItem.builder()
|
||||
.toolId(item_id)
|
||||
.toolName(item_name)
|
||||
.build();
|
||||
|
||||
setterMap.getOrDefault(pos, (builder, smallItem) -> {})
|
||||
.accept(slotInfo, toolItem);
|
||||
});
|
||||
|
||||
resultMap.put("toolSlotInfo", slotInfo.build());
|
||||
|
||||
pageKey = itemList.getLastEvaluatedKey();
|
||||
} while (pageKey != null);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public List<UsersResponse.Tattoo> getTattoo(String guid){
|
||||
List<UsersResponse.Tattoo> resTatto = new ArrayList<>();
|
||||
|
||||
Map<String, AttributeValue> pageKey = null;
|
||||
do {
|
||||
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(guid, "", DynamoDBConstants.ATTRIB_ITEM, EFilterOperator.CONTAINS,"\"equiped_inven_type\":3", pageKey, false);
|
||||
|
||||
itemList.getItems().forEach(item -> {
|
||||
ItemAttrib attrib = CommonUtils.stringByObject(item.getAttribValue(), ItemAttrib.class);
|
||||
int item_id = attrib.getItemMetaId();
|
||||
String item_name = metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id));
|
||||
|
||||
int pos = attrib.getEquipedPos();
|
||||
|
||||
UsersResponse.Tattoo tattoo = new UsersResponse.Tattoo();
|
||||
|
||||
tattoo.setItemId(item_id);
|
||||
tattoo.setItemGuid(attrib.getItemGuid());
|
||||
tattoo.setLevel(attrib.getLevel());
|
||||
tattoo.setItemName(item_name);
|
||||
tattoo.setSlot(pos);
|
||||
resTatto.add(tattoo);
|
||||
});
|
||||
|
||||
pageKey = itemList.getLastEvaluatedKey();
|
||||
} while (pageKey != null);
|
||||
|
||||
return UsersResponse.InventoryInfo.builder()
|
||||
.cloth(clothList)
|
||||
.prop(propList)
|
||||
.beauty(beautyList)
|
||||
.tattoo(tattooList)
|
||||
.currency(currencyList)
|
||||
.etc(etcList)
|
||||
.build();
|
||||
return resTatto.stream().sorted(Comparator.comparing(UsersResponse.Tattoo::getSlot)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@DynamoDBTransaction
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.caliverse.admin.dynamodb.service;
|
||||
|
||||
import com.caliverse.admin.domain.datacomponent.MetaDataHandler;
|
||||
import com.caliverse.admin.domain.entity.CLOTHSMALLTYPE;
|
||||
import com.caliverse.admin.domain.entity.EFilterOperator;
|
||||
import com.caliverse.admin.domain.entity.ITEMLARGETYPE;
|
||||
import com.caliverse.admin.domain.response.UsersResponse;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.atrrib.MyHomeAttrib;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
|
||||
import com.caliverse.admin.dynamodb.domain.doc.MyhomeDoc;
|
||||
import com.caliverse.admin.dynamodb.dto.PageResult;
|
||||
import com.caliverse.admin.dynamodb.entity.KeyParam;
|
||||
import com.caliverse.admin.dynamodb.repository.ItemRepository;
|
||||
import com.caliverse.admin.dynamodb.repository.MyHomeRepository;
|
||||
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DynamodbMyHomeService {
|
||||
private final MyHomeRepository myHomeRepository;
|
||||
private final ItemRepository itemRepository;
|
||||
private final MetaDataHandler metaDataHandler;
|
||||
|
||||
public List<UsersResponse.Myhome> getMyHome(String guid){
|
||||
List<UsersResponse.Myhome> myhomeList = new ArrayList<>();
|
||||
|
||||
Map<String, AttributeValue> pageKey = null;
|
||||
do {
|
||||
PageResult<MyhomeDoc> myHomeDocList = myHomeRepository.getMyHomeListWithPaging(guid, "", DynamoDBConstants.ATTRIB_MY_HOME, null,"", pageKey, false);
|
||||
|
||||
myHomeDocList.getItems().forEach(doc -> {
|
||||
UsersResponse.Myhome myhome = new UsersResponse.Myhome();
|
||||
|
||||
MyHomeAttrib attrib = CommonUtils.stringByObject(doc.getAttribValue(), MyHomeAttrib.class);
|
||||
String myhome_guid = attrib.getMyhomeGuid();
|
||||
|
||||
myhome.setMyhomeGuid(myhome_guid);
|
||||
myhome.setMyhomeName(attrib.getMyhomeName());
|
||||
|
||||
List<UsersResponse.Item> myHomeItemList = new ArrayList<>();
|
||||
Map<String, AttributeValue> itemPageKey = null;
|
||||
do {
|
||||
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(myhome_guid, "", DynamoDBConstants.ATTRIB_ITEM, null,"", itemPageKey, false);
|
||||
|
||||
itemList.getItems().forEach(itemDoc -> {
|
||||
ItemAttrib itemAttrib = CommonUtils.stringByObject(itemDoc.getAttribValue(), ItemAttrib.class);
|
||||
int item_id = itemAttrib.getItemMetaId();
|
||||
String item_name = metaDataHandler.getTextStringData(metaDataHandler.getMetaItemNameData(item_id));
|
||||
|
||||
UsersResponse.Item item = UsersResponse.Item.builder()
|
||||
.itemId(item_id)
|
||||
.itemName(item_name)
|
||||
.count(itemAttrib.getItemStackCount())
|
||||
.itemGuid(itemAttrib.getItemGuid())
|
||||
.build();
|
||||
myHomeItemList.add(item);
|
||||
|
||||
});
|
||||
|
||||
itemPageKey = itemList.getLastEvaluatedKey();
|
||||
} while (itemPageKey != null);
|
||||
myhome.setPropList(myHomeItemList);
|
||||
myhomeList.add(myhome);
|
||||
});
|
||||
|
||||
pageKey = myHomeDocList.getLastEvaluatedKey();
|
||||
} while (pageKey != null);
|
||||
|
||||
return myhomeList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,9 @@ public class DynamoDBConstants {
|
||||
public static final String PK_KEY_BANNER = "banner#global";
|
||||
public static final String PK_KEY_QUEST = "quest#";
|
||||
public static final String PK_KEY_CHARACTER = "character_base#";
|
||||
public static final String PK_KEY_MY_HOME = "my_home#";
|
||||
public static final String PK_KEY_FRIEND = "friend#";
|
||||
public static final String PK_KEY_BLOCK_USER = "block#";
|
||||
|
||||
//SK
|
||||
public static final String SK_KEY_NAME = "SK";
|
||||
@@ -51,6 +54,9 @@ public class DynamoDBConstants {
|
||||
public static final String ATTRIB_BANNER = "BannerAttrib";
|
||||
public static final String ATTRIB_QUEST = "QuestAttrib";
|
||||
public static final String ATTRIB_CHARACTER = "CharacterBaseAttrib";
|
||||
public static final String ATTRIB_MY_HOME = "MyHomeAttrib";
|
||||
public static final String ATTRIB_FRIEND = "FriendAttrib";
|
||||
public static final String ATTRIB_BLOCK_USER = "BlockUserAttrib";
|
||||
|
||||
//DOC
|
||||
public static final String DOC_SYSTEMMAIL = "SystemMetaMailDoc";
|
||||
@@ -68,6 +74,9 @@ public class DynamoDBConstants {
|
||||
public static final String DOC_BANNER = "BannerDoc";
|
||||
public static final String DOC_QUEST = "QuestDoc";
|
||||
public static final String DOC_CHARACTER = "CharacterBaseDoc";
|
||||
public static final String DOC_MY_HOME = "MyhomeDoc";
|
||||
public static final String DOC_FRIEND = "FriendDoc";
|
||||
public static final String DOC_BLOCK_USER = "BlockUserDoc";
|
||||
|
||||
//SCHEMA
|
||||
public static final String SCHEMA_UPDATE_TIME = "UpdatedDateTime";
|
||||
|
||||
Reference in New Issue
Block a user