From 9d35ba657fa5e3add766405d76e3ff8c4dcd4ad4 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 04 七月 2020 15:38:00 +0800 Subject: [PATCH] 多系统兼容优化 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java | 130 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 104 insertions(+), 26 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java index 5748f06..25ca896 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java @@ -9,6 +9,8 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.entity.accept.AdminAcceptData; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -54,13 +56,14 @@ * 淇濆瓨淇℃伅 * * @param callback - * @param special * @param out */ @RequestMapping(value = "save") - public void save(String callback, BrandClass brandClass, PrintWriter out) { + public void save(AdminAcceptData acceptData, String callback, BrandClass brandClass, PrintWriter out) { try { - brandClassService.saveObject(brandClass); + List<SystemEnum> systemList=new ArrayList<>(); + systemList.add(acceptData.getSystem()); + brandClassService.saveObject(brandClass,systemList); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); } catch (BrandClassException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); @@ -74,13 +77,12 @@ * 淇敼鎺掑簭 * * @param callback - * @param goodsClass * @param out */ @RequestMapping(value = "updateOrder") - public void updateOrder(String callback, Long id, Integer moveType, PrintWriter out) { + public void updateOrder(AdminAcceptData acceptData,String callback, Long id, Integer moveType, PrintWriter out) { try { - brandClassService.updateOrder(id, moveType); + brandClassService.updateOrder(id, moveType,acceptData.getSystem()); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); } catch (BrandClassException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); @@ -101,9 +103,8 @@ * @param out */ @RequestMapping(value = "query") - public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, + public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) { - if (pageIndex == null || pageIndex < 1) { pageIndex = 1; } @@ -113,14 +114,13 @@ } try { - List<BrandClass> list = brandClassService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state); - + List<BrandClass> list = brandClassService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state,acceptData.getSystem()); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); return; } - long count = brandClassService.countQuery(key, state); + long count = brandClassService.countQuery(key, state,acceptData.getSystem()); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); @@ -132,11 +132,28 @@ JSONObject data = new JSONObject(); data.put("pe", pe); data.put("result_list", gson.toJson(list)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + + /** + * 淇敼鐘舵�� + * @param callback + * @param id + * @param out + */ + @RequestMapping(value = "switchStateClass") + public void switchStateClass(String callback, Long id, PrintWriter out) { + try { + brandClassService.switchState(id); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); + } catch (BrandClassException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触")); e.printStackTrace(); } } @@ -150,7 +167,6 @@ */ @RequestMapping(value = "delete") public void delete(String callback, String idArray, PrintWriter out) { - try { if (StringUtil.isNullOrEmpty(idArray)) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�")); @@ -179,9 +195,9 @@ * @param out */ @RequestMapping(value = "getOptions") - public void getOptions(String callback, PrintWriter out) { + public void getOptions(AdminAcceptData acceptData, String callback, PrintWriter out) { try { - List<BrandClass> list = brandClassService.listEffective(); + List<BrandClass> list = brandClassService.listEffective(acceptData.getSystem()); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); return; @@ -278,7 +294,6 @@ * 娣诲姞搴楅摵鍏ュ簱 * * @param callback - * @param special * @param out */ @RequestMapping(value = "saveShopInfo") @@ -362,7 +377,6 @@ * 淇濆瓨淇℃伅 * * @param callback - * @param special * @param out */ @RequestMapping(value = "saveClassShop") @@ -388,7 +402,6 @@ * 淇敼鎺掑簭 * * @param callback - * @param goodsClass * @param out */ @RequestMapping(value = "updateOrderClassShop") @@ -445,9 +458,15 @@ * @param out */ @RequestMapping(value = "saveBrand") - public void saveBrand(String callback, BrandInfo brandInfo, PrintWriter out) { + public void saveBrand(String callback, BrandInfo brandInfo, HttpServletRequest request, PrintWriter out) { try { - brandInfoService.saveObject(brandInfo); + // 1. 鍏堝垽鏂環ttpRequest 鏄惁鍚湁鏂囦欢绫诲瀷 + if (request instanceof MultipartHttpServletRequest) { + MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request; + brandInfoService.saveObject(fileRequest.getFile("file"), brandInfo); + }else{ + brandInfoService.saveObject(null, brandInfo); + } JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); } catch (BrandInfoException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); @@ -457,6 +476,25 @@ } } + + /** + * 淇敼鐘舵�� + * @param callback + * @param id + * @param out + */ + @RequestMapping(value = "switchStateBrand") + public void switchStateBrand(String callback, Long id, PrintWriter out) { + try { + brandInfoService.switchState(id); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); + } catch (BrandInfoException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触")); + e.printStackTrace(); + } + } /** * 鍒犻櫎 @@ -489,6 +527,25 @@ } /** + * 淇敼鎺掑簭 + * + * @param callback + * @param out + */ + @RequestMapping(value = "updateOrderBrand") + public void updateOrderBrand(String callback, Long id, Integer moveType, PrintWriter out) { + try { + brandInfoService.updateOrder(id, moveType); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); + } catch (BrandInfoException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触")); + e.printStackTrace(); + } + } + + /** * 鍝佺墝淇℃伅鏌ヨ * @param callback * @param pageIndex @@ -499,8 +556,8 @@ * @param out */ @RequestMapping(value = "queryBrand") - public void query(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state, - PrintWriter out) { + public void queryBrand(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state, + Integer showState, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { pageIndex = 1; @@ -509,16 +566,37 @@ if (pageSize == null || pageSize < 1) { pageSize = Constant.PAGE_SIZE; } - + + List<String> keys = null; + if (!StringUtil.isNullOrEmpty(key)) { + String[] array = key.split("\\s+"); + if (array != null && array.length > 0) { + keys = new ArrayList<String>(); + for (int i= 0; i < array.length; i++) { + keys.add(array[i].toString()); + } + } + } + try { - List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid, state); + List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, keys, cid, state, showState); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); return; } + + for (BrandInfo brandInfo: list) { + BrandClass brandClass = brandInfo.getBrandClass(); + if (brandClass != null && StringUtil.isNullOrEmpty(brandClass.getName())) { + BrandClass bclass = brandClassService.selectByPrimaryKey(brandClass.getId()); + if (bclass != null) { + brandInfo.setBrandClass(bclass); + } + } + } - long count = brandInfoService.countQuery(key, cid, state); + long count = brandInfoService.countQuery(keys, cid, state, showState); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); -- Gitblit v1.8.0