mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 12:52:26 +00:00
1. 统一移动代码生成模板到根目录templates目录,删除旧模板文件 2. 调整SQLAlchemy导入顺序,优化代码格式 3. 重构查询参数类,复用BaseQueryParam基础能力 4. 新增发票管理模块:添加weasyprint依赖,实现本地PDF发票渲染 5. 完善邮件、菜单等模块的代码实现与注释 6. 修复SQL查询条件写法,使用is_(True)替代==True 7. 补全模型类的UserMixin、TenantMixin继承与配置
31 lines
925 B
Python
31 lines
925 B
Python
from app.core.base_crud import CRUDBase
|
|
from app.core.base_schema import AuthSchema
|
|
|
|
from .model import InvoiceModel
|
|
from .schema import InvoiceCreateSchema, InvoiceUpdateSchema
|
|
|
|
|
|
class InvoiceCRUD(CRUDBase[InvoiceModel, InvoiceCreateSchema, InvoiceUpdateSchema]):
|
|
"""发票 CRUD —— 继承 CRUDBase 获得增删改查、软删除过滤、租户隔离、权限过滤"""
|
|
|
|
def __init__(self, auth: AuthSchema) -> None:
|
|
"""
|
|
初始化发票 CRUD
|
|
|
|
参数:
|
|
- auth (AuthSchema): 认证信息模型
|
|
"""
|
|
super().__init__(model=InvoiceModel, auth=auth)
|
|
|
|
async def get_by_order_id(self, order_id: int) -> InvoiceModel | None:
|
|
"""
|
|
根据订单 ID 查询发票
|
|
|
|
参数:
|
|
- order_id (int): 订单 ID
|
|
|
|
返回:
|
|
- InvoiceModel | None: 发票对象,不存在返回 None
|
|
"""
|
|
return await self.get(order_id=order_id)
|