Procházet zdrojové kódy

无限发表 发布间隔判断修改

wangyunpeng před 6 hodinami
rodič
revize
b2cf83c316

+ 4 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/CoreService.java

@@ -1,5 +1,7 @@
 package com.tzld.piaoquan.longarticle.service.local;
 
+import com.tzld.piaoquan.longarticle.model.po.longarticle.PlanAccount;
+
 public interface CoreService {
 
     void initAccountSpecialSettings();
@@ -10,5 +12,7 @@ public interface CoreService {
 
     void core() throws InterruptedException;
 
+    void operatePlanAccount(PlanAccount planAccount);
+
     void getPushStatus();
 }

+ 12 - 1
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java

@@ -175,6 +175,7 @@ public class CoreServiceImpl implements CoreService {
             }
             retryCount++;
         }
+        allLongArticleSystemPlans = allLongArticleSystemPlans.stream().filter(o -> o.getId().equals("20260409030333343928599")).collect(Collectors.toList());
         for (LongArticleSystemPlan longArticleSystemPlan : allLongArticleSystemPlans) {
             Plan plan = createPlan(longArticleSystemPlan);
             planAccountService.saveOrUpdatePlan(plan);
@@ -541,11 +542,13 @@ public class CoreServiceImpl implements CoreService {
                 return false;
             }
             if (planAccount.getPublishTimeInterval() != null) {
+                List<PlanAccount> planAccountList = getTodayPlanAccountList(planAccount.getPlanId(), planAccount.getAccountId());
+                List<Long> planAccountIds = planAccountList.stream().map(PlanAccount::getId).collect(Collectors.toList());
                 // 找到该账号最近发布的内容,判断时间间隔
                 PublishContentExample example = new PublishContentExample();
                 example.createCriteria().andStatusIn(Arrays.asList(1, 2))
                         .andCreateTimeGreaterThan(DateUtil.getThatDayDate())
-                        .andPlanAccountIdEqualTo(planAccount.getId());
+                        .andPlanAccountIdIn(planAccountIds);
                 example.setOrderByClause("create_time desc");
                 List<PublishContent> publishContents = publishContentMapper.selectByExample(example);
                 if (!CollectionUtils.isEmpty(publishContents)) {
@@ -653,6 +656,13 @@ public class CoreServiceImpl implements CoreService {
         return flag;
     }
 
+    private List<PlanAccount> getTodayPlanAccountList(String planId, String accountId) {
+        PlanAccountExample example = new PlanAccountExample();
+        example.createCriteria().andPlanIdEqualTo(planId).andAccountIdEqualTo(accountId)
+                .andCreateTimeGreaterThan(DateUtil.getThatDayDate());
+        return planAccountMapper.selectByExample(example);
+    }
+
 
     @Override
     public void core() throws InterruptedException {
@@ -692,6 +702,7 @@ public class CoreServiceImpl implements CoreService {
         }
     }
 
+    @Override
     public void operatePlanAccount(PlanAccount planAccount) {
         boolean flag = checkPlanAccount(planAccount);
         log.info("planAccount={}, flag={}", planAccount, flag);

+ 10 - 0
long-article-server/src/test/java/com/tzld/piaoquan/longarticle/CoreServiceJobTest.java

@@ -1,5 +1,7 @@
 package com.tzld.piaoquan.longarticle;
 
+import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.PlanAccountMapper;
+import com.tzld.piaoquan.longarticle.model.po.longarticle.PlanAccount;
 import com.tzld.piaoquan.longarticle.service.local.CoreService;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
@@ -12,9 +14,17 @@ public class CoreServiceJobTest {
 
     @Autowired
     CoreService coreService;
+    @Autowired
+    PlanAccountMapper planAccountMapper;
 
     @Test
     public void getPushStatus() {
         coreService.getPushStatus();
     }
+
+    @Test
+    public void operatePlanAccount() {
+        PlanAccount planAccount = planAccountMapper.selectByPrimaryKey(175636L);
+        coreService.operatePlanAccount(planAccount);
+    }
 }