ソースを参照

初始化拉手

wangwx 1 年間 前
コミット
0924f82e34

+ 8 - 1
ruoyi-system/src/main/java/com/ruoyi/advertiser/util/CreateCarouselPlanUtil.java

@@ -1,5 +1,6 @@
 package com.ruoyi.advertiser.util;
 
+import cn.hutool.core.util.ArrayUtil;
 import com.ruoyi.advertiser.constant.SubwayConstant;
 import com.ruoyi.advertiser.domain.CarouselPlan;
 import com.ruoyi.advertiser.domain.Material;
@@ -107,6 +108,12 @@ public class CreateCarouselPlanUtil {
         List<CarouselPlanDayPicsDto> dateList = dayDto.getDataList();
         Long[] imageIds = dateList.stream().map(item->item.getAdMaterialUrlDto().getId()).toArray(Long[]::new);
 
+        // 不管有没有图片,都要把1,2,3公益图片放进去
+        Long[] bindingIds = dayDto.getImageBindingIds();
+        if (!ArrayUtil.contains(bindingIds, Long.valueOf(SubwayConstant.AD_PUBLIC_BENEFIT_MATERIAL))){
+            bindingIds = ArrayUtil.insert(bindingIds,0, new Long[]{ Long.valueOf(SubwayConstant.AD_PUBLIC_BENEFIT_MATERIAL) });
+        }
+
         // 存入redis
         CarouselPlanRedisDto adCarouselPlanRedisDto = new CarouselPlanRedisDto();
         adCarouselPlanRedisDto.setAdMaterialsMorning(adMaterialsMorning)
@@ -115,7 +122,7 @@ public class CreateCarouselPlanUtil {
                 .setImageIds(imageIds)
                 .setStationStartDate(dayDto.getStationStartDate())
                 .setStationEndDate(dayDto.getStationEndDate())
-                .setImageBindingIds(dayDto.getImageBindingIds());
+                .setImageBindingIds(bindingIds);
         redisCache.setCacheObject(SubwayConstant.AD_CAROUSEL_PLAN_KEY + carouselPlan.getSubwayId().toString(), adCarouselPlanRedisDto);
 
     }