wangyunpeng 2 hónapja
szülő
commit
81626b04bf

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

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.api.controller.contentplatform;
 
+import com.tzld.piaoquan.api.job.ContentPlatformVideoJob;
 import com.tzld.piaoquan.api.model.param.contentplatform.*;
 import com.tzld.piaoquan.api.model.vo.contentplatform.GzhPlanItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.QwPlanItemVO;
@@ -21,6 +22,9 @@ public class ContentPlatformPlanController {
     @Autowired
     ContentPlatformPlanService planService;
 
+    @Autowired
+    private ContentPlatformVideoJob videoJob;
+
     @ApiOperation(value = "公众号计划列表")
     @PostMapping("/gzh/list")
     public CommonResponse<Page<GzhPlanItemVO>> gzhPlanList(@RequestBody GzhPlanListParam param) {
@@ -64,4 +68,11 @@ public class ContentPlatformPlanController {
         planService.qwPlanSave(param);
         return CommonResponse.success();
     }
+
+    @ApiOperation(value = "同步每日top1000视频")
+    @PostMapping("/syncContentPlatformVideoJob")
+    public CommonResponse<Void> syncContentPlatformVideoJob(@RequestBody QwPlanSaveParam param) {
+        videoJob.syncContentPlatformVideoJob(null);
+        return CommonResponse.success();
+    }
 }

+ 1 - 2
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ContentPlatformQwPlanMapper.java

@@ -2,9 +2,8 @@ package com.tzld.piaoquan.api.dao.mapper.contentplatform;
 
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlanExample;
-import org.apache.ibatis.annotations.Param;
-
 import java.util.List;
+import org.apache.ibatis.annotations.Param;
 
 public interface ContentPlatformQwPlanMapper {
     long countByExample(ContentPlatformQwPlanExample example);

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

@@ -49,4 +49,5 @@ public interface ContentPlatformPlanMapperExt {
                                               @Param("pageSize") Integer pageSize);
     void batchInsertQwPlan(@Param("records") List<ContentPlatformQwPlan> saveList);
 
+    void insertQwPlanReturnId(@Param("record") ContentPlatformQwPlan qwPlan);
 }

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

@@ -3,8 +3,6 @@ package com.tzld.piaoquan.api.model.po.contentplatform;
 public class ContentPlatformQwPlan {
     private Long id;
 
-    private Integer publishStage;
-
     private Integer type;
 
     private Integer scene;
@@ -27,14 +25,6 @@ public class ContentPlatformQwPlan {
         this.id = id;
     }
 
-    public Integer getPublishStage() {
-        return publishStage;
-    }
-
-    public void setPublishStage(Integer publishStage) {
-        this.publishStage = publishStage;
-    }
-
     public Integer getType() {
         return type;
     }
@@ -98,7 +88,6 @@ public class ContentPlatformQwPlan {
         sb.append(" [");
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
-        sb.append(", publishStage=").append(publishStage);
         sb.append(", type=").append(type);
         sb.append(", scene=").append(scene);
         sb.append(", pageUrl=").append(pageUrl);

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

@@ -175,66 +175,6 @@ public class ContentPlatformQwPlanExample {
             return (Criteria) this;
         }
 
-        public Criteria andPublishStageIsNull() {
-            addCriterion("publish_stage is null");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageIsNotNull() {
-            addCriterion("publish_stage is not null");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageEqualTo(Integer value) {
-            addCriterion("publish_stage =", value, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageNotEqualTo(Integer value) {
-            addCriterion("publish_stage <>", value, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageGreaterThan(Integer value) {
-            addCriterion("publish_stage >", value, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageGreaterThanOrEqualTo(Integer value) {
-            addCriterion("publish_stage >=", value, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageLessThan(Integer value) {
-            addCriterion("publish_stage <", value, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageLessThanOrEqualTo(Integer value) {
-            addCriterion("publish_stage <=", value, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageIn(List<Integer> values) {
-            addCriterion("publish_stage in", values, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageNotIn(List<Integer> values) {
-            addCriterion("publish_stage not in", values, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageBetween(Integer value1, Integer value2) {
-            addCriterion("publish_stage between", value1, value2, "publishStage");
-            return (Criteria) this;
-        }
-
-        public Criteria andPublishStageNotBetween(Integer value1, Integer value2) {
-            addCriterion("publish_stage not between", value1, value2, "publishStage");
-            return (Criteria) this;
-        }
-
         public Criteria andTypeIsNull() {
             addCriterion("`type` is null");
             return (Criteria) this;

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

@@ -156,7 +156,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         List<ContentPlatformGzhPlanVideo> existsVideo = getGzhVideoByPlanId(id);
         List<Long> existsVideoIds = existsVideo.stream().map(ContentPlatformGzhPlanVideo::getVideoId).collect(Collectors.toList());
         Map<Long, ContentPlatformGzhPlanVideo> existsVideoMap = existsVideo.stream()
-               .collect(Collectors.toMap(ContentPlatformGzhPlanVideo::getVideoId, item -> item));
+                .collect(Collectors.toMap(ContentPlatformGzhPlanVideo::getVideoId, item -> item));
         for (ContentPlatformGzhPlanVideo item : existsVideo) {
             if (!videoIds.contains(item.getVideoId())) {
                 gzhPlanVideoMapper.deleteByPrimaryKey(item.getId());
@@ -321,7 +321,6 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     public void qwPlanSave(QwPlanSaveParam param) {
         ContentPlatformAccount loginUser = LoginUserContext.getUser();
         Long now = System.currentTimeMillis();
-        List<ContentPlatformQwPlan> saveList = new ArrayList<>();
         for (QwPlanSaveVideoParam videoParam : param.getVideoList()) {
             ContentPlatformQwPlan qwPlan = new ContentPlatformQwPlan();
             qwPlan.setType(param.getType());
@@ -333,9 +332,22 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             qwPlan.setRootSourceId(rootSourceId);
             qwPlan.setCreateAccountId(loginUser.getId());
             qwPlan.setCreateTimestamp(now);
-            saveList.add(qwPlan);
+            planMapperExt.insertQwPlanReturnId(qwPlan);
+            // 保存视频内容
+            saveQwPlanVideo(videoParam, qwPlan.getId(), loginUser.getId());
         }
-        planMapperExt.batchInsertQwPlan(saveList);
+    }
+
+    private void saveQwPlanVideo(QwPlanSaveVideoParam videoParam, Long planId, Long loginAccountId) {
+        ContentPlatformQwPlanVideo item = new ContentPlatformQwPlanVideo();
+        item.setPlanId(planId);
+        item.setVideoId(videoParam.getVideoId());
+        item.setTitle(videoParam.getTitle());
+        item.setCover(videoParam.getCover());
+        item.setVideo(videoParam.getVideo());
+        item.setCreateAccountId(loginAccountId);
+        item.setCreateTimestamp(System.currentTimeMillis());
+        qwPlanVideoMapper.insertSelective(item);
     }
 
 }

+ 8 - 25
api-module/src/main/resources/mapper/contentplatform/ContentPlatformQwPlanMapper.xml

@@ -3,7 +3,6 @@
 <mapper namespace="com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwPlanMapper">
   <resultMap id="BaseResultMap" type="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
     <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="publish_stage" jdbcType="INTEGER" property="publishStage" />
     <result column="type" jdbcType="INTEGER" property="type" />
     <result column="scene" jdbcType="INTEGER" property="scene" />
     <result column="page_url" jdbcType="VARCHAR" property="pageUrl" />
@@ -71,7 +70,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, publish_stage, `type`, scene, page_url, root_source_id, create_account_id, create_timestamp, 
+    id, `type`, scene, page_url, root_source_id, create_account_id, create_timestamp, 
     update_timestamp
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlanExample" resultMap="BaseResultMap">
@@ -108,14 +107,12 @@
     </if>
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
-    insert into content_platform_qw_plan (id, publish_stage, `type`, 
-      scene, page_url, root_source_id, 
-      create_account_id, create_timestamp, update_timestamp
-      )
-    values (#{id,jdbcType=BIGINT}, #{publishStage,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, 
-      #{scene,jdbcType=INTEGER}, #{pageUrl,jdbcType=VARCHAR}, #{rootSourceId,jdbcType=VARCHAR}, 
-      #{createAccountId,jdbcType=BIGINT}, #{createTimestamp,jdbcType=BIGINT}, #{updateTimestamp,jdbcType=BIGINT}
-      )
+    insert into content_platform_qw_plan (id, `type`, scene, 
+      page_url, root_source_id, create_account_id, 
+      create_timestamp, update_timestamp)
+    values (#{id,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{scene,jdbcType=INTEGER}, 
+      #{pageUrl,jdbcType=VARCHAR}, #{rootSourceId,jdbcType=VARCHAR}, #{createAccountId,jdbcType=BIGINT}, 
+      #{createTimestamp,jdbcType=BIGINT}, #{updateTimestamp,jdbcType=BIGINT})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
     insert into content_platform_qw_plan
@@ -123,9 +120,6 @@
       <if test="id != null">
         id,
       </if>
-      <if test="publishStage != null">
-        publish_stage,
-      </if>
       <if test="type != null">
         `type`,
       </if>
@@ -152,9 +146,6 @@
       <if test="id != null">
         #{id,jdbcType=BIGINT},
       </if>
-      <if test="publishStage != null">
-        #{publishStage,jdbcType=INTEGER},
-      </if>
       <if test="type != null">
         #{type,jdbcType=INTEGER},
       </if>
@@ -190,9 +181,6 @@
       <if test="record.id != null">
         id = #{record.id,jdbcType=BIGINT},
       </if>
-      <if test="record.publishStage != null">
-        publish_stage = #{record.publishStage,jdbcType=INTEGER},
-      </if>
       <if test="record.type != null">
         `type` = #{record.type,jdbcType=INTEGER},
       </if>
@@ -222,7 +210,6 @@
   <update id="updateByExample" parameterType="map">
     update content_platform_qw_plan
     set id = #{record.id,jdbcType=BIGINT},
-      publish_stage = #{record.publishStage,jdbcType=INTEGER},
       `type` = #{record.type,jdbcType=INTEGER},
       scene = #{record.scene,jdbcType=INTEGER},
       page_url = #{record.pageUrl,jdbcType=VARCHAR},
@@ -237,9 +224,6 @@
   <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
     update content_platform_qw_plan
     <set>
-      <if test="publishStage != null">
-        publish_stage = #{publishStage,jdbcType=INTEGER},
-      </if>
       <if test="type != null">
         `type` = #{type,jdbcType=INTEGER},
       </if>
@@ -266,8 +250,7 @@
   </update>
   <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
     update content_platform_qw_plan
-    set publish_stage = #{publishStage,jdbcType=INTEGER},
-      `type` = #{type,jdbcType=INTEGER},
+    set `type` = #{type,jdbcType=INTEGER},
       scene = #{scene,jdbcType=INTEGER},
       page_url = #{pageUrl,jdbcType=VARCHAR},
       root_source_id = #{rootSourceId,jdbcType=VARCHAR},

+ 7 - 0
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.xml

@@ -158,4 +158,11 @@
         </foreach>
     </insert>
 
+    <insert id="insertQwPlanReturnId" useGeneratedKeys="true" keyProperty="id">
+        insert into content_platform_qw_plan (publish_stage, `type`, scene, page_url, root_source_id,
+                                              create_account_id, create_timestamp, update_timestamp)
+        values (#{record.publishStage}, #{record.type}, #{record.scene}, #{record.pageUrl}, #{record.rootSourceId},
+                #{record.createAccountId}, #{record.createTimestamp}, #{record.updateTimestamp})
+    </insert>
+
 </mapper>