From a8e45a802600ca1cde28fe8522a26635328bbd99 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 15 三月 2019 17:45:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java |   74 ++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 1 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java
index 3fda54d..2032cb9 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java
@@ -8,21 +8,27 @@
 import javax.annotation.Resource;
 import javax.transaction.Transactional;
 
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
+import org.yeshi.utils.tencentcloud.COSManager;
 
 import com.yeshi.fanli.dao.mybatis.homemodule.SwiperPictureMapper;
 import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
+import com.yeshi.fanli.exception.NotExistObjectException;
 import com.yeshi.fanli.exception.banner.SwiperPictureException;
+import com.yeshi.fanli.service.inter.config.SystemConfigService;
 import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
 import com.yeshi.fanli.util.StringUtil;
-import org.yeshi.utils.tencentcloud.COSManager;
 
 @Service
 public class SwiperPictureServiceImpl implements SwiperPictureService {
 
 	@Resource
 	private SwiperPictureMapper swiperPictureMapper;
+	
+	@Resource
+	private SystemConfigService systemConfigService;
 	
 	@Override
 	public int deleteByPrimaryKey(Long id) throws SwiperPictureException{
@@ -64,6 +70,66 @@
 		return swiperPictureMapper.countQueryByBannerID(bannerId);
 	}
 
+	
+	
+	@Override
+	public void save(SwiperPicture record) throws SwiperPictureException{
+		
+		if (record == null) {
+			throw new SwiperPictureException(1, "鍙傛暟涓嶈兘涓虹┖");
+		}
+		
+		Long bannerId = record.getBannerId();
+		if (bannerId == null) {
+			throw new SwiperPictureException(1, "鏍囪瘑绠$悊ID涓嶈兘涓虹┖");
+		}
+		
+		String params = record.getParams();
+		if (!StringUtil.isNullOrEmpty(params)) {
+			try {
+				String jumpValue = systemConfigService.get("jump");
+				if (StringUtil.isNullOrEmpty(jumpValue)) {
+					jumpValue = "{\"url\":\"#\"}";
+				}
+				params = jumpValue.replace("#", params);
+				
+			} catch (NotExistObjectException e) {
+				e.printStackTrace();
+			}
+		}
+		
+		Long id = record.getId();
+		
+		if (id == null) {
+			// 鏂板
+			
+			int maxOrder = swiperPictureMapper.getMaxOrderByBannerID(bannerId);
+			record.setOrder(maxOrder + 1);
+			// 榛樿鍋滅敤
+			record.setState(1);
+			// 榛樿闈炵郴缁熸帶鍒�
+			record.setAutoControl(1);
+			// 榛樿闈炵櫥闄�
+			record.setJumpNeedLogin(false);
+			record.setCreatetime(new Date());
+			record.setUpdatetime(new Date());
+			
+			swiperPictureMapper.insert(record);
+		} else {
+			// 淇敼
+			SwiperPicture resultObj = swiperPictureMapper.selectByPrimaryKey(id);
+			if (resultObj == null) {
+				throw new SwiperPictureException(1, "鍙傛暟涓嶈兘涓虹┖");
+			}
+			
+			record.setOrder(resultObj.getOrder());
+			record.setCreatetime(resultObj.getCreatetime());
+			record.setUpdatetime(new Date());
+			swiperPictureMapper.updateByPrimaryKey(record);
+		}
+	}
+	
+	
 	@Override
 	@Transactional
 	public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException{
@@ -124,5 +190,11 @@
 		return swiperPictureMapper.getMaxOrderByBannerID(bannerId);
 	}
 	
+	@Override
+	@Cacheable(value = "bannerCache", key = "'getByBannerCard-'+#card")
+	public List<SwiperPicture> getByBannerCard(String card) throws SwiperPictureException {
+		return swiperPictureMapper.getByBannerCard(card);
+	}
+	
 }
 

--
Gitblit v1.8.0