Browse Source

Merge branch 'wyp/0217-videoPoolAudit' of Server/long-article-recommend into master

wangyunpeng 4 months ago
parent
commit
910609ce75

+ 32 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/longArticle/ArticleVideoBadStatusEnum.java

@@ -0,0 +1,32 @@
+package com.tzld.longarticle.recommend.server.common.enums.longArticle;
+
+import lombok.Getter;
+
+@Getter
+public enum ArticleVideoBadStatusEnum {
+
+    TITLE_DEFAULT_STATUS(0, "正常"),
+    TITLE_EXIT_STATUS(1, "违规"),
+    TITLE_FESTIVAL_STATUS(2, "节日"),
+    TITLE_DUPLICATE_STATUS(3, "重复"),
+    TITLE_SHORT_STATUS(4, "过短"),
+    TITLE_AIGC_REJECT_STATUS(4, "aigc审核不通过"),
+    ;
+
+    private final int code;
+    private final String msg;
+
+    ArticleVideoBadStatusEnum(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public static ArticleVideoBadStatusEnum getByCode(int code) {
+        for (ArticleVideoBadStatusEnum statusEnum : ArticleVideoBadStatusEnum.values()) {
+            if (statusEnum.getCode() == code) {
+                return statusEnum;
+            }
+        }
+        return null;
+    }
+}

+ 27 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/longArticle/VideoPoolAuditMapper.java

@@ -0,0 +1,27 @@
+package com.tzld.longarticle.recommend.server.mapper.longArticle;
+
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource;
+import com.tzld.longarticle.recommend.server.model.param.videoAudit.ArticleTitleUpdateParam;
+import com.tzld.longarticle.recommend.server.model.param.videoAudit.VideoTitleUpdateParam;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface VideoPoolAuditMapper {
+
+    int articleVideoAuditListCount(List<String> contentId, List<Integer> status,
+                                   List<String> title, List<String> auditAccount, List<Integer> flowPoolLevels);
+
+    List<PublishSingleVideoSource> articleVideoAuditList(List<String> contentId, List<Integer> status,
+                                                         List<String> title, List<String> auditAccount,
+                                                         List<Integer> flowPoolLevels,
+                                                         int offset, Integer pageSize, String poolLevelDesc);
+
+    List<String> searchFilterValueByItemName(String itemName, String searchKeyword);
+
+    void updateArticleTitle(ArticleTitleUpdateParam param, Long updateTime);
+
+    void updateVideoTitle(VideoTitleUpdateParam param, Long updateTime);
+
+}

+ 33 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/PublishSingleVideoSource.java

@@ -23,6 +23,15 @@ public class PublishSingleVideoSource {
     @Column(name = "article_title")
     private String articleTitle;
 
+    @Column(name = "old_article_title")
+    private String oldArticleTitle;
+
+    @Column(name = "article_title_update_account")
+    private String articleTitleUpdateAccount;
+
+    @Column(name = "article_title_update_timestamp")
+    private Long articleTitleUpdateTimestamp;
+
     @Column(name = "out_account_id")
     private String outAccountId;
 
@@ -88,4 +97,28 @@ public class PublishSingleVideoSource {
 
     @Column(name = "mini_program_title")
     private String miniProgramTitle;
+
+    @Column(name = "old_mini_program_title")
+    private String oldMiniProgramTitle;
+
+    @Column(name = "mini_program_title_update_account")
+    private String miniProgramTitleUpdateAccount;
+
+    @Column(name = "mini_program_title_update_timestamp")
+    private Long miniProgramTitleUpdateTimestamp;
+
+    @Column(name = "extract_status")
+    private Integer extractStatus;
+
+    @Column(name = "summary_text")
+    private String summaryText;
+
+    @Column(name = "video_pool_audit_status")
+    private Integer videoPoolAuditStatus;
+
+    @Column(name = "video_pool_audit_account")
+    private String videoPoolAuditAccount;
+
+    @Column(name = "video_pool_audit_timestamp")
+    private Long videoPoolAuditTimestamp;
 }

+ 17 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/videoAudit/VideoPoolAuditListParam.java

@@ -0,0 +1,17 @@
+package com.tzld.longarticle.recommend.server.model.param.videoAudit;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class VideoPoolAuditListParam {
+    private List<String> contentId;
+    private List<String> title;
+    private List<Integer> status;
+    private List<String> auditAccount;
+    private List<Integer> flowPoolLevel;
+
+    private Integer pageNum = 1;
+    private Integer pageSize = 50;
+}

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/videoAudit/VideoTitleUpdateParam.java

@@ -5,7 +5,7 @@ import lombok.Data;
 @Data
 public class VideoTitleUpdateParam {
     private String contentId;
-    private Long videoId;
+    private String videoId;
     private String title;
     private String updateAccount;
 }

+ 25 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/VideoPoolAuditListVO.java

@@ -0,0 +1,25 @@
+package com.tzld.longarticle.recommend.server.model.vo;
+
+import lombok.Data;
+
+@Data
+public class VideoPoolAuditListVO {
+
+    private String contentId;
+    private Integer status;
+    private String title;
+    private String synopsis;
+    private String flowPoolLevel;
+    private Long crawlerTimestamp;
+    private String auditAccount;
+    private Long auditTimestamp;
+    private VideoItem video;
+
+    @Data
+    public static class VideoItem {
+        private String videoId;
+        private String title;
+        private String videoUrl;
+        private String coverUrl;
+    }
+}

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/PublishSingleVideoSourceRepository.java

@@ -13,4 +13,6 @@ public interface PublishSingleVideoSourceRepository extends JpaRepository<Publis
     PublishSingleVideoSource getByContentTraceId(String sourceId);
 
     PublishSingleVideoSource getByUpLevelSource(String sourceId);
+
+    List<PublishSingleVideoSource> getByVideoPoolAuditStatus(Integer status);
 }

+ 154 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/VideoPoolAuditService.java

@@ -0,0 +1,154 @@
+package com.tzld.longarticle.recommend.server.service.recommend;
+
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishContentStatusEnum;
+import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoAuditStatusEnum;
+import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoBadStatusEnum;
+import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
+import com.tzld.longarticle.recommend.server.mapper.longArticle.VideoPoolAuditMapper;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource;
+import com.tzld.longarticle.recommend.server.model.param.videoAudit.*;
+import com.tzld.longarticle.recommend.server.model.vo.VideoPoolAuditListVO;
+import com.tzld.longarticle.recommend.server.repository.longArticle.PublishSingleVideoSourceRepository;
+import com.tzld.longarticle.recommend.server.util.page.Page;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class VideoPoolAuditService {
+
+    @Autowired
+    private VideoPoolAuditMapper videoPoolAuditMapper;
+    @Autowired
+    private PublishContentMapper publishContentMapper;
+    @Autowired
+    private PublishSingleVideoSourceRepository videoSourceRepository;
+
+    @Value("${cdnUrl:https://rescdn.piaoquantv.com/}")
+    private String cdnUrl;
+
+    @Value("${videoAudit.poolLevel.sort:}")
+    private String poolLevelDesc;
+
+    public Page<VideoPoolAuditListVO> list(VideoPoolAuditListParam param) {
+        int offset = (param.getPageNum() - 1) * param.getPageSize();
+        int count = videoPoolAuditMapper.articleVideoAuditListCount(param.getContentId(), param.getStatus(),
+                param.getTitle(), param.getAuditAccount(), param.getFlowPoolLevel());
+        List<PublishSingleVideoSource> list = videoPoolAuditMapper.articleVideoAuditList(param.getContentId(),
+                param.getStatus(), param.getTitle(), param.getAuditAccount(), param.getFlowPoolLevel()
+                , offset, param.getPageSize(), poolLevelDesc);
+        List<VideoPoolAuditListVO> result = buildVideoPoolAuditListVO(list);
+        Page<VideoPoolAuditListVO> page = new Page<>(param.getPageNum(), param.getPageSize());
+        page.setTotalSize(count);
+        page.setObjs(result);
+        return page;
+    }
+
+    private List<VideoPoolAuditListVO> buildVideoPoolAuditListVO(List<PublishSingleVideoSource> list) {
+        List<VideoPoolAuditListVO> result = new ArrayList<>();
+        if (CollectionUtils.isEmpty(list)) {
+            return result;
+        }
+        for (PublishSingleVideoSource item : list) {
+            VideoPoolAuditListVO vo = new VideoPoolAuditListVO();
+            vo.setContentId(item.getContentTraceId());
+            vo.setTitle(item.getArticleTitle());
+            vo.setStatus(item.getVideoPoolAuditStatus());
+            vo.setSynopsis(item.getSummaryText());
+            vo.setFlowPoolLevel(String.valueOf(item.getFlowPoolLevel()));
+            vo.setCrawlerTimestamp(item.getCrawlerTimestamp() * 1000);
+            vo.setAuditAccount(item.getVideoPoolAuditAccount());
+            if (Objects.nonNull(item.getVideoPoolAuditTimestamp())) {
+                vo.setAuditTimestamp(item.getVideoPoolAuditTimestamp() * 1000);
+            }
+            VideoPoolAuditListVO.VideoItem videoItem = new VideoPoolAuditListVO.VideoItem();
+            videoItem.setVideoId(item.getContentTraceId());
+            videoItem.setTitle(item.getMiniProgramTitle());
+            videoItem.setVideoUrl(cdnUrl + item.getVideoOssPath());
+            videoItem.setCoverUrl(item.getCoverUrl());
+            vo.setVideo(videoItem);
+            result.add(vo);
+        }
+        return result;
+    }
+
+    public void auditArticle(ArticleAuditParam param) {
+        PublishSingleVideoSource videoAudit = videoSourceRepository.getByContentTraceId(param.getContentId());
+        Long now = System.currentTimeMillis();
+        if (param.getStatus().equals(ArticleVideoAuditStatusEnum.REJECT.getCode())) {
+            videoAudit.setBadStatus(ArticleVideoBadStatusEnum.TITLE_AIGC_REJECT_STATUS.getCode());
+        } else {
+            videoAudit.setBadStatus(ArticleVideoBadStatusEnum.TITLE_DEFAULT_STATUS.getCode());
+        }
+        videoAudit.setVideoPoolAuditStatus(param.getStatus());
+        videoAudit.setVideoPoolAuditAccount(param.getAuditAccount());
+        videoAudit.setVideoPoolAuditTimestamp(now);
+        videoSourceRepository.save(videoAudit);
+        if (param.getStatus() == 2) {
+            // 审核不通过
+            auditArticleReject(videoAudit);
+        } else {
+            // 审核通过
+            auditArticlePass(videoAudit);
+        }
+
+    }
+
+    private void auditArticlePass(PublishSingleVideoSource videoAudit) {
+        // publish_content
+        publishContentMapper.updatePublishContentStatus(videoAudit.getContentTraceId(),
+                PublishContentStatusEnum.waiting_publish.getVal(),
+                PublishContentStatusEnum.gzh_article_deprecated.getVal());
+    }
+
+    private void auditArticleReject(PublishSingleVideoSource videoAudit) {
+        // publish_content
+        publishContentMapper.updatePublishContentStatus(videoAudit.getContentTraceId(),
+                PublishContentStatusEnum.gzh_article_deprecated.getVal(),
+                PublishContentStatusEnum.waiting_publish.getVal());
+    }
+
+    public List<Object> getFilterValue(AuditFilterParam param) {
+        String itemName = param.getItemName();
+        if ("contentId".equals(itemName) || "title".equals(itemName) || "auditAccount".equals(itemName)) {
+            return videoPoolAuditMapper.searchFilterValueByItemName(itemName, param.getSearchKeyword())
+                    .stream().collect(Collectors.toList());
+        } else {
+            return new ArrayList<>();
+        }
+    }
+
+    public void updateArticleTitle(ArticleTitleUpdateParam param) {
+        long now = System.currentTimeMillis();
+        videoPoolAuditMapper.updateArticleTitle(param, now);
+    }
+
+    public void updateVideoTitle(VideoTitleUpdateParam param) {
+        long now = System.currentTimeMillis();
+        videoPoolAuditMapper.updateVideoTitle(param, now);
+    }
+
+    @XxlJob("shuffleVideoPoolAuditGroup")
+    public ReturnT<String> shuffleVideoPoolAuditGroup(String param) {
+        List<String> auditUser = Arrays.asList("a","b","c","d","e","f","g","h","i","j");
+        List<PublishSingleVideoSource> contentIds = videoSourceRepository.getByVideoPoolAuditStatus(ArticleVideoAuditStatusEnum.WAITING.getCode());
+        for (int i = 0; i < contentIds.size(); i++) {
+            int per = i % auditUser.size();
+            PublishSingleVideoSource audit = contentIds.get(i);
+            audit.setVideoPoolAuditAccount(auditUser.get(per));
+            videoSourceRepository.save(audit);
+        }
+        return ReturnT.SUCCESS;
+    }
+}

+ 56 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/VideoPoolAuditController.java

@@ -0,0 +1,56 @@
+package com.tzld.longarticle.recommend.server.web.recommend;
+
+import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
+import com.tzld.longarticle.recommend.server.model.param.videoAudit.*;
+import com.tzld.longarticle.recommend.server.model.vo.VideoPoolAuditListVO;
+import com.tzld.longarticle.recommend.server.service.recommend.VideoPoolAuditService;
+import com.tzld.longarticle.recommend.server.util.page.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/videoPoolAudit")
+@Slf4j
+public class VideoPoolAuditController {
+
+    @Autowired
+    VideoPoolAuditService service;
+
+    @PostMapping("/list")
+    public CommonResponse<Page<VideoPoolAuditListVO>> articleVideoAuditList(@RequestBody VideoPoolAuditListParam param) {
+        return CommonResponse.success(service.list(param));
+    }
+
+    @PostMapping("/auditArticle")
+    public CommonResponse<Void> auditArticle(@RequestBody ArticleAuditParam param) {
+        service.auditArticle(param);
+        return CommonResponse.success();
+    }
+
+    @PostMapping("/getFilterValue")
+    public CommonResponse<List<Object>> getFilterValue(@RequestBody AuditFilterParam param) {
+        return CommonResponse.success(service.getFilterValue(param));
+    }
+
+    @PostMapping("/updateArticleTitle")
+    public CommonResponse<Void> updateArticleTitle(@RequestBody ArticleTitleUpdateParam param) {
+        service.updateArticleTitle(param);
+        return CommonResponse.success();
+    }
+
+    @PostMapping("/updateVideoTitle")
+    public CommonResponse<Void> updateVideoTitle(@RequestBody VideoTitleUpdateParam param) {
+        service.updateVideoTitle(param);
+        return CommonResponse.success();
+    }
+
+    @GetMapping("/shuffleAuditGroup")
+    public CommonResponse<Void> shuffleVideoPoolAuditGroup() {
+        service.shuffleVideoPoolAuditGroup(null);
+        return CommonResponse.success();
+    }
+
+}

+ 144 - 0
long-article-recommend-service/src/main/resources/mapper/longArticle/VideoPoolAuditMapper.xml

@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzld.longarticle.recommend.server.mapper.longArticle.VideoPoolAuditMapper">
+
+    <select id="articleVideoAuditListCount" resultType="java.lang.Integer">
+        select count(content_trace_id)
+        from publish_single_video_source
+        where bad_status = 0 and audit_status = 1
+        <if test="status!= null and status.size() > 0">
+            and video_pool_audit_status in
+            <foreach collection="status" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="contentId!= null and contentId.size() > 0">
+            and content_trace_id in
+            <foreach collection="contentId" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="title!= null and title.size() > 0">
+            and article_title in
+            <foreach collection="title" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="auditAccount!= null and auditAccount.size() > 0">
+            and video_pool_audit_account in
+            <foreach collection="auditAccount" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="flowPoolLevels!= null and flowPoolLevels.size() > 0">
+            and flow_pool_level in
+            <foreach collection="flowPoolLevels" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="articleVideoAuditList"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource">
+        select *
+        from publish_single_video_source
+        where bad_status = 0 and audit_status = 1
+        <if test="status!= null and status.size() > 0">
+            and `video_pool_audit_status` in
+            <foreach collection="status" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="contentId!= null and contentId.size() > 0">
+            and content_trace_id in
+            <foreach collection="contentId" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="title!= null and title.size() > 0">
+            and article_title in
+            <foreach collection="title" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="auditAccount!= null and auditAccount.size() > 0">
+            and video_pool_audit_account in
+            <foreach collection="auditAccount" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="flowPoolLevels!= null and flowPoolLevels.size() > 0">
+            and flow_pool_level in
+            <foreach collection="flowPoolLevels" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <choose>
+            <when test="poolLevelDesc != null and poolLevelDesc != ''">
+                order by flow_pool_level ${poolLevelDesc}, content_trace_id desc
+            </when>
+            <otherwise>
+                order by content_trace_id desc
+            </otherwise>
+        </choose>
+        limit #{offset}, #{pageSize}
+    </select>
+
+    <select id="searchFilterValueByItemName" resultType="java.lang.String">
+        <choose>
+            <when test="itemName == 'contentId'">
+                select content_trace_id
+                from publish_single_video_source
+                <where>
+                    <if test="searchKeyword != null and searchKeyword !=''">
+                        and content_trace_id like concat('%', #{searchKeyword}, '%')
+                    </if>
+                </where>
+                order by crawler_timestamp desc
+                limit 100
+            </when>
+            <when test="itemName == 'auditAccount'">
+                select distinct video_pool_audit_account
+                from publish_single_video_source
+                <where>
+                    <if test="searchKeyword != null and searchKeyword !=''">
+                        and video_pool_audit_account like concat('%', #{searchKeyword}, '%')
+                    </if>
+                </where>
+                order by crawler_timestamp desc
+                limit 100
+            </when>
+            <when test="itemName == 'title'">
+                select distinct article_title
+                from publish_single_video_source
+                <where>
+                    <if test="searchKeyword != null and searchKeyword !=''">
+                        and article_title like concat('%', #{searchKeyword}, '%')
+                    </if>
+                </where>
+                order by crawler_timestamp desc
+                limit 100
+            </when>
+        </choose>
+    </select>
+
+    <update id="updateArticleTitle">
+        update publish_single_video_source
+        set old_article_title = article_title,
+            article_title = #{param.title},
+            article_title_update_account = #{param.updateAccount},
+            article_title_update_timestamp = #{updateTime}
+        where content_trace_id = #{param.contentId}
+    </update>
+
+    <update id="updateVideoTitle">
+        update publish_single_video_source
+        set old_mini_program_title = mini_program_title,
+            mini_program_title = #{param.title},
+            mini_program_title_update_account = #{param.updateAccount},
+            mini_program_title_update_timestamp = #{updateTime}
+        where content_trace_id = #{param.contentId}
+    </update>
+
+
+</mapper>