ref: response schema file
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
from schemas.common import *
|
||||
from schemas.menu import *
|
||||
from schemas.role import *
|
||||
from schemas.user import *
|
||||
|
@@ -1,5 +1,6 @@
|
||||
"""公共模型"""
|
||||
from typing import Generic, TypeVar
|
||||
from datetime import datetime
|
||||
from typing import Generic, Optional, TypeVar
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic.generics import GenericModel
|
||||
@@ -7,6 +8,21 @@ from pydantic.generics import GenericModel
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class Response(GenericModel, Generic[T]):
|
||||
code: int = 200
|
||||
data: Optional[T]
|
||||
msg: str = "请求成功"
|
||||
|
||||
|
||||
class ReadBase(BaseModel):
|
||||
"""数据读取的基类"""
|
||||
|
||||
id: int
|
||||
status: int = Field(default=1, description="数据状态 1正常默认值 9 删除 5使用中 ")
|
||||
created: datetime
|
||||
modified: datetime
|
||||
|
||||
|
||||
class LoginForm(BaseModel):
|
||||
"""用户登录参数"""
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from tortoise.contrib.pydantic import pydantic_model_creator
|
||||
|
||||
from core import ReadBase
|
||||
from models import RoleModel
|
||||
from schemas.common import ReadBase
|
||||
|
||||
RoleRed = pydantic_model_creator(RoleModel, name="RoleOut")
|
||||
|
||||
|
@@ -8,7 +8,7 @@ from schemas.common import QueryData
|
||||
|
||||
UserRole = pydantic_model_creator(UserRoleModel, name="UserRole", exclude_readonly=True)
|
||||
|
||||
from core import ReadBase
|
||||
from schemas.common import ReadBase
|
||||
|
||||
|
||||
class UserBasic(BaseModel):
|
||||
|
Reference in New Issue
Block a user