feat: 添加计划表相关API
This commit is contained in:
@@ -23,7 +23,8 @@ __author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .scripts import router as scripts_router
|
||||
from .plan import router as plan_router
|
||||
from .queue import router as queue_router
|
||||
from .setting import router as setting_router
|
||||
|
||||
__all__ = ["scripts_router", "queue_router", "setting_router"]
|
||||
__all__ = ["scripts_router", "plan_router", "queue_router", "setting_router"]
|
||||
|
||||
82
app/api/plan.py
Normal file
82
app/api/plan.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# AUTO_MAA:A MAA Multi Account Management and Automation Tool
|
||||
# Copyright © 2024-2025 DLmaster361
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Contact: DLmaster_361@163.com
|
||||
|
||||
|
||||
from fastapi import APIRouter, Body
|
||||
|
||||
from core import Config
|
||||
from models.schema import *
|
||||
|
||||
router = APIRouter(prefix="/api/plan", tags=["计划管理"])
|
||||
|
||||
|
||||
@router.post(
|
||||
"/add", summary="添加计划表", response_model=PlanCreateOut, status_code=200
|
||||
)
|
||||
async def add_plan(plan: PlanCreateIn = Body(...)) -> PlanCreateOut:
|
||||
|
||||
uid, config = await Config.add_plan(plan.type)
|
||||
return PlanCreateOut(planId=str(uid), data=await config.toDict())
|
||||
|
||||
|
||||
@router.post(
|
||||
"/get", summary="查询计划表配置信息", response_model=PlanGetOut, status_code=200
|
||||
)
|
||||
async def get_plan(plan: PlanGetIn = Body(...)) -> PlanGetOut:
|
||||
|
||||
try:
|
||||
index, data = await Config.get_plan(plan.planId)
|
||||
except Exception as e:
|
||||
return PlanGetOut(code=500, status="error", message=str(e), index=[], data={})
|
||||
return PlanGetOut(index=index, data=data)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/update", summary="更新计划表配置信息", response_model=OutBase, status_code=200
|
||||
)
|
||||
async def update_plan(plan: PlanUpdateIn = Body(...)) -> OutBase:
|
||||
|
||||
try:
|
||||
await Config.update_plan(plan.planId, plan.data)
|
||||
except Exception as e:
|
||||
return OutBase(code=500, status="error", message=str(e))
|
||||
return OutBase()
|
||||
|
||||
|
||||
@router.post("/delete", summary="删除计划表", response_model=OutBase, status_code=200)
|
||||
async def delete_plan(plan: PlanDeleteIn = Body(...)) -> OutBase:
|
||||
|
||||
try:
|
||||
await Config.del_plan(plan.planId)
|
||||
except Exception as e:
|
||||
return OutBase(code=500, status="error", message=str(e))
|
||||
return OutBase()
|
||||
|
||||
|
||||
@router.post(
|
||||
"/order", summary="重新排序计划表", response_model=OutBase, status_code=200
|
||||
)
|
||||
async def reorder_plan(plan: PlanReorderIn = Body(...)) -> OutBase:
|
||||
|
||||
try:
|
||||
await Config.reorder_plan(plan.indexList)
|
||||
except Exception as e:
|
||||
return OutBase(code=500, status="error", message=str(e))
|
||||
return OutBase()
|
||||
Reference in New Issue
Block a user