From aec36e0e136b55ffeb1d22dd3d7f5c2443b806aa Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 23 九月 2019 10:49:56 +0800
Subject: [PATCH] 品牌 后台管理

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 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..a85cf19 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
@@ -445,9 +445,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()));
@@ -499,7 +505,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "queryBrand")
-	public void query(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
+	public void queryBrand(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
 			PrintWriter out) {
 
 		if (pageIndex == null || pageIndex < 1) {
@@ -509,7 +515,7 @@
 		if (pageSize == null || pageSize < 1) {
 			pageSize = Constant.PAGE_SIZE;
 		}
-
+		
 		try {
 			List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid, state);
 
@@ -517,6 +523,16 @@
 				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);
 			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);

--
Gitblit v1.8.0