From 7ad7905f32ef6b2d67bbd45260a0413be904fa8d Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期五, 20 九月 2019 14:33:08 +0800
Subject: [PATCH] 品牌 、金币任务bug

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/BrandShopAdminController.java |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 107 insertions(+), 0 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 ed79a50..5748f06 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
@@ -20,12 +20,15 @@
 import com.yeshi.fanli.dto.taobao.TaoBaoShopInfoDTO;
 import com.yeshi.fanli.entity.brand.BrandClass;
 import com.yeshi.fanli.entity.brand.BrandClassShop;
+import com.yeshi.fanli.entity.brand.BrandInfo;
 import com.yeshi.fanli.entity.taobao.TaoBaoShop;
 import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
 import com.yeshi.fanli.exception.brand.BrandClassException;
 import com.yeshi.fanli.exception.brand.BrandClassShopException;
+import com.yeshi.fanli.exception.brand.BrandInfoException;
 import com.yeshi.fanli.service.inter.brand.BrandClassService;
 import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
+import com.yeshi.fanli.service.inter.brand.BrandInfoService;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
@@ -43,6 +46,9 @@
 
 	@Resource
 	private BrandClassShopService brandClassShopService;
+	
+	@Resource
+	private BrandInfoService brandInfoService;
 
 	/**
 	 * 淇濆瓨淇℃伅
@@ -429,4 +435,105 @@
 			e.printStackTrace();
 		}
 	}
+	
+	
+	
+	/**
+	 * 鍝佺墝淇℃伅淇濆瓨
+	 * @param callback
+	 * @param brandInfo
+	 * @param out
+	 */
+	@RequestMapping(value = "saveBrand")
+	public void saveBrand(String callback, BrandInfo brandInfo, PrintWriter out) {
+		try {
+			brandInfoService.saveObject(brandInfo);
+			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 idArray
+	 * @param out
+	 */
+	@RequestMapping(value = "deleteBrand")
+	public void deleteBrand(String callback, String idArray, PrintWriter out) {
+		try {
+			if (StringUtil.isNullOrEmpty(idArray)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
+				return;
+			}
+			Gson gson = new Gson();
+			List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
+			}.getType());
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�"));
+				return;
+			}
+			int count = brandInfoService.deleteBatchByPrimaryKey(list);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛鍒犻櫎[" + count + "]鏉℃暟鎹�"));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 鍝佺墝淇℃伅鏌ヨ
+	 * @param callback
+	 * @param pageIndex
+	 * @param pageSize
+	 * @param key
+	 * @param cid
+	 * @param state
+	 * @param out
+	 */
+	@RequestMapping(value = "queryBrand")
+	public void query(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
+			PrintWriter out) {
+
+		if (pageIndex == null || pageIndex < 1) {
+			pageIndex = 1;
+		}
+
+		if (pageSize == null || pageSize < 1) {
+			pageSize = Constant.PAGE_SIZE;
+		}
+
+		try {
+			List<BrandInfo> list = brandInfoService.listQuery((pageIndex - 1) * pageSize, pageSize, key, cid, state);
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+				return;
+			}
+
+			long count = brandInfoService.countQuery(key, cid, state);
+			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
+			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			gsonBuilder.serializeNulls();
+			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+
+			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();
+		}
+	}
+
 }

--
Gitblit v1.8.0