40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
from enum import Enum
|
|
|
|
from sqlmodel import Field
|
|
|
|
from app.model.BasicModel import BasicModel
|
|
from app.utils.create_module_service import create_model_service
|
|
|
|
|
|
class UserValidate(str, Enum):
|
|
Y = 'Y'
|
|
N = 'N'
|
|
|
|
|
|
# 公共的,也是最后返回给前端的一个用户信息数据类型
|
|
class PublicUser(BasicModel):
|
|
username: str = Field(..., description="用户名")
|
|
email: str = Field(..., description="邮箱")
|
|
full_name: str = Field(..., description="用户全名")
|
|
valid: UserValidate = Field(default=UserValidate.N, description="用户账号是否已经激活")
|
|
|
|
|
|
# 注册的时候,客户端传入的用户信息,需要包含这个明文密码字段
|
|
class RegistryUser(PublicUser):
|
|
password: str
|
|
|
|
|
|
# 对pl_user表进行增删改查时的这个model类
|
|
class UserModel(PublicUser, table=True):
|
|
__tablename__ = "pl_user"
|
|
hash_password: str
|
|
|
|
|
|
# 对pl_user表进行增删改查时的这个model类
|
|
class UserServiceModel(PublicUser, table=True):
|
|
__tablename__ = "pl_user"
|
|
__table_args__ = {'extend_existing': True}
|
|
|
|
|
|
UserService = create_model_service(UserServiceModel)
|