yujian
2020-01-03 c9cbdfa41d645d42eeaa7e06d550d4ef8ac328e7
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java
@@ -8,18 +8,20 @@
import java.util.UUID;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.mybatis.homemodule.FloatADMapper;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.FloatADException;
import com.yeshi.fanli.exception.homemodule.FloatADException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.StringUtil;
@Service
@@ -46,10 +48,16 @@
      }
      
      String params = record.getParams();
      if ((params != null && params.trim().length() == 0) || "null".equalsIgnoreCase(params) ) {
      if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params) ) {
         record.setParams(null);
      } else if (!StringUtil.isJson(params)) {
         throw new FloatADException(1, "跳转参数非JSON格式");
      }
      
      FloatADTypeEnum typeEnum = record.getTypeEnum();
      if (typeEnum == null)
         throw new FloatADException(1, "类型不能为空");
      if (!StringUtil.isNullOrEmpty(jumpType)) {
         List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType);
         if (listByType !=null && listByType.size() > 0) {
@@ -80,6 +88,12 @@
      String picture = null;
      if (file != null) {
         picture = uploadPicture(file);
      }
      // 适用类型 : 0通用  1新人
      Integer type = record.getType();
      if (type == null) {
         record.setType(0);
      }
      
      Long id = record.getId();
@@ -133,7 +147,7 @@
      String type = contentType.substring(contentType.indexOf("/") + 1);
   
      // 文件路径
      String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
      String filePath= FilePathEnum.floatAD.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
      // 执行上传
      String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
      
@@ -152,7 +166,7 @@
   }
   
   @Override
   @Transactional
   @Transactional(rollbackFor=Exception.class)
   public void updateOrder(Long id, Integer moveType) throws FloatADException {
      
      if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
@@ -185,7 +199,7 @@
   }
   
   @Override
   @Transactional
   @Transactional(rollbackFor=Exception.class)
   public int deleteByPrimaryKeyList(List<Long> list) throws Exception{
      
      List<FloatAD> listSwiper = floatADMapper.ListByPrimaryKey(list);
@@ -212,6 +226,11 @@
      }
      
      for (FloatAD floatAD : listQuery) {
         FloatADTypeEnum typeEnum = floatAD.getTypeEnum();
         if (typeEnum != null) {
            floatAD.setTypeName(typeEnum.getDesc());
         }
         
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
         Date startTime = floatAD.getStartTime();
@@ -256,8 +275,8 @@
   }
   @Override
   public FloatAD getEffectiveFloatAD(String position) {
      FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position);
   public FloatAD getEffectiveFloatAD(String position, Integer type) {
      FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position, type);
      if (floatAD != null) {
         JumpDetailV2 jumpDetail = floatAD.getJumpDetail();
         
@@ -275,5 +294,15 @@
      return floatAD;
   }
   
   @Override
   public List<FloatAD> getValidCommonByPosition(String position) {
      return floatADMapper.getValidFloatAD(position, 1);
   }
   @Override
   public List<FloatAD> getValidByPosition(String position) {
      return floatADMapper.getValidFloatAD(position, null);
   }
}