제작아이템 조회 API
This commit is contained in:
@@ -58,4 +58,16 @@ public class DictionaryController {
|
|||||||
@RequestParam Map<String, String> requestParams){
|
@RequestParam Map<String, String> requestParams){
|
||||||
metaDataService.itemExcelExport(response, requestParams);
|
metaDataService.itemExcelExport(response, requestParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/craft/list")
|
||||||
|
public ResponseEntity<DictionaryResponse> craftList(
|
||||||
|
@RequestParam Map<String, String> requestParams){
|
||||||
|
return ResponseEntity.ok().body( metaDataService.getCraftingDictList(requestParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/craft/excel-export")
|
||||||
|
public void craftExcelExport(HttpServletResponse response,
|
||||||
|
@RequestParam Map<String, String> requestParams){
|
||||||
|
metaDataService.craftExcelExport(response, requestParams);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,6 +319,9 @@ public class MetaDataFileLoader {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MetaCraftingData> getMetaCrafting() {
|
||||||
|
return craftings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,9 @@ public class MetaDataHandler {
|
|||||||
public List<MetaEventActionScoreData> getMetaEventActionScoreListData() {
|
public List<MetaEventActionScoreData> getMetaEventActionScoreListData() {
|
||||||
return metadataFileLoader.getMetaEventActionScore();
|
return metadataFileLoader.getMetaEventActionScore();
|
||||||
}
|
}
|
||||||
|
public List<MetaCraftingData> getMetaCraftingListData() {
|
||||||
|
return metadataFileLoader.getMetaCrafting();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.caliverse.admin.domain.entity;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class CraftingDict {
|
||||||
|
//제작아이디
|
||||||
|
private Integer id;
|
||||||
|
//제작 타입
|
||||||
|
@JsonProperty("type_small")
|
||||||
|
private String typeSmall;
|
||||||
|
//아이템명
|
||||||
|
@JsonProperty("item_name")
|
||||||
|
private String itemName;
|
||||||
|
//아이템아이디
|
||||||
|
@JsonProperty("item_id")
|
||||||
|
private Integer itemId;
|
||||||
|
//아이템개수
|
||||||
|
@JsonProperty("item_value")
|
||||||
|
private Integer itemValue;
|
||||||
|
//레시피 필요 여부
|
||||||
|
@JsonProperty("recipe_type")
|
||||||
|
private String recipeType;
|
||||||
|
//레시피 아이디
|
||||||
|
@JsonProperty("recipe_id")
|
||||||
|
private Integer recipeId;
|
||||||
|
//제작시 필요 재료
|
||||||
|
private String material;
|
||||||
|
//제작시 필요 능력치
|
||||||
|
private String attribute;
|
||||||
|
//제작 시간
|
||||||
|
@JsonProperty("crafting_time")
|
||||||
|
private Integer craftingTime;
|
||||||
|
//비컨 사용시 감소하는 시간
|
||||||
|
@JsonProperty("beacon_reduce_time")
|
||||||
|
private Integer beaconReduceTime;
|
||||||
|
//비컨 사용시 추가 획득되는 아이템ID
|
||||||
|
@JsonProperty("beacon_bonus_item_id")
|
||||||
|
private Integer beaconBonusItemId;
|
||||||
|
//1회당 제작 최대 가능 횟수
|
||||||
|
@JsonProperty("max_craft_limit")
|
||||||
|
private Integer maxCraftLimit;
|
||||||
|
}
|
||||||
@@ -52,6 +52,11 @@ public class MetaCraftingData {
|
|||||||
|
|
||||||
@JsonProperty("ItemValue")
|
@JsonProperty("ItemValue")
|
||||||
private int itemValue;
|
private int itemValue;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("(ItemId=%d,ItemValue=%d)", itemId, itemValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -61,5 +66,10 @@ public class MetaCraftingData {
|
|||||||
|
|
||||||
@JsonProperty("AttributeValue")
|
@JsonProperty("AttributeValue")
|
||||||
private int attributeValue;
|
private int attributeValue;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("(AttributeName=%s,AttributeValue=%d)", attributeName, attributeValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.caliverse.admin.domain.response;
|
package com.caliverse.admin.domain.response;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.CraftingDict;
|
||||||
import com.caliverse.admin.domain.entity.ItemDict;
|
import com.caliverse.admin.domain.entity.ItemDict;
|
||||||
import com.caliverse.admin.domain.entity.metadata.*;
|
import com.caliverse.admin.domain.entity.metadata.*;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
@@ -30,6 +31,9 @@ public class DictionaryResponse {
|
|||||||
@JsonProperty("item_list")
|
@JsonProperty("item_list")
|
||||||
private ItemList itemList;
|
private ItemList itemList;
|
||||||
|
|
||||||
|
@JsonProperty("crafting_list")
|
||||||
|
private CraftingList craftingList;
|
||||||
|
|
||||||
@JsonProperty("brand_list")
|
@JsonProperty("brand_list")
|
||||||
private List<MetaBrandData> brandList;
|
private List<MetaBrandData> brandList;
|
||||||
|
|
||||||
@@ -72,5 +76,19 @@ public class DictionaryResponse {
|
|||||||
private List<ItemDict> ja;
|
private List<ItemDict> ja;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public static class CraftingList {
|
||||||
|
@JsonProperty("ko")
|
||||||
|
private List<CraftingDict> ko;
|
||||||
|
|
||||||
|
@JsonProperty("en")
|
||||||
|
private List<CraftingDict> en;
|
||||||
|
|
||||||
|
@JsonProperty("ja")
|
||||||
|
private List<CraftingDict> ja;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,5 +373,187 @@ public class MetaDataService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//제작 백과사전
|
||||||
|
@RequestLog
|
||||||
|
public DictionaryResponse getCraftingDictList(@RequestParam Map<String, String> requestParam){
|
||||||
|
String searchType = requestParam.get("search_type");
|
||||||
|
String searchData = requestParam.get("search_data").trim();
|
||||||
|
String smallType = requestParam.get("small_type");
|
||||||
|
String recipeType = requestParam.get("recipe_type");
|
||||||
|
String orderBy = requestParam.get("orderby");
|
||||||
|
String pageNo = requestParam.get("page_no");
|
||||||
|
String pageSize = requestParam.get("page_size");
|
||||||
|
|
||||||
|
List<MetaCraftingData> items = metaDataHandler.getMetaCraftingListData();
|
||||||
|
|
||||||
|
List<CraftingDict> craftDictListKo = createCraftingDictList(items, LANGUAGETYPE.KO, searchType, searchData, smallType, recipeType);
|
||||||
|
List<CraftingDict> craftDictListEn = createCraftingDictList(items, LANGUAGETYPE.EN, searchType, searchData, smallType, recipeType);
|
||||||
|
List<CraftingDict> craftDictListJa = createCraftingDictList(items, LANGUAGETYPE.JA, searchType, searchData, smallType, recipeType);
|
||||||
|
|
||||||
|
int totalAll = craftDictListKo.size();
|
||||||
|
|
||||||
|
if(orderBy != null && !orderBy.isEmpty()) {
|
||||||
|
Comparator<CraftingDict> comparator = null;
|
||||||
|
|
||||||
|
if(orderBy.equalsIgnoreCase("ASC")) {
|
||||||
|
comparator = Comparator.comparing(CraftingDict::getId);
|
||||||
|
} else if(orderBy.equalsIgnoreCase("DESC")) {
|
||||||
|
comparator = Comparator.comparing(CraftingDict::getId).reversed();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(comparator != null) {
|
||||||
|
craftDictListKo = craftDictListKo.stream().sorted(comparator).toList();
|
||||||
|
craftDictListEn = craftDictListEn.stream().sorted(comparator).toList();
|
||||||
|
craftDictListJa = craftDictListJa.stream().sorted(comparator).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 페이징 처리
|
||||||
|
int currentPageNo = 1;
|
||||||
|
int currentPageSize = 10; // 기본값
|
||||||
|
|
||||||
|
if(pageNo != null && !pageNo.isEmpty()) {
|
||||||
|
try {
|
||||||
|
currentPageNo = Integer.parseInt(pageNo);
|
||||||
|
} catch(NumberFormatException e) {
|
||||||
|
currentPageNo = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pageSize != null && !pageSize.isEmpty()) {
|
||||||
|
try {
|
||||||
|
currentPageSize = Integer.parseInt(pageSize);
|
||||||
|
} catch(NumberFormatException e) {
|
||||||
|
currentPageSize = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// offset 계산
|
||||||
|
int offset = (currentPageNo - 1) * currentPageSize;
|
||||||
|
|
||||||
|
// 페이징 적용
|
||||||
|
List<CraftingDict> pagedCraftingDictListKo = craftDictListKo.stream()
|
||||||
|
.skip(offset)
|
||||||
|
.limit(currentPageSize)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
List<CraftingDict> pagedCraftingDictListEn = craftDictListEn.stream()
|
||||||
|
.skip(offset)
|
||||||
|
.limit(currentPageSize)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
List<CraftingDict> pagedCraftingDictListJa = craftDictListJa.stream()
|
||||||
|
.skip(offset)
|
||||||
|
.limit(currentPageSize)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
DictionaryResponse.CraftingList itemTotalList = DictionaryResponse.CraftingList.builder()
|
||||||
|
.ko(pagedCraftingDictListKo)
|
||||||
|
.en(pagedCraftingDictListEn)
|
||||||
|
.ja(pagedCraftingDictListJa)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
return DictionaryResponse.builder()
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.resultData(DictionaryResponse.ResultData.builder()
|
||||||
|
.craftingList(itemTotalList)
|
||||||
|
.totalAll(totalAll)
|
||||||
|
.total(pagedCraftingDictListKo.size())
|
||||||
|
.pageNo(currentPageNo)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void craftExcelExport(HttpServletResponse response, @RequestParam Map<String, String> requestParam){
|
||||||
|
String searchType = requestParam.get("search_type");
|
||||||
|
String searchData = requestParam.get("search_data").trim();
|
||||||
|
String smallType = requestParam.get("small_type");
|
||||||
|
String recipeType = requestParam.get("recipe_type");
|
||||||
|
String taskId = requestParam.get("task_id");
|
||||||
|
String lang = requestParam.get("lang");
|
||||||
|
|
||||||
|
if(taskId == null || taskId.isEmpty() || taskId.equals("undefined")){
|
||||||
|
log.error("craftExcelExport Excel Export taskId is null or empty");
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_EXCEL_DOWN.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
LANGUAGETYPE languageType = LANGUAGETYPE.valueOf(lang.toUpperCase());
|
||||||
|
|
||||||
|
progressTracker.updateProgress(taskId, 5, 100, "엑셀 생성 준비 중...");
|
||||||
|
|
||||||
|
List<MetaCraftingData> items = metaDataHandler.getMetaCraftingListData();
|
||||||
|
|
||||||
|
List<CraftingDict> craftDictList = createCraftingDictList(items, languageType, searchType, searchData, smallType, recipeType);
|
||||||
|
progressTracker.updateProgress(taskId, 30, 100, "데이터 생성완료");
|
||||||
|
|
||||||
|
try{
|
||||||
|
excelService.generateExcelToResponse(
|
||||||
|
response,
|
||||||
|
craftDictList,
|
||||||
|
"Crafting Dictionary Data",
|
||||||
|
"sheet1",
|
||||||
|
taskId
|
||||||
|
);
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("Excel Export Create Error", e);
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_EXCEL_DOWN.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CraftingDict> createCraftingDictList(List<MetaCraftingData> items, LANGUAGETYPE languageType,
|
||||||
|
String searchType, String searchData, String smallType, String recipeType) {
|
||||||
|
return items.stream()
|
||||||
|
.filter(data -> {
|
||||||
|
boolean result = true;
|
||||||
|
|
||||||
|
if(!smallType.equals("ALL")){
|
||||||
|
result = result && data.getPropSmallType().equals(smallType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipeType.equals("ALL")){
|
||||||
|
result = result && data.getRecipeType().equals(recipeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
})
|
||||||
|
.map(item -> {
|
||||||
|
String itemName = metaDataHandler.getMetaItemNameData(item.getCraftingItemId());
|
||||||
|
|
||||||
|
return CraftingDict.builder()
|
||||||
|
.id(item.getId())
|
||||||
|
.typeSmall(item.getPropSmallType())
|
||||||
|
.itemId(item.getCraftingItemId())
|
||||||
|
.itemName(metaDataHandler.getTextStringData(itemName, languageType))
|
||||||
|
.itemValue(item.getCraftingItemValue())
|
||||||
|
.recipeType(item.getRecipeType())
|
||||||
|
.recipeId(item.getRecipeItemId())
|
||||||
|
.material(item.getMaterials().toString())
|
||||||
|
.attribute(item.getAttributes().toString())
|
||||||
|
.craftingTime(item.getCraftingTime())
|
||||||
|
.beaconReduceTime(item.getBeaconReduceTime())
|
||||||
|
.beaconBonusItemId(item.getBeaconBonusItemId())
|
||||||
|
.maxCraftLimit(item.getMaxCraftLimit())
|
||||||
|
.build();
|
||||||
|
}).filter(data -> {
|
||||||
|
boolean result = true;
|
||||||
|
|
||||||
|
if(!searchData.isEmpty()){
|
||||||
|
if(searchType.equals("NAME")){
|
||||||
|
result = data.getItemName().contains(searchData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(searchType.equals("ID")){
|
||||||
|
result = data.getItemId().toString().equals(searchData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user