| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.multipart.MultipartHttpServletRequest;
|
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | 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;
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | @Resource
|
| | | private SuperGoodsClassService superGoodsClassService;
|
| | |
|
| | | @Resource
|
| | | private ClassRecommendGoodsService classRecommendGoodsService;
|
| | |
|
| | | @Resource
|
| | | private GoodsSecondClassService goodsSecondClassService;
|
| | |
| | | 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);
|
| | |
| | | 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")
|
| | |
| | | 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();
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @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) {
|
| | |
| | | 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("修改成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加类别
|
| | |
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "saveAdd", method = RequestMethod.POST)
|
| | | public void saveAdd(String callback, GoodsClass goodsClass, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
|
| | |
|
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | | public void saveAdd(String callback, GoodsClass goodsClass, HttpServletRequest request, PrintWriter out) {
|
| | | try {
|
| | |
|
| | | String name = goodsClass.getName();
|
| | |
| | | Long recordId = Long.parseLong(id);
|
| | |
|
| | | superGoodsClassService.deleteSuperGoodsClass(recordId);
|
| | | classRecommendGoodsService.deleteClassGoodsByGC(recordId);
|
| | |
|
| | | // goodsSecondClassService.deleteSecondClassByGC(recordId); |
| | | |
| | | // 删除子类分类
|
| | | goodsSubClassService.deleteByRootId(recordId);
|
| | | // 删除类别关联标签
|
| | |
| | | * @param out
|
| | | * @param response
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "uploadPicture")
|
| | | public void uploadPicture(Long id, @RequestParam("file") CommonsMultipartFile file, PrintWriter out, HttpServletResponse response) {
|
| | |
|
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | | public void uploadPicture(Long id, @RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | GoodsClass goodsClass = goodsClassService.getGoodsClass(id);
|
| | |
|
| | | if (goodsClass == null) {
|
| | | if (goodsClass == null ) {
|
| | | out.print(JsonUtil.loadFalseResult("该类别不存在或已被删除"));
|
| | | return;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | goodsClassService.uploadPicture(goodsClass, file);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult("上传成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadFalseResult("操作异常"));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|