Parcourir la source

小程序投流人群包空值处理:demand 表 crowd_segment 字段存在 NULL/空串/'-'/'null' 四种空占位,统一映射成「泛人群」展示;过滤时反向匹配,选「泛人群」走 IS NULL OR = '' OR = '-' OR = 'null' 的或条件,选具体人群包仍走等值过滤。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
刘立冬 il y a 18 heures
Parent
commit
f65e92076f

+ 18 - 4
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformDemandVideoMapperExt.xml

@@ -135,7 +135,14 @@
             AND match_method = #{matchMethod}
         </if>
         <if test="crowdPackage != null and crowdPackage != ''">
-            AND crowd_segment = #{crowdPackage}
+            <choose>
+                <when test='crowdPackage == "泛人群"'>
+                    AND (crowd_segment IS NULL OR crowd_segment = '' OR crowd_segment = '-' OR crowd_segment = 'null')
+                </when>
+                <otherwise>
+                    AND crowd_segment = #{crowdPackage}
+                </otherwise>
+            </choose>
         </if>
         <if test="excludeSelfTitle">
             AND (title IS NULL OR demand_content_title IS NULL OR title &lt;&gt; demand_content_title)
@@ -145,14 +152,21 @@
     </select>
 
     <select id="selectDistinctCrowdPackages" resultType="java.lang.String">
-        SELECT DISTINCT crowd_segment
+        SELECT DISTINCT
+            CASE
+                WHEN crowd_segment IS NULL
+                  OR crowd_segment = ''
+                  OR crowd_segment = '-'
+                  OR crowd_segment = 'null'
+                THEN '泛人群'
+                ELSE crowd_segment
+            END AS cp
         FROM content_platform_demand_video
         WHERE dt = #{dt} AND status = 1
-          AND crowd_segment IS NOT NULL AND crowd_segment &lt;&gt; '' AND crowd_segment &lt;&gt; '-'
         <if test="channelName != null and channelName != ''">
             AND channel_name = #{channelName}
         </if>
-        ORDER BY crowd_segment
+        ORDER BY cp
     </select>
 
     <select id="selectActiveVideos" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo">