85 lines
2.3 KiB
Python
85 lines
2.3 KiB
Python
![]() |
from pydantic import BaseModel
|
|||
|
from typing import Optional
|
|||
|
|
|||
|
|
|||
|
# 数据模型基类: ImsUserapiCacheBase,用于描述基础字段的类型、用途和注意点
|
|||
|
class ImsUserapiCacheBase(BaseModel):
|
|||
|
key: str # 对应数据库中的key字段
|
|||
|
content: str # 对应数据库中的content字段
|
|||
|
lastupdate: int # 对应数据库中的lastupdate字段
|
|||
|
|
|||
|
|
|||
|
class ImsUserapiCacheCreate(ImsUserapiCacheBase):
|
|||
|
"""
|
|||
|
用于创建新的ims_userapi_cache记录:
|
|||
|
- 继承自ImsUserapiCacheBase,不额外添加字段
|
|||
|
- 仅表示此Schema专用于'创建'场景
|
|||
|
"""
|
|||
|
pass
|
|||
|
|
|||
|
|
|||
|
class ImsUserapiCacheUpdate(BaseModel):
|
|||
|
"""
|
|||
|
用于更新已有ims_userapi_cache记录:
|
|||
|
- 只包含可选字段,未在此处的内容将保持不变
|
|||
|
- 注意: exclude_unset=True 可以避免更新空值
|
|||
|
"""
|
|||
|
key: Optional[str]
|
|||
|
content: Optional[str]
|
|||
|
|
|||
|
|
|||
|
class ImsUserapiCache(ImsUserapiCacheBase):
|
|||
|
"""
|
|||
|
表示完整的ims_userapi_cache记录:
|
|||
|
- id: 数据库主键ID
|
|||
|
- 包含所有字段的最终模型,ORM转换时使用
|
|||
|
"""
|
|||
|
acid: int # 表中的主键ID
|
|||
|
|
|||
|
class Config:
|
|||
|
orm_mode = True
|
|||
|
|
|||
|
|
|||
|
# 数据模型基类: ImsUserapiReplyBase,用于描述基础字段的类型、用途和注意点
|
|||
|
class ImsUserapiReplyBase(BaseModel):
|
|||
|
rid: int
|
|||
|
description: str
|
|||
|
apiurl: str
|
|||
|
token: str
|
|||
|
default_text: str
|
|||
|
cachetime: int
|
|||
|
|
|||
|
|
|||
|
class ImsUserapiReplyCreate(ImsUserapiReplyBase):
|
|||
|
"""
|
|||
|
用于创建新的ims_userapi_reply记录:
|
|||
|
- 继承自ImsUserapiReplyBase,不额外添加字段
|
|||
|
- 仅表示此Schema专用于'创建'场景
|
|||
|
"""
|
|||
|
pass
|
|||
|
|
|||
|
|
|||
|
class ImsUserapiReplyUpdate(BaseModel):
|
|||
|
"""
|
|||
|
用于更新已有ims_userapi_reply记录:
|
|||
|
- 只包含可选字段,未在此处的内容将保持不变
|
|||
|
- 注意: exclude_unset=True 可以避免更新空值
|
|||
|
"""
|
|||
|
rid: Optional[int]
|
|||
|
description: Optional[str]
|
|||
|
apiurl: Optional[str]
|
|||
|
token: Optional[str]
|
|||
|
default_text: Optional[str]
|
|||
|
cachetime: Optional[int]
|
|||
|
|
|||
|
|
|||
|
class ImsUserapiReply(ImsUserapiReplyBase):
|
|||
|
"""
|
|||
|
表示完整的ims_userapi_reply记录:
|
|||
|
- id: 数据库主键ID
|
|||
|
- 包含所有字段的最终模型,ORM转换时使用
|
|||
|
"""
|
|||
|
adid: int # 表中的主键ID
|
|||
|
|
|||
|
class Config:
|
|||
|
orm_mode = True
|