Kaynağa Gözat

文章-v0.13

MOKASZ\lw12420 1 yıl önce
ebeveyn
işleme
aa369e04e3

+ 1 - 1
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/article/ArticleInController.java

@@ -147,7 +147,7 @@ public class ArticleInController {
      * @return {@link Mono}<{@link RStatus}<{@link Boolean}>>
      */
     @GetMapping("getArticle/{id}")
-    public Mono<RStatus<LabelManagement>> getArticle(@PathVariable("id") Long id) {
+    public Mono<RStatus<Article>> getArticle(@PathVariable("id") Long id) {
         return articleServiceInterface.getArticle(id);
     }
     /**

+ 2 - 2
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/article/ArticleOutController.java

@@ -38,8 +38,8 @@ public class ArticleOutController {
        return articleServiceInterface.ArticleData();
     }
     @GetMapping("refresh")
-    public Mono<Boolean> refresh(){
-        return articleServiceInterface.refresh();
+    public void refresh(){
+         articleServiceInterface.refresh();
     }
 
     /**

+ 35 - 26
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/article/ArticleSercieImp.java

@@ -41,39 +41,43 @@ public class ArticleSercieImp implements ArticleServiceInterface {
     @Resource
     private R2dbcEntityTemplate template;
 
-
-   // @Scheduled(fixedDelay = 160000)
-    //@Scheduled(cron = "0 0 10 * * ?")
-    public Mono<Boolean> refresh(){
-      //  DateTime yesterday = DateUtil.yesterday();
+    @Scheduled(cron = "0 0 7 * * ?")
+    public void refresh(){
         String format = DateUtil.format(new Date(), "yyyy-MM-dd");
-        Criteria criteria = Criteria.where("status").is(1)
-                .and("crawler_collection_time").greaterThan(format + " 00:00:01")
-                .and("crawler_collection_time").lessThan(format + " 23:59:59");
-        Query query = Query.query(criteria);
         int size=50;
-        return template.count(query, ArticleData.class).flatMap(fm -> {
-            long page = fm % 50L;
-            long page0 = fm / 50L;
-            if (page > 0) {
-                page0++;
-            }
-            int i = 0;
-            while (i < page0) {
-                // 循环体
-                refreshInitialization(i, size,criteria).subscribe();
-                i++;
+        Mono<Long> count = template.count(Query.query(Criteria.where("date_time_str").is(format)), Article.class);
+        count.flatMap(aLong -> {
+            if(aLong>0){
+                return Mono.just(true);
             }
-            return Mono.just(true);
-        });
+            Criteria criteria = Criteria.where("status").is(1)
+                    .and("crawler_collection_time").greaterThan(format + " 00:00:01")
+                    .and("crawler_collection_time").lessThan(format + " 23:59:59");
+            Query query = Query.query(criteria);
+           return template.count(query, ArticleData.class).flatMap(fm -> {
+                long page = fm % 50L;
+                long page0 = fm / 50L;
+                if (page > 0) {
+                    page0++;
+                }
+                int i = 0;
+                while (i < page0) {
+                    // 循环体
+                    refreshInitialization(i, size,criteria).subscribe();
+                    i++;
+                }
+                return Mono.just(true);
+            });
+        }).subscribe();
+
     }
     @Override
     public Mono<Boolean> ArticleData(){
         int size=50;
-        Query query = Query.query(Criteria.where("status").is(1));
         Mono<Long> count = template.select(Article.class).count();
         return count.flatMap(aLong ->{
             if(aLong==0){
+                Query query = Query.query(Criteria.where("status").is(1));
                 return template.count(query, ArticleData.class).flatMap(fm -> {
                     long page = fm % 50L;
                     long page0 = fm / 50L;
@@ -205,8 +209,8 @@ public class ArticleSercieImp implements ArticleServiceInterface {
     }
 
     @Override
-    public Mono<RStatus<LabelManagement>> getArticle(Long id) {
-        Mono<LabelManagement> id1 = template.selectOne(Query.query(Criteria.where("id").is(id)), LabelManagement.class)
+    public Mono<RStatus<Article>> getArticle(Long id) {
+        Mono<Article> id1 = template.selectOne(Query.query(Criteria.where("id").is(id)), Article.class)
                 .onErrorResume(throwable -> Mono.error(new BaseException("查询失败:" + throwable.getMessage())));
         return RStatus.success(id1);
     }
@@ -619,7 +623,12 @@ public class ArticleSercieImp implements ArticleServiceInterface {
             AppidDomain appidDomain = appidDomains.get(i);
             AppidDomainRes appidDomainRes = new AppidDomainRes();
             appidDomainRes.setAppid(appidDomain.appid());
-            appidDomainRes.setDomain(appidDomain.domain());
+            String domain = appidDomain.domain();
+            if (Objects.nonNull(domain)) {
+                String[] split = domain.split(",");
+                int i1 = RandomUtil.randomInt(0, split.length);
+                appidDomainRes.setDomain(split[i1]);
+            }
             return Mono.just(appidDomainRes);
         });
         return RStatus.success(appidDomainResMono);

+ 2 - 2
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/article/ArticleServiceInterface.java

@@ -12,7 +12,7 @@ import reactor.core.publisher.Mono;
 import java.util.List;
 
 public interface ArticleServiceInterface {
-     Mono<Boolean> refresh();
+     void refresh();
     Mono<Boolean> ArticleData();
 
     Mono<RStatus<Paged<Classification>>> getClassificationList();
@@ -39,7 +39,7 @@ public interface ArticleServiceInterface {
 
     Mono<RStatus<Boolean>> deleteArticle(Long id);
 
-    Mono<RStatus<LabelManagement>> getArticle(Long id);
+    Mono<RStatus<Article>> getArticle(Long id);
 
     Mono<RStatus<Boolean>> articleUpdate(ArticleUpdate save);