Jelajahi Sumber

内容池交互 tag多选

wangyunpeng 1 Minggu lalu
induk
melakukan
2c299e1abf

+ 14 - 3
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.java

@@ -30,11 +30,11 @@ public interface ContentPlatformPlanMapperExt {
 
     String getVideoDatastatMaxDt();
 
-    int getVideoCount(@Param("param") VideoContentListParam param, @Param("dt") String dt,
-                      @Param("minScore") Double minScore);
-
     List<String> getVideoCategoryList(@Param("dt") String dt);
 
+    int getApiVideoCount(@Param("param") VideoContentListParam param, @Param("dt") String dt,
+                      @Param("minScore") Double minScore);
+
     List<ContentPlatformVideo> getApiVideoList(@Param("param") VideoContentListParam param,
                                             @Param("dt") String dt,
                                             @Param("datastatDt") String datastatDt,
@@ -46,6 +46,17 @@ public interface ContentPlatformPlanMapperExt {
                                             @Param("pageSize") Integer pageSize,
                                             @Param("sort") String sort);
 
+    int getVideoCount(@Param("param") VideoContentListParam param,
+                      @Param("dt") String dt,
+                      @Param("datastatDt") String datastatDt,
+                      @Param("type") String type,
+                      @Param("channel") String channel,
+                      @Param("strategy") String strategy,
+                      @Param("minScore") Double minScore,
+                      @Param("createAccountId") Long createAccountId,
+                      @Param("excludeVideoTime") Long excludeVideoTime,
+                      @Param("videoTagFilter") String videoTagFilter);
+
     List<ContentPlatformVideo> getVideoList(@Param("param") VideoContentListParam param,
                                             @Param("dt") String dt,
                                             @Param("datastatDt") String datastatDt,

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformApiServiceImpl.java

@@ -93,7 +93,7 @@ public class ContentPlatformApiServiceImpl implements ContentPlatformApiService
         String dt = planMapperExt.getVideoMaxDt();
         String datastatDt = planMapperExt.getVideoDatastatMaxDt();
         VideoContentListParam listParam = new VideoContentListParam();
-        int count = planMapperExt.getVideoCount(listParam, dt, videoMinScore);
+        int count = planMapperExt.getApiVideoCount(listParam, dt, videoMinScore);
         result.setTotalSize(count);
         if (count == 0) {
             return result;

+ 14 - 10
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -31,6 +31,7 @@ import com.tzld.piaoquan.growth.common.model.bo.VideoDetail;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.GhDetail;
 import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
+import com.tzld.piaoquan.growth.common.utils.DateUtils;
 import com.tzld.piaoquan.growth.common.utils.MessageUtil;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
 import lombok.extern.slf4j.Slf4j;
@@ -476,14 +477,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         ContentPlatformAccount user = LoginUserContext.getUser();
         Page<VideoContentItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
         int offset = (param.getPageNum() - 1) * param.getPageSize();
+        // get sql Filter param
         String dt = planMapperExt.getVideoMaxDt();
         String datastatDt = planMapperExt.getVideoDatastatMaxDt();
-        int count = planMapperExt.getVideoCount(param, dt, videoMinScore);
-        result.setTotalSize(count);
-        if (count == 0) {
-            result.setObjs(new ArrayList<>());
-            return result;
-        }
         String sort = getVideoContentListSort(param.getSortType(), param.getSort());
         String type = getVideoContentListType(param.getType());
         String channel = getVideoContentListChannel(param.getSort(), user.getChannel());
@@ -492,6 +488,14 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         String tagFilterSql = getVideoContentListTagFilterSql(param.getTags(), user.getId(), type, user.getChannel());
         // 近期未使用
         Long excludeVideoRecentNotUsed = getVideoExcludeRecentNotUsed(param.getRecentNotUsed());
+
+        int count = planMapperExt.getVideoCount(param, dt, datastatDt, type, channel, strategy,
+                videoMinScore, user.getId(), excludeVideoRecentNotUsed, tagFilterSql);
+        result.setTotalSize(count);
+        if (count == 0) {
+            result.setObjs(new ArrayList<>());
+            return result;
+        }
         List<ContentPlatformVideo> videoList = planMapperExt.getVideoList(param, dt, datastatDt, type, channel, strategy,
                 videoMinScore, user.getId(), excludeVideoRecentNotUsed, tagFilterSql, offset, param.getPageSize(), sort);
         List<VideoContentItemVO> list = buildVideoContentItemVOList(videoList, type, "sum", user.getChannel(), dt, datastatDt);
@@ -514,10 +518,10 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                     item = "videoTag.account_id = " + accountId;
                     break;
                 case "你的用户爱看":
-                    item = "videoTag.type = " + type;
+                    item = "videoTag.type = '" + type + "'";
                     break;
                 case "猜TA想看":
-                    item = "videoTag.channel = " + channel;
+                    item = "videoTag.channel = '" + channel + "'";
                     break;
                 default:
                     item = null;
@@ -541,7 +545,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         if (videoRecentNotUsedEnum == VideoRecentNotUsedEnum.HISTORY) {
             return 0L;
         }
-        return System.currentTimeMillis() - videoRecentNotUsedEnum.getDays() * 24 * 60 * 60 * 1000;
+        return DateUtils.todayBegin().getTime() - videoRecentNotUsedEnum.getDays() * 24 * 60 * 60 * 1000;
     }
 
     private String getVideoContentListType(Integer type) {
@@ -621,7 +625,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 .filter(o -> userChannel.equals(o.getChannel()) && "recommend".equals(o.getStrategy())).collect(Collectors.toMap(
                         ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
         // tag
-        List<ContentPlatformVideoTag> videoTagList = planMapperExt.getVideoTagList(dt, videoIds, user.getId(), type, channel);
+        List<ContentPlatformVideoTag> videoTagList = planMapperExt.getVideoTagList(dt, videoIds, user.getId(), type, userChannel);
         Map<Long, List<ContentPlatformVideoTag>> videoTagMap = videoTagList.stream()
                 .collect(Collectors.groupingBy(ContentPlatformVideoTag::getVideoId));
         List<VideoContentItemVO> result = new ArrayList<>();

+ 37 - 2
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.xml

@@ -100,7 +100,7 @@
         from content_platform_video_datastat_agg
     </select>
 
-    <select id="getVideoCount" resultType="java.lang.Integer">
+    <select id="getApiVideoCount" resultType="java.lang.Integer">
         select count(1)
         from content_platform_video_agg
         where dt = #{dt} and status = 1 and score > #{minScore}
@@ -129,6 +129,41 @@
         limit #{offset}, #{pageSize}
     </select>
 
+    <select id="getVideoCount" resultType="java.lang.Integer">
+        select count(1)
+        from content_platform_video_agg video
+        <if test="excludeVideoTime != null">
+            left join content_platform_gzh_plan_video gzhPlanVideo
+            on gzhPlanVideo.video_id = video.video_id and gzhPlanVideo.create_account_id = #{createAccountId}
+            <if test="excludeVideoTime != 0">
+                and gzhPlanVideo.create_timestamp > #{excludeVideoTime}
+            </if>
+            left join content_platform_qw_plan_video qwPlanVideo
+            on qwPlanVideo.video_id = video.video_id and qwPlanVideo.create_account_id = #{createAccountId}
+            <if test="excludeVideoTime != 0">
+                and qwPlanVideo.create_timestamp > #{excludeVideoTime}
+            </if>
+        </if>
+        <if test="param.tags != null and param.tags.size() > 0">
+            join content_platform_video_tag videoTag
+            on videoTag.dt = video.dt and videoTag.video_id = video.video_id and ${videoTagFilter}
+        </if>
+        where video.dt = #{dt} and video.status = 1 and video.score > #{minScore}
+        and (video.source = 1 or video.video_id in (select video_id
+                                                    from content_platform_video_account_rel
+                                                    where dt = #{dt} and account_id = #{createAccountId}))
+        <if test="param.title!= null and param.title!= ''">
+            and video.title like concat('%', #{param.title}, '%')
+        </if>
+        <if test="param.category!= null and param.category!= ''">
+            and video.category = #{param.category}
+        </if>
+        <if test="excludeVideoTime != null">
+            and gzhPlanVideo.video_id is null
+            and qwPlanVideo.video_id is null
+        </if>
+    </select>
+
     <select id="getVideoList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
         select video.*
         from content_platform_video_agg video
@@ -475,7 +510,7 @@
         <foreach collection="videoIds" item="item" open="(" close=")" separator=",">
             #{item}
         </foreach>
-        and (platform = 1 or account_id = #{accountId} or type = #{type} or channel = #{channel})
+        and (platform = 'platform' or account_id = #{accountId} or type = #{type} or channel = #{channel})
     </select>
 
     <delete id="deleteContentPlatformVideoTag">