# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllItemHandler.java
back_recharge
mashiyu 2019-01-18 12:08:26 +08:00
commit ec8c8ca7f6
4 changed files with 42 additions and 18 deletions

View File

@ -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<CommonProto.Item> itemList = ItemUtil.getAllItem(user);
PlayerInfoProto.GetItemInfoResponse getItemInfoResponse = PlayerInfoProto.GetItemInfoResponse.newBuilder()
.addAllItemlist(itemList)
.build();
try {

View File

@ -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<Integer, Item> itemMap;
private Map<Integer, Item> itemMap = new ConcurrentHashMap<>();
public ItemManager() {
itemMap = new HashMap();

View File

@ -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<CommonProto.Item > getAllItem(User user){
List<CommonProto.Item > itemList = new ArrayList<>();
ItemManager itemManager = user.getItemManager();
Map<Integer, Item> itemMap = itemManager.getItemMap();
if (itemMap.size() !=0 ){
for (Map.Entry<Integer, Item> entry :itemMap.entrySet()){
itemList.add(CBean2Proto.getItem(entry.getValue()));
}
}
return itemList;
}
}

View File

@ -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) {