From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 20 五月 2020 17:25:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2 --- fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 39 insertions(+), 12 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 f57b2f6..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 @@ -4,9 +4,10 @@ import java.util.List; import javax.annotation.Resource; -import javax.transaction.Transactional; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.yeshi.utils.tencentcloud.COSManager; import com.yeshi.fanli.dao.mybatis.homemodule.SwiperBannerMapper; import com.yeshi.fanli.entity.bus.homemodule.SwiperBanner; @@ -15,7 +16,6 @@ import com.yeshi.fanli.service.inter.homemodule.SwiperBannerService; import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService; import com.yeshi.fanli.util.StringUtil; -import org.yeshi.utils.tencentcloud.COSManager; @Service public class SwiperBannerServiceImpl implements SwiperBannerService { @@ -28,27 +28,27 @@ @Override - public int deleteByPrimaryKey(Long id) throws SwiperBannerException{ + public int deleteByPrimaryKey(Long id){ return swiperBannerMapper.deleteByPrimaryKey(id); } @Override - public int insert(SwiperBanner record) throws SwiperBannerException{ + public int insert(SwiperBanner record){ return swiperBannerMapper.insert(record); } @Override - public int insertSelective(SwiperBanner record) throws SwiperBannerException{ + public int insertSelective(SwiperBanner record){ return swiperBannerMapper.insertSelective(record); } @Override - public SwiperBanner selectByPrimaryKey(Long id) throws SwiperBannerException{ + public SwiperBanner selectByPrimaryKey(Long id){ return swiperBannerMapper.selectByPrimaryKey(id); } @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 - @Transactional + 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(); @@ -89,5 +112,9 @@ return swiperBannerMapper.deleteBatchByPrimaryKey(list); } + @Override + public List<SwiperBanner> getEffectiveOption() { + return swiperBannerMapper.getEffectiveOption(); + } } -- Gitblit v1.8.0