From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 20 五月 2020 17:25:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsClassAdminCotroller.java | 275 +++++++++++------------------------------------------- 1 files changed, 58 insertions(+), 217 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 82f9a3c..ca1cf36 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,30 @@ 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 net.sf.json.JSONObject; - 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.goods.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 net.sf.json.JSONObject; @Controller @RequestMapping("admin/new/api/v1/goodsclass") @@ -48,48 +38,22 @@ private SuperGoodsClassService superGoodsClassService; @Resource - private ClassRecommendGoodsService classRecommendGoodsService; - - @Resource private GoodsSecondClassService goodsSecondClassService; @Resource private GoodsSubClassService goodsSubClassService; - + @Resource private LabelClassService labelClassService; @Resource - private SystemService systemService; - - @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); - - 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)); - } + private BusinessSystemService businessSystemService; @RequestMapping(value = "queryAll") - public void queryAll(String callback, String platform, String packages, PrintWriter out) { + public void listquery(String callback, Integer sex, PrintWriter out) { try { - List<GoodsClass> goodsClassList = goodsClassService.queryAll(platform, packages); + List<GoodsClass> goodsClassList = goodsClassService.listquery(sex); if (goodsClassList == null || goodsClassList.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); @@ -107,7 +71,6 @@ } - @RequestMapping(value = "getGoodsClasAll") public void getGoodsClassAll(String callback, PrintWriter out) { List<GoodsClass> goodsClassList = goodsClassService.getGoodsClassAll(); @@ -122,148 +85,75 @@ } } - - @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")); - } - - /** - * 娣诲姞绫诲埆 + * 淇濆瓨淇℃伅 * * @param callback - * @param goodsClass - * @param request + * @param special * @param out */ - @RequestMapping(value = "saveAdd", method = RequestMethod.POST) - public void saveAdd(String callback, GoodsClass goodsClass, HttpServletRequest request, PrintWriter out) { + @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 (GoodsClassException 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 id + * @param out + */ + @RequestMapping(value = "switchState") + public void switchState(String callback, Long id, PrintWriter out) { + try { + goodsClassService.switchState(id); + 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(); + } + } + + /** - * 淇濆瓨淇敼淇℃伅 + * 淇敼鎺掑簭 * * @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("鎿嶄綔寮傚父")); - } - } /** @@ -275,9 +165,7 @@ */ @RequestMapping(value = "deleteBatch") public void deleteBatch(String callback, String ids, PrintWriter out) { - Gson gson = new Gson(); - try { List<String> recordIds = gson.fromJson(ids, new TypeToken<ArrayList<String>>() { }.getType()); @@ -290,59 +178,19 @@ 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 - */ - @RequestMapping(value = "uploadPicture") - public void uploadPicture(Long id, @RequestParam("file") CommonsMultipartFile file, PrintWriter out) { - - 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) { - e.printStackTrace(); - out.print(JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); } } @@ -356,7 +204,6 @@ */ @RequestMapping(value = "removePicture") public void removePicture(String callback, Long id, PrintWriter out) { - try { GoodsClass goodsClass = goodsClassService.getGoodsClass(id); @@ -373,11 +220,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); @@ -391,18 +238,12 @@ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛")); } } - - + @RequestMapping(value = "getClassOption") public void getClassOption(String callback, PrintWriter out) { - List<GoodsClass> goodsClassList = goodsClassService.getGoodsClassAll(); - JSONObject data = new JSONObject(); - data.put("result_list", goodsClassList); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } } -- Gitblit v1.8.0