diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllItemHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllItemHandler.java index ca0a41c61..c7aef8294 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllItemHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllItemHandler.java @@ -53,8 +53,9 @@ public class GetAllItemHandler extends BaseHandler { itemList.add(item2); itemList.add(item3); - PlayerInfoProto.GetItemInfoResponse getItemInfoResponse - = PlayerInfoProto.GetItemInfoResponse.newBuilder() +// User user = UserManager.getUserForLogin(userId); +// List itemList = ItemUtil.getAllItem(user); + PlayerInfoProto.GetItemInfoResponse getItemInfoResponse = PlayerInfoProto.GetItemInfoResponse.newBuilder() .addAllItemlist(itemList) .build(); try { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java index 2613ad97d..eca0c77b8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java @@ -5,9 +5,10 @@ import com.ljsd.jieling.config.SItem; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class ItemManager extends MongoBase { - private Map itemMap; + private Map itemMap = new ConcurrentHashMap<>(); public ItemManager() { itemMap = new HashMap(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index b0e3701b4..398147177 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -5,9 +5,12 @@ import com.ljsd.jieling.logic.dao.Item; import com.ljsd.jieling.logic.dao.ItemManager; import com.ljsd.jieling.logic.dao.User; import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.protocols.CommonProto; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.List; import java.util.Map; public class ItemUtil { @@ -55,4 +58,17 @@ public class ItemUtil { } } + + public static List getAllItem(User user){ + List itemList = new ArrayList<>(); + ItemManager itemManager = user.getItemManager(); + Map itemMap = itemManager.getItemMap(); + if (itemMap.size() !=0 ){ + for (Map.Entry entry :itemMap.entrySet()){ + itemList.add(CBean2Proto.getItem(entry.getValue())); + } + } + return itemList; + } + } diff --git a/test/src/main/java/ExcelUtils.java b/test/src/main/java/ExcelUtils.java index afb70c898..938ef2114 100644 --- a/test/src/main/java/ExcelUtils.java +++ b/test/src/main/java/ExcelUtils.java @@ -72,21 +72,7 @@ public class ExcelUtils { Cell cell = row.getCell(j); if (cell == null){ Cell cell1 = row4.getCell(j); - if (cell1==null){ - String in = getIn(row2.getCell(j).toString()); - if (info.length() == 0){ - info = info.append(in); - }else{ - info.append("\t").append(in); - } - }else{ - cellData = getCellFormatValue(cell1); - if (info.length() == 0){ - info = info.append(cellData); - }else{ - info.append("\t").append(cellData); - } - } + info = getStringBuilder(row2, info, j, cell1); }else{ if (getCellFormatValue(row1.getCell(j)).toString().isEmpty()){ continue; @@ -111,6 +97,26 @@ public class ExcelUtils { out.close(); } + private static StringBuilder getStringBuilder(Row row2, StringBuilder info, int j, Cell cell1) { + Object cellData; + if (cell1==null){ + String in = getIn(row2.getCell(j).toString()); + if (info.length() == 0){ + info = info.append(in); + }else{ + info.append("\t").append(in); + } + }else{ + cellData = getCellFormatValue(cell1); + if (info.length() == 0){ + info = info.append(cellData); + }else{ + info.append("\t").append(cellData); + } + } + return info; + } + private static String getIn(String row2) { String str = ""; switch (row2) {