Files
effekt-interface/app/api/model/userModel.py
2026-05-07 19:21:19 +08:00

34 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from sqlalchemy import BigInteger, Column, Integer, SmallInteger, String, TIMESTAMP, text
from sqlalchemy.ext.declarative import declarative_base
from common.sqlSession import to_dict
Base = declarative_base()
Base.to_dict = to_dict
class User(Base):
__tablename__ = 'user'
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='id')
username = Column(String(64), unique=True, nullable=False, comment='登录用户名')
real_name = Column(String(64), comment='真实姓名')
password_hash = Column(String(255), nullable=False, comment='密码哈希')
mobile = Column(String(32), comment='手机号')
email = Column(String(128), comment='邮箱')
avatar = Column(String(255), comment='头像地址')
status = Column(SmallInteger, default=1, comment='1:启用 0:禁用')
last_login_time = Column(TIMESTAMP, nullable=True, comment='最后登录时间')
created_by = Column(BigInteger, comment='创建人')
is_delete = Column(Integer, default=0, comment='0未删除1已删除')
created_time = Column(TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'), nullable=True, comment='创建时间')
updated_time = Column(TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'), server_onupdate=text('CURRENT_TIMESTAMP'), nullable=True, comment='修改时间')
class UserRole(Base):
__tablename__ = 'user_role'
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='id')
user_id = Column(BigInteger, nullable=False, comment='用户id')
role_id = Column(BigInteger, nullable=False, comment='角色id')
is_delete = Column(Integer, default=0, comment='0未删除1已删除')
created_time = Column(TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'), nullable=True, comment='创建时间')