publishPlanService = new PublishPlanService(); } /** * 发布计划列表。 * * GET /api/v1/publish-plan/list * * 请求参数: * - `status`:筛选值,支持 `all` / `running` / `stopped` / `finished` * - `page`:页码,可选 * - `page_size`:每页数量,可选 * * 返回结构: * - `filters`:状态筛选项 * - `summary`:顶部统计卡片 * - `pagination`:分页信息 * - `list`:计划卡片数据 */ public function index() { try { $payload = $this->request->payload ?? null; if (!$payload || empty($payload['userid'])) { return Response::error('未登录', 401); } $result = $this->publishPlanService->getPlanList((int) $payload['userid'], [ 'status' => (string) $this->request->get('status', 'all'), 'page' => (int) $this->request->get('page', 1), 'page_size' => (int) $this->request->get('page_size', 20), ]); return Response::success($result); } catch (\Exception $exception) { return Response::error($exception->getMessage(), $exception->getCode() ?: 500); } } /** * 开启发布计划。 * * 这里按 acgpmw `cron::fabu()` 逻辑对齐,只更新 `jrstop=0`。 * 已完成计划不提供恢复操作,避免小程序在未完整对齐复杂编辑流程时误操作。 * * @param int $id 计划ID * @return \think\response\Json */ public function start(int $id) { try { $payload = $this->request->payload ?? null; if (!$payload || empty($payload['userid'])) { return Response::error('未登录', 401); } $result = $this->publishPlanService->startPlan((int) $payload['userid'], $id); return Response::success($result, '设置成功'); } catch (\Exception $exception) { return Response::error($exception->getMessage(), $exception->getCode() ?: 500); } } /** * 暂停发布计划。 * * 这里按 acgpmw `cron::stop()` 逻辑对齐: * 1. 更新 `jrstop=1` * 2. 尝试把 `dy_cron_account` 中待执行状态改为 5 * * @param int $id 计划ID * @return \think\response\Json */ public function stop(int $id) { try { $payload = $this->request->payload ?? null; if (!$payload || empty($payload['userid'])) { return Response::error('未登录', 401); } $result = $this->publishPlanService->stopPlan((int) $payload['userid'], $id); return Response::success($result, '设置成功'); } catch (\Exception $exception) { return Response::error($exception->getMessage(), $exception->getCode() ?: 500); } } }