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:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user