urban-investment-research/Mods/User/Models.py

19 lines
883 B
Python
Raw Normal View History

2023-03-14 11:16:57 +08:00
from sqlalchemy import Column, String, Boolean, Enum, Text, DateTime, func, Integer
from Context.common import common_db
class User(common_db.Base):
__tablename__ = "user"
email = Column(String(255), primary_key=True, comment="邮箱")
name = Column(String(32), comment="用户名")
department = Column(Text, comment="部门")
post = Column(Text, comment="职务")
disable = Column(Boolean, default=False, comment="禁用")
auth_data = Column(Text, comment="权限数据")
registered = Column(Boolean, default=False, comment="用户是否注册入app")
create_time = Column(DateTime, server_default=func.now(), comment='创建时间')
update_time = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment='修改时间')
def to_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}