From 7b352c4ab440fe31246c9a13cee503729061c95c Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 29 四月 2020 16:58:36 +0800
Subject: [PATCH] 发圈排列优化
---
fanli/src/main/java/com/yeshi/fanli/controller/admin/shop/BanLiShopGoodsAdminController.java | 66 ++++++++++++--------------------
1 files changed, 25 insertions(+), 41 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 b3349d3..3b3fcde 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,21 +1,16 @@
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;
@@ -23,8 +18,6 @@
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;
@@ -53,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();
- }
/**
* 鏌ヨ
@@ -129,7 +93,6 @@
shopGoods.setGoodsClass(banLiShopGoodsClassService.selectByPrimaryKey(goodsClass.getId()));
}
}
-
long count = banLiShopGoodsService.countGoods(key, state);
@@ -180,4 +143,25 @@
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
}
}
+
+
+ /**
+ * 淇敼鐘舵��
+ * @param callback
+ * @param id
+ * @param out
+ */
+ @RequestMapping(value = "switchState")
+ public void switchState(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