From 9d384facd1f066beb9e3eefe769ee8616dc2710d Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 23 四月 2020 14:26:50 +0800
Subject: [PATCH] 后台状态切换

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java |   33 ++++++++++++++++++++++++++++-----
 1 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java
index f3633e8..77feaa2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java
@@ -48,7 +48,7 @@
 	}
 
 	@Override
-	public int updateByPrimaryKeySelective(SwiperBanner record) throws SwiperBannerException{
+	public int updateByPrimaryKeySelective(SwiperBanner record){
 		return swiperBannerMapper.updateByPrimaryKeySelective(record);
 	}
 
@@ -58,21 +58,44 @@
 	}
 
 	@Override
-	public List<SwiperBanner> query(long start, int count, String key, Integer sort) throws SwiperBannerException{
+	public List<SwiperBanner> query(long start, int count, String key, Integer sort){
 		return swiperBannerMapper.query(start, count, key, sort);
 	}
 
 	@Override
-	public long countQuery(String key) throws SwiperBannerException{
+	public long countQuery(String key) {
 		return swiperBannerMapper.countQuery(key);
 	}
 
 	@Override
+	public void switchState(Long id) throws SwiperBannerException {
+		if (id == null) {
+			throw new SwiperBannerException(1, "璇蜂紶閫掓纭弬鏁�");
+		}
+		
+		SwiperBanner resultObj = swiperBannerMapper.selectByPrimaryKey(id);
+		if (resultObj == null) {
+			throw new SwiperBannerException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�");
+		}
+		
+		Integer state = resultObj.getState();
+		if (state == null || state == 0) {
+			state = 1;
+		} else {
+			state = 0;
+		}
+		
+		SwiperBanner updateObj = new SwiperBanner();
+		updateObj.setId(id);
+		updateObj.setState(state);
+		swiperBannerMapper.updateByPrimaryKeySelective(updateObj);
+	}
+	
+	
+	@Override
 	@Transactional(rollbackFor=Exception.class)
 	public int deleteBatchByPrimaryKey(List<Long> list) throws Exception {
-		
 		List<Long> listPicID = new ArrayList<Long>();
-		
 		List<SwiperPicture> listPic = swiperPictureService.queryByListBannerID(list);
 		for (SwiperPicture swiperPicture: listPic) {
 			String src = swiperPicture.getSrc();

--
Gitblit v1.8.0