|
@@ -7,19 +7,69 @@
|
|
|
"""
|
|
|
from sqlmodel import Field, Relationship, SQLModel
|
|
|
|
|
|
-
|
|
|
class UserBase(SQLModel):
|
|
|
- email: str = Field(unique=True, index=True)
|
|
|
+ """ Shared properties """
|
|
|
+ email: str = Field(unique=True, index=True, description="用户邮箱")
|
|
|
+ user_name: str | None = None
|
|
|
is_active: bool = True
|
|
|
is_superuser: bool = False
|
|
|
- full_name: str | None = None
|
|
|
-
|
|
|
|
|
|
class User(UserBase, table=True):
|
|
|
+ """ User model """
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
|
|
hashed_password: str
|
|
|
- items: list["Item"] = Relationship(back_populates="owner")
|
|
|
-
|
|
|
+ nick_name = Field(nullable=True, default=None, description="用户昵称")
|
|
|
+ sex: str = Field(nullable=True, default=None, description="用户性别")
|
|
|
+ identity_card: str = Field(nullable=True, default=None, description="用户身份证")
|
|
|
+ phone: str | None = Field(nullable=True, default=None, description="用户电话")
|
|
|
+ address: str | None = Field(nullable=True, default=None, description="用户地址")
|
|
|
+ avatar: str | None = Field(nullable=True, default=None, description="用户头像")
|
|
|
+ introduction: str | None = Field(nullable=True, default=None, description="用户简介")
|
|
|
+ create_time: str = Field(nullable=True, default=None, description="创建时间")
|
|
|
+ update_time: str = Field(nullable=True, default=None, description="更新时间")
|
|
|
+ last_login_ip: str = Field(nullable=True, default=None, description="最后登录IP")
|
|
|
+ last_login_time: str = Field(nullable=True, default=None, description="最后登录时间")
|
|
|
+ money: float = Field(nullable=True, default=None, description="用户余额")
|
|
|
+ fee: float = Field(nullable=True, default=None, description="用户费用")
|
|
|
+ max_shop_num: int = Field(nullable=True, default=None, description="最大店铺数量")
|
|
|
+
|
|
|
+ items: list = Relationship(back_populates="owner")
|
|
|
+
|
|
|
+class Permission(SQLModel):
|
|
|
+ """ 权限表 """
|
|
|
+ id: int = Field(primary_key=True, index=True)
|
|
|
+ permission_name: str = Field(max_length=50, index=True)
|
|
|
+ description: str = Field(max_length=255)
|
|
|
+ create_time: str = Field(max_length=50)
|
|
|
+ update_time: str = Field(max_length=50)
|
|
|
+ is_active: bool = Field(default=True)
|
|
|
+
|
|
|
+class Role(SQLModel):
|
|
|
+ """ 角色表 """
|
|
|
+ id: int = Field(primary_key=True, index=True)
|
|
|
+ role_name: str = Field(max_length=50, index=True)
|
|
|
+ description: str = Field(max_length=255)
|
|
|
+ create_time: str = Field(max_length=50)
|
|
|
+ update_time: str = Field(max_length=50)
|
|
|
+ is_active: bool = Field(default=True)
|
|
|
+
|
|
|
+class UserRole(SQLModel):
|
|
|
+ """ 用户-角色表 """
|
|
|
+ id: int = Field(primary_key=True, index=True)
|
|
|
+ user_id: int = Field(index=True)
|
|
|
+ role_id: int = Field(index=True)
|
|
|
+ create_time: str = Field(max_length=50)
|
|
|
+ update_time: str = Field(max_length=50)
|
|
|
+ is_active: bool = Field(default=True)
|
|
|
+
|
|
|
+class RolePermission(SQLModel):
|
|
|
+ """ 角色-权限表 """
|
|
|
+ id: int = Field(primary_key=True, index=True)
|
|
|
+ role_id: int = Field(index=True)
|
|
|
+ permission_id: int = Field(index=True)
|
|
|
+ create_time: str = Field(max_length=50)
|
|
|
+ update_time: str = Field(max_length=50)
|
|
|
+ is_active: bool = Field(default=True)
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
|
class UserCreate(UserBase):
|