admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java
@@ -21,14 +21,11 @@
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.bus.help.HelpClass;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
import com.yeshi.fanli.exception.config.HelpClassException;
import com.yeshi.fanli.exception.homemodule.FloatADException;
import com.yeshi.fanli.service.inter.help.HelpClassService;
import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.StringUtil;
@Service
@@ -82,7 +79,7 @@
         InputStream inputStream = file.getInputStream();
         String contentType = file.getContentType();
         String type = contentType.substring(contentType.indexOf("/") + 1);
         String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
         String filePath =FilePathEnum.helpClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
         picture = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
      }
            
@@ -94,13 +91,14 @@
      if (record.getId() == null) {
         int maxOrder = helpClassMapper.getMaxOrder();
         record.setSort(maxOrder + 1);
         record.setPicture(picture);
         record.setCreateTime(new Date());
         helpClassMapper.insertSelective(record);
      } else {
         // 修改
         HelpClass resultObj = helpClassMapper.selectByPrimaryKey(record.getId());
         if (resultObj == null)
            throw new FloatADException(1, "修改内容已不存在");
            throw new HelpClassException(1, "修改内容已不存在");
         
         if (picture != null && picture.trim().length() > 0) {
            String pictureOld = resultObj.getPicture();
@@ -117,6 +115,31 @@
         record.setCreateTime(resultObj.getCreateTime());
         helpClassMapper.updateByPrimaryKey(record);
      }
   }
   @Override
   public void switchState(Long id) throws HelpClassException {
      if (id == null) {
         throw new HelpClassException(1, "请传递正确参数");
      }
      HelpClass resultObj = helpClassMapper.selectByPrimaryKey(id);
      if (resultObj == null) {
         throw new HelpClassException(1, "此内容已不存在");
      }
      Integer state = resultObj.getShowState();
      if (state == null || state == 0) {
         state = 1;
      } else {
         state = 0;
      }
      HelpClass updateObj = new HelpClass();
      updateObj.setId(id);
      updateObj.setShowState(state);
      helpClassMapper.updateByPrimaryKeySelective(updateObj);
   }
   
   
@@ -194,7 +217,7 @@
      String contentType = file.getContentType();
      String type = contentType.substring(contentType.indexOf("/") + 1);
      
      String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
      String filePath =FilePathEnum.helpClass.getPath()+ UUID.randomUUID().toString().replace("-", "") + "." + type;
      
      /*  修改图片时,先删除已存在图片  */
      String picture = helpClass.getPicture();