Browse Source

检查视频状态

wangyunpeng 2 months ago
parent
commit
9cdadd3099

+ 2 - 2
api-module/src/main/java/com/tzld/piaoquan/api/component/TouLiuHttpClient.java

@@ -8,9 +8,7 @@ import com.tzld.piaoquan.api.model.bo.VideoDetail;
 import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
-import reactor.core.publisher.Mono;
 
 import java.util.HashMap;
 import java.util.List;
@@ -76,6 +74,8 @@ public class TouLiuHttpClient {
                 videoDetail.setId(videoId);
                 videoDetail.setCover(shareImgPath);
                 videoDetail.setTitle(title);
+                videoDetail.setAuditStatus(jsonObject.getInteger("auditStatus"));
+                videoDetail.setRecommendStatus(jsonObject.getInteger("recommendStatus"));
                 map.put(videoId, videoDetail);
             }
         } catch (Exception e) {

+ 7 - 0
api-module/src/main/java/com/tzld/piaoquan/api/controller/contentplatform/ContentPlatformPlanController.java

@@ -80,4 +80,11 @@ public class ContentPlatformPlanController {
         videoJob.syncContentPlatformVideoJob(null);
         return CommonResponse.success();
     }
+
+    @ApiOperation(value = "检查视频状态")
+    @PostMapping("/checkContentPlatformVideoStatusJob")
+    public CommonResponse<Void> checkContentPlatformVideoStatusJob(@RequestBody QwPlanSaveParam param) {
+        videoJob.checkContentPlatformVideoStatusJob(null);
+        return CommonResponse.success();
+    }
 }

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

@@ -53,4 +53,6 @@ public interface ContentPlatformPlanMapperExt {
     void insertQwPlanReturnId(@Param("record") ContentPlatformQwPlan qwPlan);
 
     List<ContentPlatformGzhPlanVideo> getGzhPlanVideoListByCooperateAccountId(@Param("ghId") String ghId);
+
+    void updateVideoStatus(@Param("videoId") Long videoId, @Param("now") Long now);
 }

+ 36 - 0
api-module/src/main/java/com/tzld/piaoquan/api/job/ContentPlatformVideoJob.java

@@ -1,8 +1,11 @@
 package com.tzld.piaoquan.api.job;
 
 import com.aliyun.odps.data.Record;
+import com.google.common.collect.Lists;
+import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformVideoMapper;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
+import com.tzld.piaoquan.api.model.bo.VideoDetail;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoExample;
 import com.tzld.piaoquan.growth.common.utils.DateUtil;
@@ -15,7 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Component
@@ -27,6 +33,9 @@ public class ContentPlatformVideoJob {
     @Autowired
     private ContentPlatformVideoMapper videoMapper;
 
+    @Autowired
+    private TouLiuHttpClient touLiuHttpClient;
+
     @XxlJob("syncContentPlatformVideoJob")
     public ReturnT<String> syncContentPlatformVideoJob(String param) {
         String dt = DateUtil.getBeforeDayDateString("yyyyMMdd");
@@ -67,6 +76,33 @@ public class ContentPlatformVideoJob {
         example.createCriteria().andDtEqualTo(dt);
         return videoMapper.countByExample(example);
     }
+    @XxlJob("checkContentPlatformVideoStatusJob")
+    public ReturnT<String> checkContentPlatformVideoStatusJob(String param) {
+        String dt = planMapperExt.getVideoMaxDt();
+        List<ContentPlatformVideo> videoList = getVideoListByDt(dt);
+        Long now = System.currentTimeMillis();
+        List<Long> videoIds = videoList.stream().map(ContentPlatformVideo::getVideoId).collect(Collectors.toList());
+        Map<Long, VideoDetail> videoDetailMap = new HashMap<>();
+        for (List<Long> partitionVideoIds : Lists.partition(videoIds, 20)) {
+            videoDetailMap.putAll(touLiuHttpClient.getVideoDetailRequest(partitionVideoIds));
+        }
+        for (ContentPlatformVideo video : videoList) {
+            VideoDetail videoDetail = videoDetailMap.get(video.getVideoId());
+            if (videoDetail == null) {
+                continue;
+            }
+            if (videoDetail.getAuditStatus() != 5 || videoDetail.getRecommendStatus() != -6) {
+                planMapperExt.updateVideoStatus(video.getVideoId(), now);
+            }
+        }
+        return ReturnT.SUCCESS;
+    }
+
+    private List<ContentPlatformVideo> getVideoListByDt(String dt) {
+        ContentPlatformVideoExample example = new ContentPlatformVideoExample();
+        example.createCriteria().andDtEqualTo(dt).andStatusEqualTo(1);
+        return videoMapper.selectByExample(example);
+    }
 
 }
 

+ 6 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/bo/VideoDetail.java

@@ -10,4 +10,10 @@ public class VideoDetail {
     private String cover;
 
     private String title;
+
+    // 审核状态  1 审核中,2 不通过 3 待修改,4 自己可见 5 通过
+    private Integer auditStatus;
+
+    // 推荐状态(0:不可搜,-6:待推荐,1:普通推荐,10:编辑推荐,-7:可搜索)
+    private Integer recommendStatus;
 }

+ 22 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformVideo.java

@@ -15,8 +15,12 @@ public class ContentPlatformVideo {
 
     private Double score;
 
+    private Integer status;
+
     private Long createTimestamp;
 
+    private Long updateTimestamp;
+
     public Long getId() {
         return id;
     }
@@ -73,6 +77,14 @@ public class ContentPlatformVideo {
         this.score = score;
     }
 
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
     public Long getCreateTimestamp() {
         return createTimestamp;
     }
@@ -81,6 +93,14 @@ public class ContentPlatformVideo {
         this.createTimestamp = createTimestamp;
     }
 
+    public Long getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+
+    public void setUpdateTimestamp(Long updateTimestamp) {
+        this.updateTimestamp = updateTimestamp;
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
@@ -94,7 +114,9 @@ public class ContentPlatformVideo {
         sb.append(", title=").append(title);
         sb.append(", video=").append(video);
         sb.append(", score=").append(score);
+        sb.append(", status=").append(status);
         sb.append(", createTimestamp=").append(createTimestamp);
+        sb.append(", updateTimestamp=").append(updateTimestamp);
         sb.append("]");
         return sb.toString();
     }

+ 120 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformVideoExample.java

@@ -575,6 +575,66 @@ public class ContentPlatformVideoExample {
             return (Criteria) this;
         }
 
+        public Criteria andStatusIsNull() {
+            addCriterion("`status` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIsNotNull() {
+            addCriterion("`status` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusEqualTo(Integer value) {
+            addCriterion("`status` =", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotEqualTo(Integer value) {
+            addCriterion("`status` <>", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThan(Integer value) {
+            addCriterion("`status` >", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
+            addCriterion("`status` >=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThan(Integer value) {
+            addCriterion("`status` <", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThanOrEqualTo(Integer value) {
+            addCriterion("`status` <=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIn(List<Integer> values) {
+            addCriterion("`status` in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotIn(List<Integer> values) {
+            addCriterion("`status` not in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusBetween(Integer value1, Integer value2) {
+            addCriterion("`status` between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotBetween(Integer value1, Integer value2) {
+            addCriterion("`status` not between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
         public Criteria andCreateTimestampIsNull() {
             addCriterion("create_timestamp is null");
             return (Criteria) this;
@@ -634,6 +694,66 @@ public class ContentPlatformVideoExample {
             addCriterion("create_timestamp not between", value1, value2, "createTimestamp");
             return (Criteria) this;
         }
+
+        public Criteria andUpdateTimestampIsNull() {
+            addCriterion("update_timestamp is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampIsNotNull() {
+            addCriterion("update_timestamp is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampEqualTo(Long value) {
+            addCriterion("update_timestamp =", value, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampNotEqualTo(Long value) {
+            addCriterion("update_timestamp <>", value, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampGreaterThan(Long value) {
+            addCriterion("update_timestamp >", value, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampGreaterThanOrEqualTo(Long value) {
+            addCriterion("update_timestamp >=", value, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampLessThan(Long value) {
+            addCriterion("update_timestamp <", value, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampLessThanOrEqualTo(Long value) {
+            addCriterion("update_timestamp <=", value, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampIn(List<Long> values) {
+            addCriterion("update_timestamp in", values, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampNotIn(List<Long> values) {
+            addCriterion("update_timestamp not in", values, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampBetween(Long value1, Long value2) {
+            addCriterion("update_timestamp between", value1, value2, "updateTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimestampNotBetween(Long value1, Long value2) {
+            addCriterion("update_timestamp not between", value1, value2, "updateTimestamp");
+            return (Criteria) this;
+        }
     }
 
     public static class Criteria extends GeneratedCriteria {

+ 37 - 5
api-module/src/main/resources/mapper/contentplatform/ContentPlatformVideoMapper.xml

@@ -9,7 +9,9 @@
     <result column="title" jdbcType="VARCHAR" property="title" />
     <result column="video" jdbcType="VARCHAR" property="video" />
     <result column="score" jdbcType="DOUBLE" property="score" />
+    <result column="status" jdbcType="INTEGER" property="status" />
     <result column="create_timestamp" jdbcType="BIGINT" property="createTimestamp" />
+    <result column="update_timestamp" jdbcType="BIGINT" property="updateTimestamp" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -70,7 +72,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, dt, video_id, category, title, video, score, create_timestamp
+    id, dt, video_id, category, title, video, score, `status`, create_timestamp, update_timestamp
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoExample" resultMap="BaseResultMap">
     select
@@ -108,10 +110,12 @@
   <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
     insert into content_platform_video (id, dt, video_id, 
       category, title, video, 
-      score, create_timestamp)
+      score, `status`, create_timestamp, 
+      update_timestamp)
     values (#{id,jdbcType=BIGINT}, #{dt,jdbcType=VARCHAR}, #{videoId,jdbcType=BIGINT}, 
       #{category,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{video,jdbcType=VARCHAR}, 
-      #{score,jdbcType=DOUBLE}, #{createTimestamp,jdbcType=BIGINT})
+      #{score,jdbcType=DOUBLE}, #{status,jdbcType=INTEGER}, #{createTimestamp,jdbcType=BIGINT}, 
+      #{updateTimestamp,jdbcType=BIGINT})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
     insert into content_platform_video
@@ -137,9 +141,15 @@
       <if test="score != null">
         score,
       </if>
+      <if test="status != null">
+        `status`,
+      </if>
       <if test="createTimestamp != null">
         create_timestamp,
       </if>
+      <if test="updateTimestamp != null">
+        update_timestamp,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -163,9 +173,15 @@
       <if test="score != null">
         #{score,jdbcType=DOUBLE},
       </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
       <if test="createTimestamp != null">
         #{createTimestamp,jdbcType=BIGINT},
       </if>
+      <if test="updateTimestamp != null">
+        #{updateTimestamp,jdbcType=BIGINT},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoExample" resultType="java.lang.Long">
@@ -198,9 +214,15 @@
       <if test="record.score != null">
         score = #{record.score,jdbcType=DOUBLE},
       </if>
+      <if test="record.status != null">
+        `status` = #{record.status,jdbcType=INTEGER},
+      </if>
       <if test="record.createTimestamp != null">
         create_timestamp = #{record.createTimestamp,jdbcType=BIGINT},
       </if>
+      <if test="record.updateTimestamp != null">
+        update_timestamp = #{record.updateTimestamp,jdbcType=BIGINT},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -215,7 +237,9 @@
       title = #{record.title,jdbcType=VARCHAR},
       video = #{record.video,jdbcType=VARCHAR},
       score = #{record.score,jdbcType=DOUBLE},
-      create_timestamp = #{record.createTimestamp,jdbcType=BIGINT}
+      `status` = #{record.status,jdbcType=INTEGER},
+      create_timestamp = #{record.createTimestamp,jdbcType=BIGINT},
+      update_timestamp = #{record.updateTimestamp,jdbcType=BIGINT}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -241,9 +265,15 @@
       <if test="score != null">
         score = #{score,jdbcType=DOUBLE},
       </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
       <if test="createTimestamp != null">
         create_timestamp = #{createTimestamp,jdbcType=BIGINT},
       </if>
+      <if test="updateTimestamp != null">
+        update_timestamp = #{updateTimestamp,jdbcType=BIGINT},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -255,7 +285,9 @@
       title = #{title,jdbcType=VARCHAR},
       video = #{video,jdbcType=VARCHAR},
       score = #{score,jdbcType=DOUBLE},
-      create_timestamp = #{createTimestamp,jdbcType=BIGINT}
+      `status` = #{status,jdbcType=INTEGER},
+      create_timestamp = #{createTimestamp,jdbcType=BIGINT},
+      update_timestamp = #{updateTimestamp,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </update>
 </mapper>

+ 10 - 3
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.xml

@@ -77,7 +77,7 @@
     <select id="getVideoCount" resultType="java.lang.Integer">
         select count(1)
         from content_platform_video
-        where dt = #{dt}
+        where dt = #{dt} and status = 1
         <if test="param.title!= null and param.title!= ''">
             and title like concat('%', #{param.title}, '%')
         </if>
@@ -89,7 +89,7 @@
     <select id="getVideoList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
         select *
         from content_platform_video
-        where dt = #{dt}
+        where dt = #{dt} and status = 1
         <if test="param.title!= null and param.title!= ''">
             and title like concat('%', #{param.title}, '%')
         </if>
@@ -103,7 +103,7 @@
     <select id="getVideoCategoryList" resultType="java.lang.String">
         select distinct category
         from content_platform_video
-        where dt = #{dt}
+        where dt = #{dt} and status = 1
     </select>
 
     <insert id="batchInsertContentPlatformVideo">
@@ -176,4 +176,11 @@
           and cpgp.scene = 0
     </select>
 
+    <update id="updateVideoStatus">
+        update content_platform_video
+        set status = 0,
+            update_timestamp = #{now}
+        where video_id = #{videoId}
+    </update>
+
 </mapper>