Files
FastapiAdmin/backend/app/api/v1/module_system/ticket/crud.py
T
zhangtao 53d2a9d13e chore: cleanup old frontend code and update project configs
This commit removes the deprecated frontend/web-old directory, updates various project configuration files including tsconfig, vite config, environment variables, and backend data models. It also fixes several API paths, adds tenant awareness to multiple models, and makes minor UI adjustments.
2026-05-27 01:12:03 +08:00

52 lines
1.6 KiB
Python

from typing import Any
from app.api.v1.module_system.auth.schema import AuthSchema
from app.core.base_crud import CRUDBase
from .model import TicketModel
from .schema import TicketCreateSchema, TicketUpdateSchema
class TicketCRUD(CRUDBase[TicketModel, TicketCreateSchema, TicketUpdateSchema]):
"""工单 CRUD"""
def __init__(self, auth: AuthSchema) -> None:
self.auth = auth
super().__init__(model=TicketModel, auth=auth)
async def page_crud(
self,
offset: int,
limit: int,
order_by: list[dict[str, str]] | None,
search: dict | None = None,
out_schema: type | None = None,
preload: list[str | Any] | None = None,
) -> dict:
from .schema import TicketOutSchema
return await self.page(
offset=offset,
limit=limit,
order_by=order_by or [{"id": "asc"}],
search=search or {},
out_schema=out_schema or TicketOutSchema,
preload=preload,
)
async def get_by_id_crud(self, id: int) -> TicketModel | None:
return await self.get(id=id)
async def create_crud(self, data: TicketCreateSchema) -> TicketModel | None:
return await self.create(data=data)
async def update_crud(self, id: int, data: TicketUpdateSchema) -> TicketModel | None:
return await self.update(id=id, data=data)
async def delete_crud(self, ids: list[int]) -> None:
await self.delete(ids=ids)
async def set_crud(self, ids: list[int], **kwargs) -> None:
"""批量设置工单状态"""
await self.set(ids=ids, **kwargs)