admin
2020-11-28 dc5be7d38446f70e6ff86df311119c32b41fe7f8
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java
@@ -12,6 +12,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -21,14 +22,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 +80,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 +92,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 +116,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);
   }
   
   
@@ -151,7 +175,7 @@
   
   
   @Override
   public void updateSort(Integer moveType, Long id) throws HelpClassException {
   public void updateSort(Integer moveType, Long id, SystemEnum system) throws HelpClassException {
      
      if (id == null || moveType == null) {
         throw new HelpClassException(1, "传递参数不能为空");
@@ -162,7 +186,7 @@
         throw new HelpClassException(1, "更新数据已不存在");
      }
      
      HelpClass changeObjct = helpClassMapper.getChangeOrder(moveType, helpClass.getSort());
      HelpClass changeObjct = helpClassMapper.getChangeOrder(moveType, helpClass.getSort(),system);
      
      if (changeObjct == null) {
         throw new HelpClassException(1, "已经是最边缘位置");
@@ -194,7 +218,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();
@@ -214,24 +238,24 @@
   
   
   @Override
   public List<HelpClass> query(int start, int count, String key, Integer state)
   public List<HelpClass> query(int start, int count, String key, Integer state, SystemEnum system)
         throws HelpClassException {
      return helpClassMapper.listQuery(start, count, key, state);
      return helpClassMapper.listQuery(start, count, key, state,system);
   }
   @Override
   public long countQuery(String key, Integer state) {
      return helpClassMapper.countQuery(key, state);
   public long countQuery(String key, Integer state, SystemEnum system) {
      return helpClassMapper.countQuery(key, state,system);
   }
   
   @Override
   public List<HelpClass> getClassByState(Integer state) throws HelpClassException {
      return helpClassMapper.getClassByState(state);
   public List<HelpClass> getClassByState(Integer state, SystemEnum system) throws HelpClassException {
      return helpClassMapper.getClassByState(state,system);
   }
   
   @Override
   public List<HelpClass> getProvidedClass() throws HelpClassException {
      return helpClassMapper.getProvidedClass();
   public List<HelpClass> getProvidedClass(SystemEnum system) throws HelpClassException {
      return helpClassMapper.getProvidedClass(system);
   }