feat(publish-plan): add publish plan query and API routes

- Introduced `buildPublishPlanQuery` method in `DyVideoCron` model to create a base query for the publish plan module, filtering records based on user ID and project status.
- Added new API routes under `v1/publish-plan` for listing, starting, and stopping publish plans, requiring user authentication.
This commit is contained in:
nepiedg
2026-04-02 09:00:48 +00:00
parent c909ebdf88
commit 044586d60a
5 changed files with 896 additions and 0 deletions
+27
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace app\api\model;
use think\Model;
use think\db\Query;
/**
* 发布任务模型(对应 dy_video_cron 表)
@@ -32,4 +33,30 @@ class DyVideoCron extends Model
->where('status', '<>', 3)
->count();
}
/**
* 创建“发布计划模块”基础查询。
*
* 这里直接对齐 acgpmw 以下两个列表控制器的取数范围:
* 1. `cron::cron_list()``project_id = 0 and status not in (9,10)`
* 2. `ai_project_cron::cron_list()``project_id > 0`
*
* 小程序发布计划主页面只聚合这两类数据,避免把 `dy_video_cron`
* 中其他业务模块(如 AI 文案等)的记录误当成发布计划展示出来。
*
* @param int $userid 当前登录用户ID
* @return Query
*/
public static function buildPublishPlanQuery(int $userid): Query
{
return self::where('userid', $userid)
->where(function (Query $query) {
$query->where(function (Query $innerQuery) {
$innerQuery->where('project_id', 0)
->whereNotIn('status', [9, 10]);
})->whereOr(function (Query $innerQuery) {
$innerQuery->where('project_id', '>', 0);
});
});
}
}