|
@@ -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;
|
|
|
+ }
|
|
|
+}
|