31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""sys_user 统一用户表 ORM 模型(客户与员工共用账号体系)。"""
|
|||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
from sqlalchemy import BigInteger, DateTime, String, func
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
|
||
|
|
from model.base import Base
|
||
|
|
|
||
|
|
|
||
|
|
class SysUser(Base):
|
||
|
|
__tablename__ = "sys_user"
|
||
|
|
__table_args__ = {"comment": "统一用户表(客户与员工共用账号体系)"}
|
||
|
|
|
||
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||
|
|
username: Mapped[str] = mapped_column(String(64), unique=True)
|
||
|
|
password_hash: Mapped[str] = mapped_column(String(255))
|
||
|
|
salt: Mapped[str | None] = mapped_column(String(32))
|
||
|
|
real_name: Mapped[str | None] = mapped_column(String(32))
|
||
|
|
phone: Mapped[str] = mapped_column(String(20))
|
||
|
|
user_type: Mapped[str] = mapped_column(String(16), server_default="CUSTOMER")
|
||
|
|
employee_role: Mapped[str | None] = mapped_column(String(32))
|
||
|
|
customer_level: Mapped[str | None] = mapped_column(String(16))
|
||
|
|
status: Mapped[str] = mapped_column(String(16), server_default="正常")
|
||
|
|
create_time: Mapped[datetime] = mapped_column(
|
||
|
|
DateTime, server_default=func.now()
|
||
|
|
)
|
||
|
|
update_time: Mapped[datetime] = mapped_column(
|
||
|
|
DateTime, server_default=func.now(), onupdate=func.now()
|
||
|
|
)
|