mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-04 01:10:36 +00:00
- 删除原有的示例模块(module_example)和AI模块(module_ai) - 在应用模块(module_application)下新增AI子模块和示例子模块 - 更新相关路由配置,移除不再使用的模块路由 - 调整定时任务模块从监控模块迁移至应用模块 - 更新前端API路径和组件文件结构 - 修正数据库表名前缀,统一使用'app_'作为应用模块表前缀
66 lines
2.6 KiB
Python
66 lines
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Dict, List, Optional, Sequence
|
|
|
|
from app.core.base_crud import CRUDBase
|
|
from app.api.v1.module_system.auth.schema import AuthSchema
|
|
from .model import JobModel, JobLogModel
|
|
from .schema import JobCreateSchema,JobUpdateSchema,JobLogCreateSchema,JobLogUpdateSchema
|
|
|
|
|
|
class JobCRUD(CRUDBase[JobModel, JobCreateSchema, JobUpdateSchema]):
|
|
"""定时任务数据层"""
|
|
|
|
def __init__(self, auth: AuthSchema) -> None:
|
|
"""初始化定时任务CRUD"""
|
|
self.auth = auth
|
|
super().__init__(model=JobModel, auth=auth)
|
|
|
|
async def get_obj_by_id_crud(self, id: int) -> Optional[JobModel]:
|
|
"""获取定时任务详情"""
|
|
return await self.get(id=id)
|
|
|
|
async def get_obj_list_crud(self, search: Optional[Dict] = None, order_by: Optional[List[Dict[str, str]]] = None) -> Sequence[JobModel]:
|
|
"""获取定时任务列表"""
|
|
return await self.list(search=search, order_by=order_by)
|
|
|
|
async def create_obj_crud(self, data: JobCreateSchema) -> Optional[JobModel]:
|
|
"""创定时任务"""
|
|
return await self.create(data=data)
|
|
|
|
async def update_obj_crud(self, id: int, data: JobUpdateSchema) -> Optional[JobModel]:
|
|
"""更新定时任务"""
|
|
return await self.update(id=id, data=data)
|
|
|
|
async def delete_obj_crud(self, ids: List[int]) -> None:
|
|
"""删除定时任务"""
|
|
return await self.delete(ids=ids)
|
|
|
|
async def set_obj_field_crud(self, ids: List[int], **kwargs) -> None:
|
|
"""设置定时任务的可用状态"""
|
|
return await self.set(ids=ids, **kwargs)
|
|
|
|
async def clear_obj_crud(self) -> None:
|
|
"""清除定时任务日志"""
|
|
return await self.clear()
|
|
|
|
|
|
class JobLogCRUD(CRUDBase[JobLogModel, JobLogCreateSchema, JobLogUpdateSchema]):
|
|
"""定时任务日志数据层"""
|
|
|
|
def __init__(self, auth: AuthSchema) -> None:
|
|
"""初始化定时任务日志CRUD"""
|
|
self.auth = auth
|
|
super().__init__(model=JobLogModel, auth=auth)
|
|
|
|
async def get_obj_log_by_id_crud(self, id: int) -> Optional[JobLogModel]:
|
|
"""获取定时任务日志详情"""
|
|
return await self.get(id=id)
|
|
|
|
async def get_obj_log_list_crud(self, search: Optional[Dict] = None, order_by: Optional[List[Dict[str, str]]] = None) -> Sequence[JobLogModel]:
|
|
"""获取定时任务日志列表"""
|
|
return await self.list(search=search, order_by=order_by)
|
|
|
|
async def delete_obj_log_crud(self, ids: List[int]) -> None:
|
|
"""删除定时任务日志"""
|
|
return await self.delete(ids=ids) |