From d5f5e799633f307fed569e095c4ba999cdb14c22 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 28 十二月 2019 10:51:29 +0800
Subject: [PATCH] 学院颜色
---
fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsAdminController.java | 57 +++++++++++++++++----------------------------------------
1 files changed, 17 insertions(+), 40 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..be58ce0 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,24 @@
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 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 +32,9 @@
@Resource
private BanLiShopGoodsService banLiShopGoodsService;
+
+ @Resource
+ private BanLiShopGoodsClassService banLiShopGoodsClassService;
/**
* 淇濆瓨淇℃伅
@@ -48,50 +46,21 @@
@RequestMapping(value = "save")
public void save(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();
- }
/**
* 鏌ヨ
@@ -117,6 +86,14 @@
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);
--
Gitblit v1.8.0