AmountDeltaType 추가

getInvenItems 예외 처리 추가
This commit is contained in:
2025-06-12 14:17:51 +09:00
parent 23850acf0f
commit ab7c6e53fe
2 changed files with 119 additions and 21 deletions

View File

@@ -0,0 +1,23 @@
package com.caliverse.admin.dynamodb.entity;
import com.caliverse.admin.domain.entity.common.ValueEnum;
public enum EAmountDeltaType implements ValueEnum {
None(0),
Acquire(1),
Consume(2),
Merge(3)
;
private final int value;
EAmountDeltaType(int value) {
this.value = value;
}
@Override
public int getValue() {
return value;
}
}

View File

@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@@ -51,33 +52,107 @@ public class DynamodbItemService {
List<UsersResponse.Item> etcList = new ArrayList<>();
Map<String, AttributeValue> pageKey = null;
final AtomicInteger processedItems = new AtomicInteger(0);
do {
PageResult<ItemDoc> itemList = itemRepository.getItemListWithPaging(guid, "", DynamoDBConstants.ATTRIB_ITEM, EFilterOperator.CONTAINS,"\"equiped_inven_type\":0", 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);
try {
processedItems.incrementAndGet();
UsersResponse.Item inventory = UsersResponse.Item.builder()
.itemId(item_id)
.itemName(item_name)
.count(attrib.getItemStackCount())
.itemGuid(attrib.getItemGuid())
.build();
// 2. ItemAttrib 파싱 예외 처리
ItemAttrib attrib = null;
try {
attrib = CommonUtils.stringByObject(item.getAttribValue(), ItemAttrib.class);
if (attrib == null) {
log.warn("Failed to parse ItemAttrib for pk: {}, sk: {}",
item.getPK(), item.getSK());
return;
}
} catch (Exception e) {
log.error("Exception while parsing ItemAttrib for pk: {}, sk: {}, error: {}",
item.getPK(), item.getSK(), e.getMessage(), e);
return;
}
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);
}}
// 3. 메타데이터 조회 예외 처리
int item_id = attrib.getItemMetaId();
String item_name = "";
String item_type = "";
try {
item_name = metaDataHandler.getTextStringData(
metaDataHandler.getMetaItemNameData(item_id));
if (item_name == null) {
item_name = "Unknown Item"; // 기본값 설정
log.warn("Item name is null for itemId: {}, guid: {}", item_id, guid);
}
} catch (Exception e) {
item_name = "Unknown Item";
log.error("Failed to get item name for itemId: {}, guid: {}, error: {}",
item_id, guid, e.getMessage(), e);
}
try {
item_type = metaDataHandler.getMetaItemLargeTypeData(item_id);
if (item_type == null) {
item_type = ""; // 기본값 설정
log.warn("Item type is null for itemId: {}, guid: {}", item_id, guid);
}
} catch (Exception e) {
item_type = "";
log.error("Failed to get item type for itemId: {}, guid: {}, error: {}",
item_id, guid, e.getMessage(), e);
}
// 4. UsersResponse.Item 생성 예외 처리
UsersResponse.Item inventory = null;
try {
inventory = UsersResponse.Item.builder()
.itemId(item_id)
.itemName(item_name)
.count(attrib.getItemStackCount())
.itemGuid(attrib.getItemGuid())
.build();
} catch (Exception e) {
log.error("Failed to build inventory item for itemId: {}, guid: {}, error: {}",
item_id, guid, e.getMessage(), e);
return;
}
// 5. 아이템 분류 예외 처리
try {
if (item_type.isEmpty()) {
etcList.add(inventory);
} else {
try {
ITEMLARGETYPE itemLargeType = ITEMLARGETYPE.valueOf(item_type);
switch (itemLargeType) {
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);
}
} catch (IllegalArgumentException e) {
// ENUM 값이 존재하지 않는 경우
log.warn("Unknown item type: {} for itemId: {}, guid: {}, adding to etc list",
item_type, item_id, guid);
etcList.add(inventory);
}
}
} catch (Exception e) {
log.error("Failed to categorize item for itemId: {}, guid: {}, error: {}, adding to etc list",
item_id, guid, e.getMessage(), e);
etcList.add(inventory);
}
} catch (Exception e) {
log.error("Unexpected error processing item for guid: {}, error: {}",
guid, e.getMessage(), e);
}
});
pageKey = itemList.getLastEvaluatedKey();