admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java
@@ -22,7 +22,6 @@
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
@@ -30,6 +29,7 @@
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.StringUtil;
@Service
@@ -95,6 +95,8 @@
         record.setParams(null);
      } else if (!StringUtil.isJson(params)) {
         throw new SwiperPictureException(1, "跳转参数非JSON格式");
      } else {
         record.setParams(params.trim());
      }
      if (!StringUtil.isNullOrEmpty(jumpType)) {
@@ -193,7 +195,7 @@
      String type = contentType.substring(contentType.indexOf("/") + 1);
      // 文件路径
      String filePath = "/img/swiperPic/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
      String filePath = FilePathEnum.swiper.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
      // 执行上传
      String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
@@ -212,11 +214,36 @@
         COSManager.getInstance().deleteFile(picture);
      }
   }
   @Override
   public void switchState(Long id) throws SwiperPictureException {
      if (id == null) {
         throw new SwiperPictureException(1, "请传递正确参数");
      }
      SwiperPicture resultObj = swiperPictureMapper.selectByPrimaryKey(id);
      if (resultObj == null) {
         throw new SwiperPictureException(1, "此内容已不存在");
      }
      Integer state = resultObj.getState();
      if (state == null || state == 0) {
         state = 1;
      } else {
         state = 0;
      }
      SwiperPicture updateObj = new SwiperPicture();
      updateObj.setId(id);
      updateObj.setState(state);
      updateObj.setJumpNeedLogin(resultObj.isJumpNeedLogin());
      swiperPictureMapper.updateByPrimaryKeySelective(updateObj);
   }
   @Override
   @Transactional(rollbackFor = Exception.class)
   public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException {
      List<SwiperPicture> listSwiper = swiperPictureMapper.queryByListPrimaryKey(list);
      for (SwiperPicture swiperPicture : listSwiper) {
         String src = swiperPicture.getSrc();