Files
mini_tp/app/api/model/DyVideoCron.php
T
nepiedg 044586d60a 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.
2026-04-02 09:00:48 +00:00

63 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace app\api\model;
use think\Model;
use think\db\Query;
/**
* 发布任务模型(对应 dy_video_cron 表)
*
* 首页“发布任务”统计与 acgpmw 一致,只排除 status=3 的记录。
*/
class DyVideoCron extends Model
{
protected $connection = 'dbmember';
protected $name = 'dy_video_cron';
protected $pk = 'id';
protected $autoWriteTimestamp = false;
/**
* 统计当前用户的有效发布任务数量。
*
* @param int $userid 用户ID
* @return int
*/
public static function countActiveByUserId(int $userid): int
{
return (int) self::where('userid', $userid)
->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);
});
});
}
}