55
66import sqlalchemy as sa
77
8- from sqlalchemy .dialects .mysql import TINYINT
9- from sqlalchemy .dialects .postgresql import BYTEA
108from sqlalchemy .orm import Mapped , mapped_column , relationship
119
1210from backend .app .admin .model .m2m import sys_user_role
@@ -28,28 +26,22 @@ class User(Base):
2826 username : Mapped [str ] = mapped_column (sa .String (20 ), unique = True , index = True , comment = '用户名' )
2927 nickname : Mapped [str ] = mapped_column (sa .String (20 ), comment = '昵称' )
3028 password : Mapped [str | None ] = mapped_column (sa .String (255 ), comment = '密码' )
31- salt : Mapped [bytes | None ] = mapped_column (BYTEA ( 255 ). with_variant ( sa .VARBINARY , 'mysql' ), comment = '加密盐' )
29+ salt : Mapped [bytes | None ] = mapped_column (sa .LargeBinary ( 255 ), comment = '加密盐' )
3230 email : Mapped [str | None ] = mapped_column (sa .String (50 ), default = None , unique = True , index = True , comment = '邮箱' )
3331 phone : Mapped [str | None ] = mapped_column (sa .String (11 ), default = None , comment = '手机号' )
3432 avatar : Mapped [str | None ] = mapped_column (sa .String (255 ), default = None , comment = '头像' )
3533 status : Mapped [int ] = mapped_column (default = 1 , index = True , comment = '用户账号状态(0停用 1正常)' )
36- is_superuser : Mapped [bool ] = mapped_column (
37- sa .INTEGER ().with_variant (TINYINT , 'mysql' ), default = False , comment = '超级权限(0否 1是)'
38- )
39- is_staff : Mapped [bool ] = mapped_column (
40- sa .INTEGER ().with_variant (TINYINT , 'mysql' ), default = False , comment = '后台管理登陆(0否 1是)'
41- )
42- is_multi_login : Mapped [bool ] = mapped_column (
43- sa .INTEGER ().with_variant (TINYINT , 'mysql' ), default = False , comment = '是否重复登陆(0否 1是)'
44- )
34+ is_superuser : Mapped [bool ] = mapped_column (default = False , comment = '超级权限(0否 1是)' )
35+ is_staff : Mapped [bool ] = mapped_column (default = False , comment = '后台管理登陆(0否 1是)' )
36+ is_multi_login : Mapped [bool ] = mapped_column (default = False , comment = '是否重复登陆(0否 1是)' )
4537 join_time : Mapped [datetime ] = mapped_column (TimeZone , init = False , default_factory = timezone .now , comment = '注册时间' )
4638 last_login_time : Mapped [datetime | None ] = mapped_column (
4739 TimeZone , init = False , onupdate = timezone .now , comment = '上次登录'
4840 )
4941
5042 # 部门用户一对多
5143 dept_id : Mapped [int | None ] = mapped_column (
52- sa .ForeignKey ('sys_dept.id' , ondelete = 'SET NULL' ), default = None , comment = '部门关联ID'
44+ sa .BigInteger , sa . ForeignKey ('sys_dept.id' , ondelete = 'SET NULL' ), default = None , comment = '部门关联ID'
5345 )
5446 dept : Mapped [Dept | None ] = relationship (init = False , back_populates = 'users' )
5547
0 commit comments