From 4a05f1c9c508ab7f10c5eae22a5c716f5454ca02 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 12 三月 2019 16:29:55 +0800
Subject: [PATCH] 冲突提交

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java |   68 +++++++++++++++++++++++++++++++++-
 1 files changed, 66 insertions(+), 2 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 85f9a1f..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
@@ -11,20 +11,24 @@
 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{
@@ -66,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{

--
Gitblit v1.8.0