From eec7e789a87863c25d92c10ad5dfc22ad80c448d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 14 七月 2020 12:36:48 +0800 Subject: [PATCH] 系统区分BUG修复 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsAdminController.java | 84 ++++++++++++++++++++--------------------- 1 files changed, 41 insertions(+), 43 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsAdminController.java index ae3dbe4..f040df8 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsAdminController.java @@ -1,29 +1,25 @@ package com.yeshi.fanli.controller.admin.shop; -import java.io.IOException; -import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; -import java.util.UUID; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import com.yeshi.fanli.entity.accept.AdminAcceptData; 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.yeshi.utils.JsonUtil; -import org.yeshi.utils.tencentcloud.COSManager; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.entity.shop.BanLiShopGoods; +import com.yeshi.fanli.entity.shop.BanLiShopGoodsClass; import com.yeshi.fanli.exception.shop.BanLiShopGoodsException; -import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException; -import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetPayException; +import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsClassService; import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; @@ -37,6 +33,9 @@ @Resource private BanLiShopGoodsService banLiShopGoodsService; + + @Resource + private BanLiShopGoodsClassService banLiShopGoodsClassService; /** * 淇濆瓨淇℃伅 @@ -46,52 +45,23 @@ * @param out */ @RequestMapping(value = "save") - public void save(String callback, BanLiShopGoods record, HttpServletRequest request, PrintWriter out) { + public void save(AdminAcceptData acceptData, String callback, BanLiShopGoods record, HttpServletRequest request, PrintWriter out) { try { - String picture = null; if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request; - MultipartFile file = fileRequest.getFile("file"); - if (file != null) - picture = uploadPicture(file); + banLiShopGoodsService.saveObject(fileRequest.getFile("file"),fileRequest.getFile("file2"), record); + } else { + banLiShopGoodsService.saveObject(null, null,record); } - record.setPicture(picture); - banLiShopGoodsService.addGoods(record); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); } catch (BanLiShopGoodsException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); - } catch (BanLiShopGoodsSetException e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); - } catch (BanLiShopGoodsSetPayException e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); } catch (Exception e) { + e.printStackTrace(); JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); } } - /** - * 涓婁紶鍥剧墖 - * - * @param file - * @return - * @throws Exception - */ - public String uploadPicture(MultipartFile file) throws BanLiShopGoodsException { - // 鏂囦欢瑙f瀽 - InputStream inputStream; - try { - inputStream = file.getInputStream(); - } catch (IOException e) { - e.printStackTrace(); - throw new BanLiShopGoodsException(1, "鍥剧墖鑾峰彇澶辫触"); - } - String contentType = file.getContentType(); - String type = contentType.substring(contentType.indexOf("/") + 1); - // 鏂囦欢璺緞 - String filePath = "/img/HomeNavbar/" + UUID.randomUUID().toString().replace("-", "") + "." + type; - // 鎵ц涓婁紶 - return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); - } /** * 鏌ヨ @@ -103,7 +73,7 @@ * @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) { try { if (pageIndex == null || pageIndex < 1) @@ -116,6 +86,13 @@ if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); return; + } + + for (BanLiShopGoods shopGoods: list) { + BanLiShopGoodsClass goodsClass = shopGoods.getGoodsClass(); + if (goodsClass != null) { + shopGoods.setGoodsClass(banLiShopGoodsClassService.selectByPrimaryKey(goodsClass.getId())); + } } long count = banLiShopGoodsService.countGoods(key, state); @@ -145,7 +122,7 @@ * @param out */ @RequestMapping(value = "delete") - public void delete(String callback, String idArray, PrintWriter out) { + public void delete(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) { try { if (StringUtil.isNullOrEmpty(idArray)) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�")); @@ -167,4 +144,25 @@ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触")); } } + + + /** + * 淇敼鐘舵�� + * @param callback + * @param id + * @param out + */ + @RequestMapping(value = "switchState") + public void switchState(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) { + try { + banLiShopGoodsService.switchState(id); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); + } catch (BanLiShopGoodsException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触")); + e.printStackTrace(); + } + } + } -- Gitblit v1.8.0