From ad9fbd2c18f280ef9bba47f28353d367cf2d94e8 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 14 五月 2019 11:28:03 +0800
Subject: [PATCH] Merge branch 'div_12'

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarServiceImpl.java |  155 ++++++++++++++++++++++-----------------------------
 1 files changed, 68 insertions(+), 87 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarServiceImpl.java
index 7de7bc6..c0eb969 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/HomeNavbarServiceImpl.java
@@ -2,28 +2,27 @@
 
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.UUID;
 
 import javax.annotation.Resource;
-import javax.transaction.Transactional;
 
-import org.apache.commons.beanutils.PropertyUtils;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 import org.yeshi.utils.tencentcloud.COSManager;
 
 import com.yeshi.fanli.dao.mybatis.homemodule.HomeNavbarMapper;
-import com.yeshi.fanli.dao.mybatis.homemodule.SuperHomeNavbarMapper;
+import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
 import com.yeshi.fanli.entity.bus.homemodule.HomeNavbar;
-import com.yeshi.fanli.entity.bus.homemodule.SuperHomeNavbar;
-import com.yeshi.fanli.entity.system.BusinessSystem;
-import com.yeshi.fanli.exception.ActivityException;
+import com.yeshi.fanli.entity.bus.homemodule.HomeNavbar.NavbarTypeEnum;
+import com.yeshi.fanli.entity.bus.homemodule.SwiperBanner;
 import com.yeshi.fanli.exception.homemodule.HomeNavbarException;
-import com.yeshi.fanli.service.inter.config.BusinessSystemService;
+import com.yeshi.fanli.service.inter.goods.GoodsClassService;
 import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
+import com.yeshi.fanli.service.inter.homemodule.SwiperBannerService;
 import com.yeshi.fanli.util.StringUtil;
 
 
@@ -31,17 +30,21 @@
 public class HomeNavbarServiceImpl implements HomeNavbarService {
 	
 	@Resource
-	private BusinessSystemService businessSystemService;
-	@Resource
 	private HomeNavbarMapper homeNavbarMapper;
-	@Resource
-	private SuperHomeNavbarMapper superHomeNavbarMapper;
-
 	
+	@Resource
+	private GoodsClassService goodsClassService;
+	
+	@Resource
+	private SwiperBannerService swiperBannerService;
+
 	@Override
 	@Transactional
 	public int deleteBatchByPrimaryKey(List<Long> list) {
-		superHomeNavbarMapper.deleteBatchByNavbarIds(list);
+		if (list == null || list.size() == 0) {
+			return 0;
+		}
+		
 		for (Long id: list) {
 			HomeNavbar homeNavbar = homeNavbarMapper.selectByPrimaryKey(id);
 			if (homeNavbar !=null) {
@@ -52,7 +55,6 @@
 				}
 			}
 		}
-		
 		return homeNavbarMapper.deleteBatchByPrimaryKey(list);
 	}
 
@@ -64,6 +66,34 @@
 		String name = record.getName();
 		if (name == null || name.trim().length() == 0) {
 			throw new HomeNavbarException(1, "瀵艰埅鍚嶇О涓嶈兘涓虹┖");
+		}
+		
+		String startTime_str = record.getStartTime_str();
+		if (record.isTimeTask() && (startTime_str == null || startTime_str.length() == 0)) {
+			throw new HomeNavbarException(1, "鎺у埗鏃堕棿涓嶈兘涓虹┖");
+		}
+		
+		NavbarTypeEnum type = record.getType();
+		if (NavbarTypeEnum.category.equals(type)) {
+			Long classId = record.getClassId();
+			if (classId == null) {
+				throw new HomeNavbarException(1, "璇烽�夋嫨鍒嗙被");
+			}
+			record.setUrl(null);
+			
+		} else if(NavbarTypeEnum.weex.equals(type) || NavbarTypeEnum.web.equals(type)) {
+			String url = record.getUrl();
+			if (url == null || url.trim().length() == 0) {
+				throw new HomeNavbarException(1, "璇疯緭鍏Rl閾炬帴");
+			}
+		} else {
+			throw new HomeNavbarException(1, "绫诲瀷鐨勫�间笉姝g‘");
+		}
+		
+		
+		Long swiperBannerId = record.getSwiperBannerId();
+		if (swiperBannerId != null && swiperBannerId == 0) {
+			record.setSwiperBannerId(null);
 		}
 		
 		// 鏃堕棿杞崲
@@ -149,7 +179,7 @@
 	 * web娈垫椂闂磋浆鎹�
 	 * @param record
 	 */
-	public void conversionTime(HomeNavbar record) throws ActivityException, Exception {
+	public void conversionTime(HomeNavbar record) throws HomeNavbarException, Exception {
 		// 鏄惁鏃堕棿鎺у埗
 		if(!record.isTimeTask()) {
 			record.setStartTime(null);
@@ -160,7 +190,7 @@
 			
 			if ((startTime_str == null|| startTime_str.trim().length() == 0) 
 					&& (endTime_str == null || endTime_str.trim().length() == 0)) {
-				throw new ActivityException(1, "璇疯緭鍏ユ帶鍒舵椂闂�");
+				throw new HomeNavbarException(1, "璇疯緭鍏ユ帶鍒舵椂闂�");
 			} else {
 				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
 				if (startTime_str != null && startTime_str.trim().length() > 0) {
@@ -206,76 +236,7 @@
 		homeNavbarMapper.updateByPrimaryKeySelective(resultObj);
 
 	}
-	
 
-	@Override
-	public List<HomeNavbar> listQueryAndBusinessSystem(long start, int count, String key) {
-		
-		List<HomeNavbar> listObj = homeNavbarMapper.listQuery(start, count, key);
-		if (listObj == null || listObj.size() == 0) {
-			return null;
-		}
-		
-		List<BusinessSystem> systemList = businessSystemService.getBusinessSystems();
-		
-		List<Long> listId = new ArrayList<Long>();
-		for (HomeNavbar homeNavbar: listObj) {
-			listId.add(homeNavbar.getId());
-		}
-		List<SuperHomeNavbar> listSuper = superHomeNavbarMapper.listByNavbarIds(listId);
-		
-		if (listSuper == null || listSuper.size() == 0) {
-			
-			for (HomeNavbar homeNavbar: listObj) {
-				homeNavbar.setSystemList(systemList);
-			}
-			
-		} else {
-			for (HomeNavbar homeNavbar: listObj) {
-				
-				Long id = homeNavbar.getId();
-				List<BusinessSystem> newList = new ArrayList<BusinessSystem>();
-				
-				// 鏄惁鏈夊叧鑱旂郴缁熼�夐」
-				for (BusinessSystem dsystem : systemList) {
-					
-					BusinessSystem newsystem = new BusinessSystem();
-					try {
-						PropertyUtils.copyProperties(newsystem, dsystem);
-					} catch (Exception e) {
-						e.printStackTrace();
-					}
-					
-					if (listSuper != null && listSuper.size() > 0) {
-						Long systemId = newsystem.getId();
-						
-						for (SuperHomeNavbar superHomeNavbar : listSuper) {
-							HomeNavbar navbar = superHomeNavbar.getHomeNavbar();
-							BusinessSystem system = superHomeNavbar.getSystem();
-							
-							// 褰撳墠涓撻 銆佸綋鍓嶇郴缁�
-							if (navbar != null && system != null && id == navbar.getId() 
-									&& systemId == system.getId()) {
-								newsystem.setCheck(1);
-								break;
-							}
-						}
-						
-					}
-					
-					if (newsystem.getCheck() != 1) {
-						newsystem.setCheck(0);
-					}
-					
-					newList.add(newsystem);
-				}
-				
-				homeNavbar.setSystemList(newList);
-			}
-		}
-		
-		return listObj;
-	}
 
 	
 	@Override
@@ -311,6 +272,25 @@
 					homeNavbar.setEndTime_str(sdf.format(endTime));
 				}
 			}
+			
+			Long classId = homeNavbar.getClassId();
+			if (classId != null) {
+				GoodsClass goodsClass = goodsClassService.selectByPrimaryKey(classId);
+				if(goodsClass != null) {
+					homeNavbar.setClassName(goodsClass.getName());
+				}
+			}
+			
+			Long swiperBannerId = homeNavbar.getSwiperBannerId();
+			if (swiperBannerId != null) {
+				SwiperBanner swiperBanner = swiperBannerService.selectByPrimaryKey(swiperBannerId);
+				if(swiperBanner != null) {
+					homeNavbar.setSwiperName(swiperBanner.getTitle());
+				}
+			} else {
+				// 鍒濆鍖�
+				homeNavbar.setSwiperBannerId(0L);
+			}
 		}
 		return listObj;
 	}
@@ -321,7 +301,8 @@
 	}
 
 	@Override
-	public List<HomeNavbar> listQueryEffective() {
+	@Cacheable(value = "configCache", key = "'listQueryEffectiveNavbar'")
+	public List<HomeNavbar> listQueryEffectiveNavbar() {
 		return homeNavbarMapper.listQueryEffective();
 	}
 

--
Gitblit v1.8.0