mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 21:15:13 +00:00
Update api body params to schema (#461)
This commit is contained in:
@@ -11,7 +11,7 @@ from backend.common.schema import SchemaBase
|
||||
class ApiSchemaBase(SchemaBase):
|
||||
name: str
|
||||
method: MethodType = Field(default=MethodType.GET, description='请求方法')
|
||||
path: str = Field(..., description='api路径')
|
||||
path: str = Field(description='api路径')
|
||||
remark: str | None = None
|
||||
|
||||
|
||||
|
||||
@@ -7,13 +7,19 @@ from backend.common.schema import SchemaBase
|
||||
|
||||
|
||||
class CreatePolicyParam(SchemaBase):
|
||||
sub: str = Field(..., description='用户uuid / 角色ID')
|
||||
path: str = Field(..., description='api 路径')
|
||||
sub: str = Field(description='用户uuid / 角色ID')
|
||||
path: str = Field(description='api 路径')
|
||||
method: MethodType = Field(default=MethodType.GET, description='请求方法')
|
||||
|
||||
|
||||
class UpdatePolicyParam(CreatePolicyParam):
|
||||
pass
|
||||
class UpdatePolicyParam(SchemaBase):
|
||||
old: CreatePolicyParam
|
||||
new: CreatePolicyParam
|
||||
|
||||
|
||||
class UpdatePoliciesParam(SchemaBase):
|
||||
old: list[CreatePolicyParam]
|
||||
new: list[CreatePolicyParam]
|
||||
|
||||
|
||||
class DeletePolicyParam(CreatePolicyParam):
|
||||
@@ -26,8 +32,8 @@ class DeleteAllPoliciesParam(SchemaBase):
|
||||
|
||||
|
||||
class CreateUserRoleParam(SchemaBase):
|
||||
uuid: str = Field(..., description='用户 uuid')
|
||||
role: str = Field(..., description='角色')
|
||||
uuid: str = Field(description='用户 uuid')
|
||||
role: str = Field(description='角色')
|
||||
|
||||
|
||||
class DeleteUserRoleParam(CreateUserRoleParam):
|
||||
@@ -38,9 +44,9 @@ class GetPolicyListDetails(SchemaBase):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
ptype: str = Field(..., description='规则类型, p / g')
|
||||
v0: str = Field(..., description='用户 uuid / 角色')
|
||||
v1: str = Field(..., description='api 路径 / 角色')
|
||||
ptype: str = Field(description='规则类型, p / g')
|
||||
v0: str = Field(description='用户 uuid / 角色')
|
||||
v1: str = Field(description='api 路径 / 角色')
|
||||
v2: str | None = None
|
||||
v3: str | None = None
|
||||
v4: str | None = None
|
||||
|
||||
@@ -22,21 +22,21 @@ class AuthLoginParam(AuthSchemaBase):
|
||||
|
||||
class RegisterUserParam(AuthSchemaBase):
|
||||
nickname: str | None = None
|
||||
email: EmailStr = Field(..., examples=['user@example.com'])
|
||||
email: EmailStr = Field(examples=['user@example.com'])
|
||||
|
||||
|
||||
class AddUserParam(AuthSchemaBase):
|
||||
dept_id: int
|
||||
roles: list[int]
|
||||
nickname: str | None = None
|
||||
email: EmailStr = Field(..., examples=['user@example.com'])
|
||||
email: EmailStr = Field(examples=['user@example.com'])
|
||||
|
||||
|
||||
class UserInfoSchemaBase(SchemaBase):
|
||||
dept_id: int | None = None
|
||||
username: str
|
||||
nickname: str
|
||||
email: EmailStr = Field(..., examples=['user@example.com'])
|
||||
email: EmailStr = Field(examples=['user@example.com'])
|
||||
phone: CustomPhoneNumber | None = None
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class UpdateUserRoleParam(SchemaBase):
|
||||
|
||||
|
||||
class AvatarParam(SchemaBase):
|
||||
url: HttpUrl = Field(..., description='头像 http 地址')
|
||||
url: HttpUrl = Field(description='头像 http 地址')
|
||||
|
||||
|
||||
class GetUserInfoNoRelationDetail(UserInfoSchemaBase):
|
||||
|
||||
Reference in New Issue
Block a user