Преглед на файлове

Merge branch 'master' into wyp/1107-category

wangyunpeng преди 8 месеца
родител
ревизия
0c6e0873d5

+ 2 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/GhDetailVo.java

@@ -9,9 +9,9 @@ public class GhDetailVo {
 
     private Long id;
 
-    private String ghId;
+    private String accountId;
 
-    private String ghName;
+    private String accountName;
 
     private Integer type;
 

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/ArticlePoolPromotionSourceRepository.java

@@ -15,5 +15,5 @@ public interface ArticlePoolPromotionSourceRepository extends JpaRepository<Arti
 
     List<ArticlePoolPromotionSource> getByChannelContentIdInAndStatusAndDeleted(List<String> channelContentIds, Integer status, Integer deleted);
 
-    List<ArticlePoolPromotionSource> getByStatus(Integer status);
+    List<ArticlePoolPromotionSource> getByStatusAndDeleted(Integer status, Integer deleted);
 }

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/exterior/GhDetailService.java

@@ -7,7 +7,7 @@ import com.tzld.longarticle.recommend.server.util.page.Page;
 
 public interface GhDetailService {
 
-    CommonResponse<Page<GhDetailVo>> getGhDetailList(Integer pageNum, Integer pageSize, String ghId);
+    CommonResponse<Page<GhDetailVo>> getGhDetailList(Integer pageNum, Integer pageSize, String accountId);
 
     CommonResponse<Void> addGhDetail(GhDetailVo ghDetailVo);
 

+ 12 - 6
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/exterior/impl/GhDetailServiceImpl.java

@@ -30,7 +30,7 @@ public class GhDetailServiceImpl implements GhDetailService {
     private GhDetailMapper ghDetailMapper;
 
     @Override
-    public CommonResponse<Page<GhDetailVo>> getGhDetailList(Integer pageNum, Integer pageSize, String ghId) {
+    public CommonResponse<Page<GhDetailVo>> getGhDetailList(Integer pageNum, Integer pageSize, String accountId) {
         if (pageNum == null) {
             pageNum = 1;
         }
@@ -44,8 +44,8 @@ public class GhDetailServiceImpl implements GhDetailService {
         page.setCurrentPage(pageNum);
         page.setPageSize(pageSize);
         GhDetailExample example = new GhDetailExample();
-        if (StringUtils.isNotEmpty(ghId)) {
-            example.createCriteria().andGhIdEqualTo(ghId);
+        if (StringUtils.isNotEmpty(accountId)) {
+            example.createCriteria().andGhIdEqualTo(accountId);
         }
         example.setPage(page);
         long total = ghDetailMapper.countByExample(example);
@@ -57,6 +57,8 @@ public class GhDetailServiceImpl implements GhDetailService {
             for (GhDetail ghDetail : ghDetails) {
                 GhDetailVo ghDetailVo = new GhDetailVo();
                 BeanUtils.copyProperties(ghDetail, ghDetailVo);
+                ghDetailVo.setAccountId(ghDetail.getGhId());
+                ghDetailVo.setAccountName(ghDetail.getGhName());
                 ghDetailVo.setTypeName(GhTypeEnum.getTypeName(ghDetailVo.getType()));
                 ghDetailVos.add(ghDetailVo);
             }
@@ -68,16 +70,18 @@ public class GhDetailServiceImpl implements GhDetailService {
     @Override
     public CommonResponse<Void> addGhDetail(GhDetailVo ghDetailVo) {
         if (ghDetailVo == null
-                || StringUtils.isEmpty(ghDetailVo.getGhId())
-                || StringUtils.isEmpty(ghDetailVo.getGhName())
+                || StringUtils.isEmpty(ghDetailVo.getAccountId())
+                || StringUtils.isEmpty(ghDetailVo.getAccountName())
                 || ghDetailVo.getType() == null
                 || StringUtils.isEmpty(ghDetailVo.getCategory1())) {
-            CommonResponse.create(500, "参数错误");
+            return CommonResponse.create(500, "参数错误");
         }
 
         try {
             GhDetail ghDetail = new GhDetail();
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
+            ghDetail.setGhId(ghDetailVo.getAccountId());
+            ghDetail.setGhName(ghDetailVo.getAccountName());
             ghDetailMapper.insert(ghDetail);
             return CommonResponse.success();
         } catch (Exception e) {
@@ -91,6 +95,8 @@ public class GhDetailServiceImpl implements GhDetailService {
         try {
             GhDetail ghDetail = new GhDetail();
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
+            ghDetail.setGhId(ghDetailVo.getAccountId());
+            ghDetail.setGhName(ghDetailVo.getAccountName());
             ghDetailMapper.updateByPrimaryKeySelective(ghDetail);
             return CommonResponse.success();
         } catch (Exception e) {

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleService.java

@@ -272,12 +272,17 @@ public class ArticleService {
             ArticlePoolPromotionSource item = articlePoolPromotionSourceRepository.getByChannelContentId(channelContentId);
             tasks.add(item);
         } else {
-            tasks = articlePoolPromotionSourceRepository.getByStatus(0);
+            tasks = articlePoolPromotionSourceRepository.getByStatusAndDeleted(0, 0);
         }
         long now = System.currentTimeMillis();
         for (ArticlePoolPromotionSource task : tasks) {
             // 溯源
             Article article = articleRepository.getByWxSn(task.getWxSn());
+            if (Objects.isNull(article)) {
+                task.setDeleted(StatusEnum.SUCCESS.getCode());
+                articlePoolPromotionSourceRepository.save(task);
+                continue;
+            }
             PublishAccount publishAccount = publishAccountRepository.getByGhId(article.getGhId());
             if (Objects.isNull(publishAccount)) {
                 continue;
@@ -286,6 +291,8 @@ public class ArticleService {
             List<PublishContent> publishContentList = aigcBaseMapper.getNearestPublishContent(publishAccount.getId(), publishTimestamp, 100);
             PublishContent publishContent = findPublishContent(publishContentList, task.getTitle(), publishTimestamp);
             if (Objects.isNull(publishContent)) {
+                task.setDeleted(StatusEnum.SUCCESS.getCode());
+                articlePoolPromotionSourceRepository.save(task);
                 continue;
             }
             RootPublishContentVO source = getRootPublishContent(publishContent.getCrawlerChannelContentId(), null, publishContent.getId(), null, 0);

+ 6 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/DataDashboardService.java

@@ -1460,9 +1460,12 @@ public class DataDashboardService {
                 }
             }
             List<PublishContent> hisPublish = hisPublishMap.get(article.getTitle());
-            long hisMinDate = hisPublish.stream().mapToLong(PublishContent::getPublishTimestamp).min().orElse(0);
-            int explorationInterval = (int) ((article.getUpdateTime() - (hisMinDate / 1000)) / 86400);
-            item.setFirstExplorationIntervalAvg(explorationInterval);
+            if (CollectionUtils.isNotEmpty(hisPublish)) {
+                long hisMinDate = hisPublish.stream().filter(o -> Objects.nonNull(o.getPublishTimestamp()))
+                        .mapToLong(PublishContent::getPublishTimestamp).min().orElse(0);
+                int explorationInterval = (int) ((article.getUpdateTime() - (hisMinDate / 1000)) / 86400);
+                item.setFirstExplorationIntervalAvg(explorationInterval);
+            }
             result.add(item);
         }
         saveDatastatScore(dateStrList, result);

+ 10 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/GhDetailController.java → long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/AccountDetailController.java

@@ -5,7 +5,6 @@ import com.tzld.longarticle.recommend.server.common.enums.GhTypeEnum;
 import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
 import com.tzld.longarticle.recommend.server.model.vo.GhDetailVo;
 import com.tzld.longarticle.recommend.server.model.vo.GhTypeVo;
-import com.tzld.longarticle.recommend.server.repository.model.GhDetail;
 import com.tzld.longarticle.recommend.server.service.exterior.GhDetailService;
 import com.tzld.longarticle.recommend.server.util.page.Page;
 import lombok.extern.slf4j.Slf4j;
@@ -18,34 +17,36 @@ import java.util.stream.Collectors;
 
 @Slf4j
 @RestController
-@RequestMapping("/gh")
-public class GhDetailController {
+@RequestMapping("/account")
+public class AccountDetailController {
 
     @Autowired
     private GhDetailService ghDetailService;
 
     @GetMapping("/getList")
-    public CommonResponse<Page<GhDetailVo>> getGhDetailList(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @RequestParam String ghId) {
-        return ghDetailService.getGhDetailList(pageNum, pageSize, ghId);
+    public CommonResponse<Page<GhDetailVo>> getAccountDetailList(@RequestParam Integer pageNum,
+                                                            @RequestParam Integer pageSize,
+                                                            @RequestParam(defaultValue = "") String accountId) {
+        return ghDetailService.getGhDetailList(pageNum, pageSize, accountId);
     }
 
     @PostMapping("/add")
-    public CommonResponse<Void> addGhDetail(@RequestBody GhDetailVo detailVo) {
+    public CommonResponse<Void> addAccountDetail(@RequestBody GhDetailVo detailVo) {
         return ghDetailService.addGhDetail(detailVo);
     }
 
     @PostMapping("/update")
-    public CommonResponse<Void> updateGhDetail(@RequestBody GhDetailVo detailVo) {
+    public CommonResponse<Void> updateAccountDetail(@RequestBody GhDetailVo detailVo) {
         return ghDetailService.updateDetail(detailVo);
     }
 
     @GetMapping("/refresh")
-    public CommonResponse<Void> refreshGhDetail() {
+    public CommonResponse<Void> refreshAccountDetail() {
         return ghDetailService.refreshGhDetail();
     }
 
     @GetMapping("/types")
-    public CommonResponse<List<GhTypeVo>> getAllGhTypes() {
+    public CommonResponse<List<GhTypeVo>> getAllAccountTypes() {
         return CommonResponse.success(Arrays.stream(GhTypeEnum.values())
                 .map(ghTypeEnum -> new GhTypeVo(ghTypeEnum.type, ghTypeEnum.name))
                 .collect(Collectors.toList()));