소스 검색

企微计划

wangyunpeng 2 달 전
부모
커밋
8a053cf027

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

@@ -40,6 +40,12 @@ public class ContentPlatformPlanController {
         return CommonResponse.success(planService.getVideoContentList(param));
     }
 
+    @ApiOperation(value = "发布内容视频品类列表")
+    @GetMapping("/videoContentCategoryList")
+    public CommonResponse<List<String>> getVideoContentCategoryList() {
+        return CommonResponse.success(planService.getVideoContentCategoryList());
+    }
+
     @ApiOperation(value = "发布内容视频封面截帧列表")
     @PostMapping("/videoContentCoverFrameList")
     public CommonResponse<List<String>> getVideoContentCoverFrameList(@RequestBody VideoContentCoverFrameParam param) {

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

@@ -2,9 +2,10 @@ 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 java.util.List;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface ContentPlatformQwPlanMapper {
     long countByExample(ContentPlatformQwPlanExample example);
 

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

@@ -1,8 +1,10 @@
 package com.tzld.piaoquan.api.dao.mapper.contentplatform.ext;
 
 import com.tzld.piaoquan.api.model.param.contentplatform.GzhPlanListParam;
+import com.tzld.piaoquan.api.model.param.contentplatform.QwPlanListParam;
 import com.tzld.piaoquan.api.model.param.contentplatform.VideoContentListParam;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan;
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo;
 import org.apache.ibatis.annotations.Param;
 
@@ -29,10 +31,22 @@ public interface ContentPlatformPlanMapperExt {
 
     int getVideoCount(@Param("param") VideoContentListParam param, @Param("dt") String dt);
 
+    List<String> getVideoCategoryList(@Param("dt") String dt);
+
     List<ContentPlatformVideo> getVideoList(@Param("param") VideoContentListParam param,
                                             @Param("dt") String dt,
                                             @Param("offset") int offset,
                                             @Param("pageSize") Integer pageSize);
 
     void batchInsertContentPlatformVideo(@Param("records") List<ContentPlatformVideo> saveList);
+
+    int getQwPlanCount(@Param("param") QwPlanListParam param,
+                       @Param("createAccountId") Long createAccountId);
+
+    List<ContentPlatformQwPlan> getQwPlanList(@Param("param") QwPlanListParam param,
+                                              @Param("createAccountId") Long createAccountId,
+                                              @Param("offset") int offset,
+                                              @Param("pageSize") Integer pageSize);
+    void batchInsertQwPlan(@Param("records") List<ContentPlatformQwPlan> saveList);
+
 }

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformPlanService.java

@@ -16,6 +16,8 @@ public interface ContentPlatformPlanService {
 
     Page<VideoContentItemVO> getVideoContentList(VideoContentListParam param);
 
+    List<String> getVideoContentCategoryList();
+
     List<String> getVideoContentCoverFrameList(VideoContentCoverFrameParam param);
 
     Page<QwPlanItemVO> qwPlanList(QwPlanListParam param);

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

@@ -5,7 +5,7 @@ import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
 import com.tzld.piaoquan.api.common.exception.CommonException;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhPlanMapper;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhPlanVideoMapper;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwPlanMapper;
+import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwPlanVideoMapper;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
 import com.tzld.piaoquan.api.model.config.LoginUserContext;
 import com.tzld.piaoquan.api.model.param.contentplatform.*;
@@ -22,6 +22,8 @@ import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
 import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.growth.common.model.po.GhDetail;
+import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
+import com.tzld.piaoquan.growth.common.utils.MessageUtil;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -33,6 +35,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -46,7 +49,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     @Autowired
     private ContentPlatformGzhPlanVideoMapper gzhPlanVideoMapper;
     @Autowired
-    private ContentPlatformQwPlanMapper qwPlanMapper;
+    private ContentPlatformQwPlanVideoMapper qwPlanVideoMapper;
     @Autowired
     private ContentPlatformCooperateAccountService cooperateAccountService;
     @Autowired
@@ -55,6 +58,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     private AigcApiService aigcApiService;
     @Autowired
     private ManagerApiService managerApiService;
+    @Autowired
+    private MessageAttachmentService messageAttachmentService;
 
     @Override
     public Page<GzhPlanItemVO> gzhPlanList(GzhPlanListParam param) {
@@ -251,6 +256,12 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         return result;
     }
 
+    @Override
+    public List<String> getVideoContentCategoryList() {
+        String dt = planMapperExt.getVideoMaxDt();
+        return planMapperExt.getVideoCategoryList(dt);
+    }
+
     @Override
     public List<String> getVideoContentCoverFrameList(VideoContentCoverFrameParam param) {
         return managerApiService.getCoverImagePaths(param.getVideoId());
@@ -258,11 +269,73 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
 
     @Override
     public Page<QwPlanItemVO> qwPlanList(QwPlanListParam param) {
-        return null;
+        ContentPlatformAccount loginAccount = LoginUserContext.getUser();
+        Page<QwPlanItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
+        int offset = (param.getPageNum() - 1) * param.getPageSize();
+        int count = planMapperExt.getQwPlanCount(param, loginAccount.getId());
+        result.setTotalSize(count);
+        if (count == 0) {
+            return result;
+        }
+        List<ContentPlatformQwPlan> planList = planMapperExt.getQwPlanList(param,
+                loginAccount.getId(), offset, param.getPageSize());
+        List<QwPlanItemVO> list = buildQwPlanItemVOList(planList);
+        result.setObjs(list);
+        return result;
+    }
+
+    private List<QwPlanItemVO> buildQwPlanItemVOList(List<ContentPlatformQwPlan> planList) {
+        if (CollectionUtils.isEmpty(planList)) {
+            return null;
+        }
+        List<Long> planIds = planList.stream().map(ContentPlatformQwPlan::getId).collect(Collectors.toList());
+        List<ContentPlatformQwPlanVideo> videoList = getQwPlanVideoList(planIds);
+        Map<Long, ContentPlatformQwPlanVideo> videoMap = videoList.stream()
+                .collect(Collectors.toMap(ContentPlatformQwPlanVideo::getPlanId, Function.identity()));
+        List<QwPlanItemVO> result = new ArrayList<>();
+        for (ContentPlatformQwPlan qwPlan : planList) {
+            QwPlanItemVO planItemVO = new QwPlanItemVO();
+            planItemVO.setId(qwPlan.getId());
+            planItemVO.setType(qwPlan.getType());
+            planItemVO.setScene(qwPlan.getScene());
+            planItemVO.setPageUrl(qwPlan.getPageUrl());
+            planItemVO.setCreateTimestamp(qwPlan.getCreateTimestamp());
+            ContentPlatformQwPlanVideo videoItem = videoMap.get(qwPlan.getId());
+            if (Objects.nonNull(videoItem)) {
+                planItemVO.setTitle(videoItem.getTitle());
+                planItemVO.setCover(videoItem.getCover());
+                planItemVO.setVideo(videoItem.getVideo());
+            }
+            result.add(planItemVO);
+        }
+        return result;
+    }
+
+    private List<ContentPlatformQwPlanVideo> getQwPlanVideoList(List<Long> planIds) {
+        ContentPlatformQwPlanVideoExample example = new ContentPlatformQwPlanVideoExample();
+        example.createCriteria().andPlanIdIn(planIds);
+        return qwPlanVideoMapper.selectByExample(example);
     }
 
     @Override
     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());
+            qwPlan.setScene(videoParam.getScene());
+            String pageUrl = messageAttachmentService.getPage(loginUser.getChannel(), "wxbdd2a2e93d9a6e25",
+                    "dyyjs", "企微", "社群", "位置X", videoParam.getVideoId());
+            String rootSourceId = MessageUtil.getRootSourceId(pageUrl);
+            qwPlan.setPageUrl(pageUrl);
+            qwPlan.setRootSourceId(rootSourceId);
+            qwPlan.setCreateAccountId(loginUser.getId());
+            qwPlan.setCreateTimestamp(now);
+            saveList.add(qwPlan);
+        }
+        planMapperExt.batchInsertQwPlan(saveList);
     }
+
 }

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

@@ -100,6 +100,12 @@
         limit #{offset}, #{pageSize}
     </select>
 
+    <select id="getVideoCategoryList" resultType="java.lang.String">
+        select distinct category
+        from content_platform_video
+        where dt = #{dt}
+    </select>
+
     <insert id="batchInsertContentPlatformVideo">
         insert into content_platform_video (dt, video_id, category, title, video, score, create_timestamp)
         values
@@ -109,4 +115,47 @@
         </foreach>
     </insert>
 
+    <select id="getQwPlanCount" resultType="java.lang.Integer">
+        select count(*)
+        from content_platform_qw_plan
+        where create_account_id = #{createAccountId}
+          and type = #{param.type}
+        <if test="param.scene != null">
+            and scene &lt; #{param.scene}
+        </if>
+        <if test="param.title != null and param.title != ''">
+            and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},
+            '%'))
+        </if>
+    </select>
+
+    <select id="getQwPlanList"
+            resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwPlan">
+        select count(*)
+        from content_platform_qw_plan
+        where create_account_id = #{createAccountId}
+        and type = #{param.type}
+        <if test="param.scene != null">
+            and scene &lt; #{param.scene}
+        </if>
+        <if test="param.title != null and param.title != ''">
+            and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},
+            '%'))
+        </if>
+        order by create_timestamp desc
+        limit #{offset}, #{pageSize}
+    </select>
+
+    <insert id="batchInsertQwPlan">
+        insert into content_platform_qw_plan (publish_stage, `type`, scene, page_url, root_source_id,
+        create_account_id, create_timestamp, update_timestamp
+        )
+        values 
+        <foreach collection="records" item="item" separator=",">
+            (#{item.publishStage}, #{item.type}, #{item.scene}, #{item.pageUrl}, #{item.rootSourceId},
+            #{item.createAccountId}, #{item.createTimestamp}, #{item.updateTimestamp}
+            )
+        </foreach>
+    </insert>
+
 </mapper>

+ 31 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

@@ -434,4 +434,35 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
                 pageSize
         );
     }
+
+    @Override
+    public String getPage(String channel, String carrierId, String scene, String putTypeOne,
+                          String putTypeTwo, String putTypeThree, Long videoId) {
+        AdPutFlowParam param = new AdPutFlowParam();
+        param.setChannel(channel);
+        param.setPath("pages/category.html");
+        param.setPutCarrierId(carrierId);
+        param.setPutScene(scene);
+        param.setPutStartDate(DateUtil.getDayDateString("yyyy-MM-dd"));
+        param.setPutTypeOne(putTypeOne);
+        param.setPutTypeTwo(putTypeTwo);
+        param.setPutTypeThree(putTypeThree);
+        param.setVideoId(videoId);
+        Map<String, String> requestParam = new HashMap<>();
+        String jumpPage = "pages/user-videos?id=${videoId}&fromGzh=1&rootShareId=${uuid}&shareId=${uuid}&rootSourceId=[rootSourceId]"
+                .replace("${videoId}", "" + videoId)
+                .replace("${uuid}", "" + UUID.randomUUID());
+        requestParam.put("jumpPage", jumpPage);
+        param.setRequestParam(requestParam);
+        try {
+            String res = httpPoolClient.post(POST_ADD_TENCENT, JSONObject.toJSONString(param));
+            JSONObject jsonObject = JSONObject.parseObject(res);
+            JSONObject data = jsonObject.getJSONObject("data");
+            return data.getString("url");
+        } catch (IOException e) {
+            log.error("MessageAttachmentService getPage error", e);
+        }
+        return null;
+    }
+
 }

+ 2 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/MessageAttachmentService.java

@@ -20,4 +20,6 @@ public interface MessageAttachmentService {
     String getPicMediaId(String cover, Long corpId);
 
     String getPage(Staff staff, Long videoId);
+
+    String getPage(String channel, String carrierId, String scene, String putTypeOne, String putTypeTwo, String putTypeThree, Long videoId);
 }

+ 11 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/utils/MessageUtil.java

@@ -17,6 +17,17 @@ public class MessageUtil {
         return null;
     }
 
+    public static String getRootSourceId(String page) {
+        String translate = URLUtil.translate(page);
+        if (translate.contains("rootSourceId=")) {
+            String rootSourceId = translate.split("rootSourceId=")[1].split("&")[0];
+            if (StringUtils.isNotEmpty(rootSourceId)) {
+                return rootSourceId;
+            }
+        }
+        return null;
+    }
+
     public static String getName(String remark) {
         return String.format(defaultName, DateUtil.getDayDateString("MMdd"), remark);
     }