From 651a15c78f668bef3859d9ed1bb7ad0b669d3600 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 03 七月 2020 17:52:07 +0800
Subject: [PATCH] 多APP优化

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java |  133 ++++++++++++++++++++++++--------------------
 1 files changed, 73 insertions(+), 60 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java
index 55d5e28..bccbfcb 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java
@@ -12,6 +12,8 @@
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
+import com.yeshi.fanli.entity.accept.AdminAcceptData;
+import org.apache.commons.beanutils.PropertyUtils;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
@@ -30,6 +32,7 @@
 import com.yeshi.fanli.entity.common.JumpDetailV2;
 import com.yeshi.fanli.exception.banner.SwiperBannerException;
 import com.yeshi.fanli.exception.banner.SwiperPictureException;
+import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.AdminUserService;
 import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
 import com.yeshi.fanli.service.inter.config.AppVersionService;
@@ -57,19 +60,10 @@
 public class SwiperBannerAdminController {
 
 	@Resource
-	private AdminUserService adminUserService;
-
-	@Resource
 	private SwiperBannerService swiperBannerService;
 
 	@Resource
 	private SwiperPictureService swiperPictureService;
-
-	@Resource
-	private SystemConfigService systemConfigService;
-
-	@Resource
-	private JumpDetailV2Service jumpDetailV2Service;
 
 	@Resource
 	private AppVersionService appVersionService;
@@ -89,7 +83,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "saveAdd")
-	public void saveAdd(String callback, SwiperBanner swiperBanner, PrintWriter out) {
+	public void saveAdd(AdminAcceptData acceptData, String callback, SwiperBanner swiperBanner, PrintWriter out) {
 
 		try {
 			String title = swiperBanner.getTitle();
@@ -107,10 +101,12 @@
 			Date nowTime = new Date();
 			swiperBanner.setCreatetime(nowTime);
 			swiperBanner.setUpdatetime(nowTime);
+			swiperBanner.setSystem(acceptData.getSystem());
 			swiperBannerService.insertSelective(swiperBanner);
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛"));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
@@ -123,7 +119,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "saveModify")
-	public void saveModify(String callback, SwiperBanner swiperBanner, PrintWriter out) {
+	public void saveModify(AdminAcceptData acceptData, String callback, SwiperBanner swiperBanner, PrintWriter out) {
 		try {
 			Long id = swiperBanner.getId();
 			if (id == null) {
@@ -160,6 +156,7 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
@@ -171,7 +168,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "switchState")
-	public void switchState(String callback, Long id, PrintWriter out) {
+	public void switchState(AdminAcceptData acceptData, String callback, Long id, PrintWriter out) {
 		try {
 			swiperBannerService.switchState(id);
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
@@ -179,25 +176,23 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
-	
 
 	/**
 	 * 鏌ヨ
-	 * 
+	 * @param acceptData
 	 * @param callback
 	 * @param pageIndex
 	 * @param pageSize
-	 * @param key
-	 *            妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
-	 * @param sort
-	 *            鎺掑簭 锛� 鍒涘缓鏃堕棿鍊掑簭1 榛樿姝e簭
+	 * @param key   妯$硦鏌ヨ锛氳鏄庛�佹爣璇�
+	 * @param sort   鎺掑簭 锛� 鍒涘缓鏃堕棿鍊掑簭1 榛樿姝e簭
 	 * @param out
 	 */
 	@RequestMapping(value = "query")
-	public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, PrintWriter out) {
+	public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, PrintWriter out) {
 		if (pageIndex == null || pageIndex < 1) {
 			pageIndex = 1;
 		}
@@ -206,7 +201,7 @@
 			pageSize = Constant.PAGE_SIZE;
 		}
 		try {
-			List<SwiperBanner> list = swiperBannerService.query((pageIndex - 1) * pageSize, pageSize, key, sort);
+			List<SwiperBanner> list = swiperBannerService.query((pageIndex - 1) * pageSize, pageSize, key, sort,acceptData.getSystem());
 			if (list == null || list.size() == 0) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
 				return;
@@ -222,7 +217,7 @@
 				swiperBanne.setTotalPic(TotalPic);
 			}
 
-			long count = swiperBannerService.countQuery(key);
+			long count = swiperBannerService.countQuery(key,acceptData.getSystem());
 			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
 			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
 
@@ -236,6 +231,7 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
@@ -248,7 +244,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("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
@@ -267,12 +263,13 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛鍒犻櫎[" + count + "]鏉℃暟鎹�"));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
 
 	@RequestMapping(value = "getEffectiveOption")
-	public void getEffectiveOption(String callback, PrintWriter out) {
+	public void getEffectiveOption(AdminAcceptData acceptData, String callback, PrintWriter out) {
 		try {
 			List<Object> list = new ArrayList<Object>();
 			Map<String, Object> mapDefalut = new HashMap<String, Object>();
@@ -280,7 +277,7 @@
 			mapDefalut.put("value", "--鏈�夋嫨--");
 			list.add(mapDefalut);
 
-			List<SwiperBanner> listBanner = swiperBannerService.getEffectiveOption();
+			List<SwiperBanner> listBanner = swiperBannerService.getEffectiveOption(acceptData.getSystem());
 			if (listBanner != null && listBanner.size() > 0) {
 				for (SwiperBanner swiperBanner : listBanner) {
 					Map<String, Object> map = new HashMap<String, Object>();
@@ -295,6 +292,7 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
@@ -309,7 +307,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "queryPicInfo")
-	public void queryPicInfo(String callback, Integer pageIndex, Integer pageSize, Long bannerId, String version,
+	public void queryPicInfo(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, Long bannerId, String version,
 			String platform, PrintWriter out) {
 		if (bannerId == null) {
 			out.print(JsonUtil.loadFalseResult("杞挱鍥剧鐞咺D涓嶈兘涓虹┖"));
@@ -329,7 +327,7 @@
 				if (appVersion != null)
 					versionList.add(appVersion);
 			} else {
-				List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform);
+				List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform,acceptData.getSystem());
 				if (appVersionList != null) {
 					versionList.addAll(appVersionList);
 				}
@@ -337,70 +335,81 @@
 		}
 
 		try {
-			List<BannerVO> list = swiperPictureService.queryByBannerID((pageIndex - 1) * pageSize, pageSize,
+			List<SwiperPicture> listPic = swiperPictureService.queryByBannerID((pageIndex - 1) * pageSize, pageSize,
 					bannerId);
-			if (list == null || list.size() == 0) {
+			if (listPic == null || listPic.size() == 0) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
 				return;
 			}
 
+			List<BannerVO> list = new ArrayList<BannerVO>();
 			// 璺宠浆閾炬帴
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
-			for (BannerVO swiperPicture : list) {
-				if (swiperPicture.getState() != null && swiperPicture.getState() == 0) {
-					swiperPicture.setState(1);
-				} else {
-					swiperPicture.setState(0);
+			for (SwiperPicture swiperPicture : listPic) {
+				BannerVO bannerVO = new BannerVO();
+				try {
+					PropertyUtils.copyProperties(bannerVO, swiperPicture);
+				} catch (Exception e) {
+					e.printStackTrace();
+					continue;
 				}
 				
 				
-				Date startTime = swiperPicture.getStartTime();
+				if (bannerVO.getState() != null && bannerVO.getState() == 0) {
+					bannerVO.setState(1);
+				} else {
+					bannerVO.setState(0);
+				}
+				
+				
+				Date startTime = bannerVO.getStartTime();
 				if (startTime == null) {
-					swiperPicture.setStartTime_str("");
+					bannerVO.setStartTime_str("");
 				} else {
-					swiperPicture.setStartTime_str(sdf.format(startTime));
+					bannerVO.setStartTime_str(sdf.format(startTime));
 				}
 
-				Date endTime = swiperPicture.getEndTime();
+				Date endTime = bannerVO.getEndTime();
 				if (endTime == null) {
-					swiperPicture.setEndTime_str("");
+					bannerVO.setEndTime_str("");
 				} else {
-					swiperPicture.setEndTime_str(sdf.format(endTime));
+					bannerVO.setEndTime_str(sdf.format(endTime));
 				}
 
-				String params = swiperPicture.getParams();
+				String params = bannerVO.getParams();
 				if (params == null) {
-					swiperPicture.setParams("");
+					bannerVO.setParams("");
 				}
 
-				String remark = swiperPicture.getRemark();
+				String remark = bannerVO.getRemark();
 				if (remark == null) {
-					swiperPicture.setRemark("");
+					bannerVO.setRemark("");
 				}
 
-				JumpDetailV2 jumpDetail = swiperPicture.getJumpDetail();
+				JumpDetailV2 jumpDetail = bannerVO.getJumpDetail();
 				if (jumpDetail == null) {
 					// 榛樿鏈�夋嫨
 					JumpDetailV2 jumpDetailV2 = new JumpDetailV2();
 					jumpDetailV2.setName("-鏈�夋嫨-");
 					jumpDetailV2.setType("default");
-					swiperPicture.setJumpDetail(jumpDetailV2);
+					bannerVO.setJumpDetail(jumpDetailV2);
 				}
 				
 				// 鍒嗕韩琛ュ厖淇℃伅
-				CommonShareInfo info = commonShareInfoService.getByPidAndType(swiperPicture.getId(),
+				CommonShareInfo info = commonShareInfoService.getByPidAndType(bannerVO.getId(),
 						CommonShareInfoEnum.banner.name());
 				if (info == null) {
-					swiperPicture.setNeedSpin(false);
-					swiperPicture.setComment("");
+					bannerVO.setNeedSpin(false);
+					bannerVO.setComment("");
 				} else {
-					swiperPicture.setNeedSpin(info.getNeedSpin());
+					bannerVO.setNeedSpin(info.getNeedSpin());
 					if (StringUtil.isNullOrEmpty(info.getComment())) {
-						swiperPicture.setComment("");
+						bannerVO.setComment("");
 					} else {
-						swiperPicture.setComment(info.getComment());
+						bannerVO.setComment(info.getComment());
 					}
 				}
+				list.add(bannerVO);
 			}
 
 			long count = swiperPictureService.countQueryByBannerID(bannerId);
@@ -442,6 +451,7 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 		} catch (SwiperPictureException e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 
@@ -455,9 +465,10 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "savePicInfo")
-	public void savePicInfo(String callback, SwiperPicture record, String jumpType, CommonShareInfo extra, 
+	public void savePicInfo(AdminAcceptData acceptData, String callback, SwiperPicture record, String jumpType, CommonShareInfo extra,
 			HttpServletRequest request,	PrintWriter out) {
 		try {
+			record.setSystem(acceptData.getSystem());
 			// 1. 鍏堝垽鏂環ttpRequest 鏄惁鍚湁鏂囦欢绫诲瀷
 			if (request instanceof MultipartHttpServletRequest) {
 				MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
@@ -471,6 +482,7 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
@@ -483,7 +495,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "switchStatePic")
-	public void switchStatePic(String callback, Long id, PrintWriter out) {
+	public void switchStatePic(AdminAcceptData acceptData, String callback, Long id, PrintWriter out) {
 		try {
 			swiperPictureService.switchState(id);
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
@@ -491,6 +503,7 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
@@ -504,7 +517,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "deletePicInfo")
-	public void deletePicInfo(String callback, String idArray, PrintWriter out) {
+	public void deletePicInfo(AdminAcceptData acceptData, String callback, String idArray, PrintWriter out) {
 		try {
 			if (StringUtil.isNullOrEmpty(idArray)) {
 				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�"));
@@ -524,6 +537,7 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛鍒犻櫎[" + count + "]鏉℃暟鎹�"));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			LogHelper.errorDetailInfo(e);
 			e.printStackTrace();
 		}
 	}
@@ -536,7 +550,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "saveOrder")
-	public void saveOrder(String callback, Long id, Integer moveType, PrintWriter out) {
+	public void saveOrder(AdminAcceptData acceptData, String callback, Long id, Integer moveType, PrintWriter out) {
 		if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掔殑绫诲瀷涓嶆纭�"));
 			return;
@@ -569,8 +583,9 @@
 			swiperPictureService.updateByPrimaryKeySelective(resultObj);
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
 		} catch (Exception e) {
-			e.printStackTrace();
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			LogHelper.errorDetailInfo(e);
+			e.printStackTrace();
 		}
 	}
 
@@ -579,12 +594,10 @@
 	 * 
 	 * @param callback
 	 * @param id
-	 * @param moveType
-	 * @param sex
 	 * @param out
 	 */
 	@RequestMapping(value = "setVersions")
-	public void setVersions(String callback, Long id, String versions, PrintWriter out) {
+	public void setVersions(AdminAcceptData acceptData, String callback, Long id, String versions, PrintWriter out) {
 		JSONArray versionArray = JSONArray.fromObject(versions);
 		List<Long> versionIds = new ArrayList<>();
 		for (int i = 0; i < versionArray.size(); i++) {
@@ -600,7 +613,7 @@
 	}
 
 	@RequestMapping(value = "getVersions")
-	public void getVersions(String callback, Long id, PrintWriter out) {
+	public void getVersions(AdminAcceptData acceptData, String callback, Long id, PrintWriter out) {
 		List<AdActivityVersionControl> list = adActivityVersionControlService
 				.listByTypeAndSourceId(AdActivityType.banner, id);
 

--
Gitblit v1.8.0