Administrator
2018-11-09 3831cce6dc5b5264523e7daaefb056fa3d6f6046
fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsClassController.java
@@ -797,4 +797,62 @@
      }
   }
   
   @RequestMapping(value={"getcategory"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
   public void getcategory(AcceptData acceptData, PrintWriter out) {
      com.yeshi.fanli.entity.system.System system = this.systemService
            .getSystemCache(acceptData.getPlatform(),
                  acceptData.getPackages());
      if (system == null) {
         out.print(JsonUtil.loadFalseResult("系统不存在"));
         return;
      }
      List<SuperGoodsClass> superGoodsClassList = this.superGoodsClassService
            .getSuperGoodsClassBySystemId(system.getId().longValue());
      if ((superGoodsClassList == null) || (superGoodsClassList.size() == 0)) {
         out.print(JsonUtil.loadFalseResult("暂无数据"));
         return;
      }
      List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>();
      for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
         GoodsClass goodsClass = superGoodsClass.getGoodsClass();
         goodsClassList.add(goodsClass);
      }
      JSONArray array = new JSONArray();
      Gson gson = new GsonBuilder().create();
      if (goodsClassList.size() > 0) {
         for (GoodsClass goodsClass : goodsClassList) {
            goodsClass.setKey(null);
            goodsClass.setCreatetime(0L);
            goodsClass.setSearchParam(null);
            goodsClass.setIosClick(null);
            goodsClass.setAndroidClick(null);
            JSONObject data = new JSONObject();
            data.put("gclass", goodsClass);
            long gcid = goodsClass.getId();
            try {
               List<GoodsSubClass> subClassList = this.goodsSubClassService.getSubClassCache(Long.valueOf(gcid),
                           Integer.valueOf(1));
               if ((subClassList == null) || (subClassList.size() == 0)) {
                  subClassList = new ArrayList<GoodsSubClass>();
               }
               data.put("subList", gson.toJson(subClassList));
            } catch (Exception e) {
               e.printStackTrace();
            }
            array.add(data);
         }
      }
      JSONObject data = new JSONObject();
      data.put("categoryList", array);
      out.print(JsonUtil.loadTrueResult(data));
   }
}