diff --git a/backend/app/admin/schema/user.py b/backend/app/admin/schema/user.py index 2b3b84a6..a120d8bf 100644 --- a/backend/app/admin/schema/user.py +++ b/backend/app/admin/schema/user.py @@ -3,6 +3,7 @@ from datetime import datetime from pydantic import ConfigDict, EmailStr, Field, HttpUrl, model_validator +from typing_extensions import Self from backend.app.admin.schema.dept import GetDeptListDetails from backend.app.admin.schema.role import GetRoleListDetails @@ -21,21 +22,21 @@ class AuthLoginParam(AuthSchemaBase): class RegisterUserParam(AuthSchemaBase): nickname: str | None = None - email: EmailStr = Field(..., example='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(..., example='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(..., example='user@example.com') + email: EmailStr = Field(..., examples=['user@example.com']) phone: CustomPhoneNumber | None = None @@ -80,7 +81,7 @@ class GetCurrentUserInfoDetail(GetUserInfoListDetails): roles: list[GetRoleListDetails] | list[str] | None = None @model_validator(mode='after') - def handel(self, values): + def handel(self) -> Self: """处理部门和角色""" dept = self.dept if dept: @@ -88,7 +89,7 @@ def handel(self, values): roles = self.roles if roles: self.roles = [role.name for role in roles] # type: ignore - return values + return self class CurrentUserIns(GetUserInfoListDetails): diff --git a/backend/app/generator/schema/gen_business.py b/backend/app/generator/schema/gen_business.py index 9c7c3ac9..404b6bfc 100644 --- a/backend/app/generator/schema/gen_business.py +++ b/backend/app/generator/schema/gen_business.py @@ -3,6 +3,7 @@ from datetime import datetime from pydantic import ConfigDict, Field, model_validator +from typing_extensions import Self from backend.app.generator.schema.gen_model import GetGenModelListDetails from backend.common.schema import SchemaBase @@ -21,7 +22,7 @@ class GenBusinessSchemaBase(SchemaBase): remark: str | None = None @model_validator(mode='after') - def check_schema_name(self): + def check_schema_name(self) -> Self: if self.schema_name is None: self.schema_name = self.table_name_en return self