daily/Models/UserModel.py

41 lines
1.9 KiB
Python
Raw Normal View History

2023-02-28 13:52:51 +08:00
from sqlalchemy import Column, String, Boolean, Enum, Text, DateTime, func, Integer
2023-02-28 16:28:48 +08:00
from sqlalchemy.orm import relationship
2023-02-28 13:52:51 +08:00
from Utils.SqlAlchemyUtils import Base
class User(Base):
2023-02-28 16:28:48 +08:00
__tablename__ = "user"
2023-03-07 12:03:06 +08:00
# openid = Column(String(255), primary_key=True, comment="用户OpenID")
email = Column(String(255), primary_key=True, comment="邮箱")
2023-03-17 16:29:13 +08:00
phone = Column(String(255), comment="手机号")
2023-02-28 13:52:51 +08:00
name = Column(String(32), comment="用户名")
department = Column(Text, comment="部门")
post = Column(Text, comment="职务")
2023-04-03 17:04:48 +08:00
manage_departments = Column(Text, comment="所管部门")
2023-02-28 13:52:51 +08:00
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}
2023-03-02 09:27:05 +08:00
class UserInfo(Base):
__tablename__ = "user_info"
email = Column(String(255), primary_key=True, index=True, comment="邮箱")
2023-03-17 16:29:13 +08:00
phone = Column(String(255), comment="手机号")
2023-03-02 09:27:05 +08:00
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}