daily/Models/UserModel.py

42 lines
2.0 KiB
Python

from sqlalchemy import Column, String, Boolean, Enum, Text, DateTime, func, Integer
from sqlalchemy.orm import relationship
from Utils.SqlAlchemyUtils import Base
class User(Base):
__tablename__ = "user"
openid = Column(String(255), comment="用户OpenID")
email = Column(String(255), primary_key=True, comment="邮箱")
phone = Column(String(255), comment="手机号")
name = Column(String(32), comment="用户名")
department = Column(Text, comment="部门")
post = Column(Text, comment="职务")
manage_departments = Column(Text, comment="所管部门")
disable = Column(Boolean, default=False, comment="禁用")
daily_fill_notice = Column(Boolean, default=True, 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}
class UserInfo(Base):
__tablename__ = "user_info"
email = Column(String(255), primary_key=True, index=True, comment="邮箱")
phone = Column(String(255), 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}