admin
2020-08-26 26f7accb815f55f18f8eedfca4324700a96884ec
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java
@@ -12,6 +12,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -68,6 +69,8 @@
         record.setParams(null);
      } else if (!StringUtil.isJson(params)) {
         throw new FloatADException(1, "跳转参数非JSON格式");
      } else {
         record.setParams(params.trim());
      }
      
      FloatADTypeEnum typeEnum = record.getTypeEnum();
@@ -114,7 +117,7 @@
      
      Long id = record.getId();
      if (id == null) {
         int maxOrder = floatADMapper.getMaxOrderByPosition(position);
         int maxOrder = floatADMapper.getMaxOrderByPosition(position,record.getSystem());
         record.setPicture(picture);
         Integer state = record.getState();
         if (state == null) {
@@ -172,7 +175,6 @@
   /**
    * 删除图片-不更新数据库
    * @param record
    * @throws Exception
    */
   public void removePicture(String picture) throws Exception {
@@ -198,7 +200,7 @@
      String position = resultObj.getPosition();
      
      // 获取交换对象
      FloatAD exchangeObject = floatADMapper.getByAdjoinOrder(position, order, moveType);
      FloatAD exchangeObject = floatADMapper.getByAdjoinOrder(position, order, moveType,resultObj.getSystem());
      if (exchangeObject == null) {
         if (moveType == 1) {
            throw new FloatADException(1, "在相同使用地方中优先级已经最低了");
@@ -213,6 +215,31 @@
      floatADMapper.updateByPrimaryKey(resultObj);
      floatADMapper.updateByPrimaryKey(exchangeObject);
   }
   @Override
   public void switchState(Long id) throws FloatADException {
      if (id == null) {
         throw new FloatADException(1, "请传递正确参数");
      }
      FloatAD resultObj = floatADMapper.selectByPrimaryKey(id);
      if (resultObj == null) {
         throw new FloatADException(1, "此内容已不存在");
      }
      Integer state = resultObj.getState();
      if (state == null || state == 0) {
         state = 1;
      } else {
         state = 0;
      }
      FloatAD updateObj = new FloatAD();
      updateObj.setId(id);
      updateObj.setState(state);
      floatADMapper.updateByPrimaryKeySelective(updateObj);
   }
   
   @Override
   @Transactional(rollbackFor=Exception.class)
@@ -240,9 +267,9 @@
   
   @Override
   public List<FloatAD> listQuery(long start, int count, String key, Integer state) throws FloatADException {
   public List<FloatAD> listQuery(long start, int count, String key, Integer state,SystemEnum system) throws FloatADException {
      
      List<FloatAD> listQuery = floatADMapper.listQuery(start, count, key, state);
      List<FloatAD> listQuery = floatADMapper.listQuery(start, count, key, state,system);
      if (listQuery == null || listQuery.size() == 0) {
         return listQuery;
      }
@@ -292,14 +319,14 @@
   @Override
   public long countQuery(String key, Integer state) {
      return floatADMapper.countQuery(key, state);
   public long countQuery(String key, Integer state,SystemEnum system) {
      return floatADMapper.countQuery(key, state,system);
   }
   @Cacheable(value = "configCache", key = "'getEffectiveFloatAD-'+#position+'-'+#type")
   @Override
   public FloatAD getEffectiveFloatAD(String position, Integer type) {
      FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position, type);
   public FloatAD getEffectiveFloatAD(String position, Integer type,SystemEnum system) {
      FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position, type,system);
      if (floatAD != null) {
         JumpDetailV2 jumpDetail = floatAD.getJumpDetail();
         
@@ -365,13 +392,12 @@
      }
   }
   
   @Cacheable(value = "configCache", key = "'getValidFloatADCache-'+#position+'-'+#type+'-'+#platform+'-'+#versionCode")
   @Cacheable(value = "configCache", key = "'getValidFloatADCache-'+#position+'-'+#type+'-'+#platform+'-'+#versionCode+'-'+#system")
   @Override
   public List<FloatAD> getValidFloatADCache(String position, Integer type, String platform, Integer versionCode) {
      List<FloatAD> list = floatADMapper.getValidFloatAD(position, type);
   public List<FloatAD> getValidFloatADCache(String position, Integer type, String platform, Integer versionCode, SystemEnum system) {
      List<FloatAD> list = floatADMapper.getValidFloatAD(position, type,system);
      // 过滤
      filterFloatAD(list, platform, versionCode);
      filterFloatAD(list, platform, versionCode,system);
      return list;
   }
   
@@ -382,10 +408,10 @@
    * @param platform
    * @param versionCode
    */
   private void filterFloatAD(List<FloatAD> list, String platform, int versionCode) {
   private void filterFloatAD(List<FloatAD> list, String platform, int versionCode, SystemEnum system) {
      if (list == null || list.size() == 0)
         return;
      AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
      AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode,system);
      if (app == null) {
         list.clear();
         return;