From a82cab28796d4287f4514813f6d8b2c3023fb4cb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 09 五月 2019 10:51:50 +0800
Subject: [PATCH] 增加缓存清除,增加搜索与推荐的淘客商品过滤
---
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsClassAdminCotroller.java | 346 ++++++---------------------------------------------------
1 files changed, 38 insertions(+), 308 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsClassAdminCotroller.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsClassAdminCotroller.java
index 7277912..d1662e3 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsClassAdminCotroller.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsClassAdminCotroller.java
@@ -2,40 +2,29 @@
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
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.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-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.exception.FloatADException;
+import com.yeshi.fanli.exception.GoodsClassException;
+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.service.inter.goods.SuperGoodsClassService;
import com.yeshi.fanli.service.inter.lable.LabelClassService;
-import com.yeshi.fanli.tag.PageEntity;
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;
@@ -50,81 +39,40 @@
private SuperGoodsClassService superGoodsClassService;
@Resource
- private ClassRecommendGoodsService classRecommendGoodsService;
-
- @Resource
private GoodsSecondClassService goodsSecondClassService;
@Resource
private GoodsSubClassService goodsSubClassService;
-
+
@Resource
private LabelClassService labelClassService;
@Resource
- private SystemService systemService;
-
- // private static final String IMGPATH="/upload/class";
-
- @RequestMapping(value = "getGoodsClassList"/* , method = RequestMethod.POST */)
- 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);
-
- int count = goodsClassService.getCount(platform, packages, key);
- int totalPage = count % Constant.PAGE_SIZE == 0 ? count / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1;
- PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count, totalPage);
- Map<String, String> map = new HashMap<String, String>();
- map.put("platform", platform);
- map.put("packages", packages);
- map.put("key", key);
- pe.setParams(map);
- JSONObject data = new JSONObject();
- data.put("pe", pe);
- List<System> systemList = systemService.getSystems();
-
- data.put("systemList", systemList);
- data.put("goodsClassList", goodsClassList);
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
- // out.print(JsonUtil.loadTrueResult(data));
-
- return;
-
- }
+ private BusinessSystemService businessSystemService;
@RequestMapping(value = "queryAll")
- public void queryAll(String callback, String platform, String packages, PrintWriter out) {
+ public void listquery(String callback, PrintWriter out) {
try {
- List<GoodsClass> goodsClassList = goodsClassService.queryAll(platform, packages);
+ List<GoodsClass> goodsClassList = goodsClassService.listquery();
if (goodsClassList == null || goodsClassList.size() == 0) {
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
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();
@@ -138,224 +86,54 @@
}
}
- @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) {
- GoodsClass rb = goodsClassService.getGoodsClass(id);
- if (rb != null) {
- out.print(JsonUtil.loadTrueResult(rb));
- return;
- }
- 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 callback
- * @param goodsClass
- * @param request
+ * @param special
* @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", "*");
+ @RequestMapping(value = "save")
+ public void save(String callback, GoodsClass goodsClass, String jumpType, HttpServletRequest request,
+ PrintWriter out) {
+ if (goodsClass.getTaobaoCids() != null)
+ goodsClass.setTaobaoCids(goodsClass.getTaobaoCids().replace("锛�", ","));
try {
-
- String name = goodsClass.getName();
- if (StringUtil.isNullOrEmpty(name)) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绫诲埆鍚嶇О涓嶈兘涓虹┖"));
- return;
- }
-
+ // 1. 鍏堝垽鏂環ttpRequest 鏄惁鍚湁鏂囦欢绫诲瀷
if (request instanceof MultipartHttpServletRequest) {
-
- long result;
- List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");
-
- goodsClass.setAndroidClick(0L);
- goodsClass.setIosClick(0L);
- // 鎼滅储鏉′欢:鏈夊埜銆佸湪鍞环20-200銆佺墰鐨櫍杞诲井
- goodsClass.setSearchParam("{\"quan\":1,\"endPrice\":220,\"includeGoodRate\":true,\"baoYou\":true,\"ip\":\"218.72.111.105\"}");
-
- if (files != null && files.size() > 0) {
- // 鍥剧墖鏂囦欢涓婁紶
- result = goodsClassService.saveAdd(goodsClass, files.get(0));
- } else {
- // 鏃犲浘淇濆瓨
- result = goodsClassService.saveAdd(goodsClass, null);
- }
-
- if (result > 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
- } else {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
- }
-
+ MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
+ goodsClassService.saveObject(fileRequest.getFile("file"), goodsClass);
} else {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭殑鍙傛暟"));
+ goodsClassService.saveObject(null, goodsClass);
}
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+ } catch (FloatADException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
} catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
e.printStackTrace();
}
-
}
/**
- * 淇濆瓨淇敼淇℃伅
+ * 淇敼鎺掑簭
*
* @param callback
* @param goodsClass
* @param out
*/
- @RequestMapping(value = "saveModify")
- public void saveModify(String callback, GoodsClass goodsClass, PrintWriter out) {
-
+ @RequestMapping(value = "updateOrder")
+ public void updateOrder(String callback, Long id, Integer moveType, PrintWriter out) {
try {
-
- Long id = goodsClass.getId();
-
- GoodsClass resultObj = goodsClassService.getGoodsClass(id);
-
- if (resultObj == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鍒笉瀛樺湪鎴栧凡琚垹闄�"));
- } else {
- String name = goodsClass.getName();
- if (!StringUtil.isNullOrEmpty(name)) {
- resultObj.setName(name);
- }
-
- String key = goodsClass.getKey();
- if (!StringUtil.isNullOrEmpty(key)) {
- resultObj.setKey(key);
- }
-
- goodsClassService.updateGoodsClass(resultObj);
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
- }
-
+ goodsClassService.updateOrder(id, moveType);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+ } catch (GoodsClassException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
} catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
e.printStackTrace();
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
}
-
- }
-
- /**
- * 淇濆瓨淇敼淇℃伅
- *
- * @param callback
- * @param goodsClass
- * @param out
- */
- @RequestMapping(value = "saveOrderby")
- public void saveOrderby(String callback, Long id, int orderby, PrintWriter out) {
-
- try {
-
- GoodsClass resultObj = goodsClassService.getGoodsClass(id);
-
- if (resultObj == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鍒笉瀛樺湪鎴栧凡琚垹闄�"));
- } else {
-
- List<GoodsClass> glist = goodsClassService.getByorderby(orderby);
- if (glist != null && glist.size() > 0) {
- GoodsClass changeObj = glist.get(0);
- changeObj.setOrderby(resultObj.getOrderby());
- goodsClassService.updateGoodsClass(changeObj);
- }
-
- resultObj.setOrderby(orderby);
- goodsClassService.updateGoodsClass(resultObj);
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
- }
-
}
/**
@@ -382,67 +160,20 @@
Long recordId = Long.parseLong(id);
superGoodsClassService.deleteSuperGoodsClass(recordId);
- classRecommendGoodsService.deleteClassGoodsByGC(recordId);
-
- // goodsSecondClassService.deleteSecondClassByGC(recordId);
-
+
// 鍒犻櫎瀛愮被鍒嗙被
goodsSubClassService.deleteByRootId(recordId);
// 鍒犻櫎绫诲埆鍏宠仈鏍囩
labelClassService.deleteByClassId(recordId);
-
+
goodsClassService.deleteGoodsClass(recordId);
}
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛"));
}
} catch (Exception e) {
- // TODO Auto-generated catch block
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
e.printStackTrace();
- }
-
- }
-
- //
- /**
- * 涓婁紶/淇敼 鍥剧墖
- *
- * @param callback
- * @param file
- * @param request
- * @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", "*");
-
- try {
-
- GoodsClass goodsClass = goodsClassService.getGoodsClass(id);
-
- if (goodsClass == null) {
- out.print(JsonUtil.loadFalseResult("璇ョ被鍒笉瀛樺湪鎴栧凡琚垹闄�"));
- return;
- }
-
- if (file == 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("鎿嶄綔寮傚父"));
}
}
@@ -474,11 +205,11 @@
e.printStackTrace();
out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")));
}
-
}
-
+
@RequestMapping(value = "setSuperSystem")
- public void setSuperSystem(String callback,String type, Long gcid, String platform, String packageName, PrintWriter out) {
+ public void setSuperSystem(String callback, 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);
@@ -492,8 +223,7 @@
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛"));
}
}
-
-
+
@RequestMapping(value = "getClassOption")
public void getClassOption(String callback, PrintWriter out) {
--
Gitblit v1.8.0