admin
2019-04-01 e782b2bcfd89f7ce2e3079c7ebb0867bb00124a7
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsClassAdminCotroller.java
@@ -9,8 +9,6 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -24,9 +22,8 @@
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.admin.GoodsClassAdmin;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.system.System;
import com.yeshi.fanli.service.inter.config.SystemService;
import com.yeshi.fanli.service.inter.goods.ClassRecommendGoodsService;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.goods.GoodsClassService;
import com.yeshi.fanli.service.inter.goods.GoodsSecondClassService;
import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
@@ -36,6 +33,8 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.Utils;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/goodsclass")
@@ -47,8 +46,6 @@
   @Resource
   private SuperGoodsClassService superGoodsClassService;
   @Resource
   private ClassRecommendGoodsService classRecommendGoodsService;
   @Resource
   private GoodsSecondClassService goodsSecondClassService;
@@ -60,11 +57,9 @@
   private LabelClassService labelClassService;
   @Resource
   private SystemService systemService;
   private BusinessSystemService businessSystemService;
   // private static final String IMGPATH="/upload/class";
   @RequestMapping(value = "getGoodsClassList"/* , method = RequestMethod.POST */)
   @RequestMapping(value = "getGoodsClassList")
   public void getGoodsClassList(String callback, Integer pageIndex, String platform, String packages, String key, PrintWriter out) {
      List<GoodsClassAdmin> goodsClassList = goodsClassService.getGoodsClassAdmins(pageIndex - 1, platform, packages, key);
@@ -79,17 +74,12 @@
      pe.setParams(map);
      JSONObject data = new JSONObject();
      data.put("pe", pe);
      List<System> systemList = systemService.getSystems();
      List<BusinessSystem> systemList = businessSystemService.getBusinessSystems();
      data.put("systemList", systemList);
      data.put("goodsClassList", goodsClassList);
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      // out.print(JsonUtil.loadTrueResult(data));
      return;
   }
   @RequestMapping(value = "queryAll")
@@ -103,26 +93,19 @@
            return;
         }
         Map<String, String> map = new HashMap<String, String>();
         map.put("platform", platform);
         map.put("packages", packages);
         JSONObject data = new JSONObject();
         // List<System> systemList = systemService.getSystems();
         // data.put("systemList", systemList);
         data.put("goodsClassList", goodsClassList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
      }
   }
   @RequestMapping(value = "getGoodsClasAll"/* , method = RequestMethod.POST */)
   @RequestMapping(value = "getGoodsClasAll")
   public void getGoodsClassAll(String callback, PrintWriter out) {
      List<GoodsClass> goodsClassList = goodsClassService.getGoodsClassAll();
@@ -136,67 +119,6 @@
      }
   }
   @RequestMapping(value = "addGoodsClass", method = RequestMethod.POST)
   public void addGoodsClass(GoodsClass goodsClass, PrintWriter out) {
      if (goodsClass == null) {
         out.print(JsonUtil.loadFalseResult("goodsClass不能为空"));
         return;
      }
      Integer res = goodsClassService.addGoodsClass(goodsClass);
      if (res == null) {
         out.print(JsonUtil.loadTrueResult("添加分类成功"));
      } else {
         out.print(JsonUtil.loadFalseResult("添加失败"));
      }
      return;
   }
   // @RequestMapping(value="uploadImg",method=RequestMethod.POST)
   // public void uploadImg(@RequestParam("file") CommonsMultipartFile
   // file,HttpServletRequest request,PrintWriter out){
   // ServletContext servletContext = request.getSession().getServletContext();
   // JSONObject json=new JSONObject();
   // if(file != null){
   // String root=servletContext.getRealPath(IMGPATH);
   // if (!new File(root).exists()){
   // new File(root).mkdirs();
   // }
   // File newFile=new File(root+"/"+file.getOriginalFilename());
   // //通过CommonsMultipartFile的方法直接写文件(注意这个时候)
   // try {
   // file.transferTo(newFile);
   // json.put("code", "0");
   // json.put("path", IMGPATH+"/"+newFile.getName());
   // } catch (IllegalStateException e) {
   // e.printStackTrace();
   // json.put("code", "1");
   // } catch (IOException e) {
   // e.printStackTrace();
   // json.put("code", "1");
   // }finally{
   // out.print(json);
   // }
   // }else{
   // json.put("code", "1");
   // out.print(json);
   // }
   // }
   @RequestMapping(value = "setGoodsClassSystem", method = RequestMethod.POST)
   public void setGoodsClassSystem(String type, long gcid, String platform, String packageName, PrintWriter out) {
      platform = Utils.getMap().get(platform);
      if (Constant.DEL.equals(type)) {
         Integer integer = superGoodsClassService.deleteSuperGoodsClass(gcid, platform, packageName);
         if (integer > 0) {
            out.print(JsonUtil.loadTrueResult("删除成功"));
         } else {
            out.print(JsonUtil.loadTrueResult("删除失败"));
         }
      } else {
         superGoodsClassService.addSuperGoodsClass(gcid, platform, packageName);
         out.print(JsonUtil.loadTrueResult("添加成功"));
      }
   }
   @RequestMapping(value = "getGoodsClass", method = RequestMethod.POST)
   public void getGoodsClass(long id, PrintWriter out) {
@@ -208,17 +130,6 @@
      out.print(JsonUtil.loadFalseResult("不存在该GoodsClass"));
   }
   @RequestMapping(value = "deleteGoodsClass", method = RequestMethod.POST)
   public void deleteGoodsClass(long[] gcids, PrintWriter out) {
      goodsClassService.deleteGoodsClasss(gcids);
      out.print(JsonUtil.loadTrueResult("删除成功"));
   }
   @RequestMapping(value = "updateGoodsClass", method = RequestMethod.POST)
   public void updateGoodsClass(GoodsClass goodsClass, PrintWriter out) {
      goodsClassService.updateGoodsClass(goodsClass);
      out.print(JsonUtil.loadTrueResult("修改成功"));
   }
   /**
    * 添加类别
@@ -376,10 +287,7 @@
               Long recordId = Long.parseLong(id);
               superGoodsClassService.deleteSuperGoodsClass(recordId);
               classRecommendGoodsService.deleteClassGoodsByGC(recordId);
               
               // goodsSecondClassService.deleteSecondClassByGC(recordId);
               // 删除子类分类
               goodsSubClassService.deleteByRootId(recordId);
               // 删除类别关联标签