| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.yeshi.fanli.entity.SystemEnum;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
| | | @Service
|
| | | public class SwiperBannerServiceImpl implements SwiperBannerService {
|
| | |
|
| | | @Resource
|
| | | private SwiperBannerMapper swiperBannerMapper;
|
| | | |
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | | |
| | | |
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id){
|
| | | return swiperBannerMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | | @Resource
|
| | | private SwiperBannerMapper swiperBannerMapper;
|
| | |
|
| | | @Override
|
| | | public int insert(SwiperBanner record){
|
| | | return swiperBannerMapper.insert(record);
|
| | | }
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | |
|
| | | @Override
|
| | | public int insertSelective(SwiperBanner record){
|
| | | return swiperBannerMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public SwiperBanner selectByPrimaryKey(Long id){
|
| | | return swiperBannerMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) {
|
| | | return swiperBannerMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(SwiperBanner record) throws SwiperBannerException{
|
| | | return swiperBannerMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | @Override
|
| | | public int insert(SwiperBanner record) {
|
| | | return swiperBannerMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(SwiperBanner record) {
|
| | | return swiperBannerMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | @Override
|
| | | public int insertSelective(SwiperBanner record) {
|
| | | return swiperBannerMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SwiperBanner> query(long start, int count, String key, Integer sort) throws SwiperBannerException{
|
| | | return swiperBannerMapper.query(start, count, key, sort);
|
| | | }
|
| | | @Override
|
| | | public SwiperBanner selectByPrimaryKey(Long id) {
|
| | | return swiperBannerMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countQuery(String key) throws SwiperBannerException{
|
| | | return swiperBannerMapper.countQuery(key);
|
| | | }
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(SwiperBanner record) {
|
| | | return swiperBannerMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @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();
|
| | | if (!StringUtil.isNullOrEmpty(src)) {
|
| | | COSManager.getInstance().deleteFile(src);
|
| | | }
|
| | | listPicID.add(swiperPicture.getId());
|
| | | }
|
| | | |
| | | if (listPicID.size() > 0) {
|
| | | swiperPictureService.deleteBatchByPrimaryKey(listPicID);
|
| | | }
|
| | | |
| | | return swiperBannerMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<SwiperBanner> getEffectiveOption() {
|
| | | return swiperBannerMapper.getEffectiveOption();
|
| | | }
|
| | | @Override
|
| | | public int updateByPrimaryKey(SwiperBanner record) {
|
| | | return swiperBannerMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SwiperBanner> query(long start, int count, String key, Integer sort, SystemEnum system) {
|
| | | return swiperBannerMapper.query(start, count, key, sort, system);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countQuery(String key, SystemEnum system) {
|
| | | return swiperBannerMapper.countQuery(key, system);
|
| | | }
|
| | |
|
| | | @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();
|
| | | if (!StringUtil.isNullOrEmpty(src)) {
|
| | | COSManager.getInstance().deleteFile(src);
|
| | | }
|
| | | listPicID.add(swiperPicture.getId());
|
| | | }
|
| | |
|
| | | if (listPicID.size() > 0) {
|
| | | swiperPictureService.deleteBatchByPrimaryKey(listPicID);
|
| | | }
|
| | |
|
| | | return swiperBannerMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SwiperBanner> getEffectiveOption(SystemEnum system) {
|
| | | return swiperBannerMapper.getEffectiveOption(system);
|
| | | }
|
| | | }
|
| | |
|