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

61 lines
2.4 KiB
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"
2023-03-14 13:56:24 +08:00
email = Column(String(128), primary_key=True, comment="邮箱")
2023-03-21 16:28:32 +08:00
phone = Column(String(255), comment="手机号")
2023-03-14 11:16:57 +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}
class Department(common_db.Base):
__tablename__ = "department"
id = Column(Integer, primary_key=True, comment="部门id")
name = Column(String(32), comment="部门名称")
belong = Column(Integer, comment="上级部门")
auth_data = Column(Text, comment="部门权限数据")
type = Column(String(128), comment="部门所属类型")
def to_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class Post(common_db.Base):
__tablename__ = "post"
id = Column(Integer, primary_key=True, comment="职务id")
name = Column(String(32), comment="职务名称")
belong = Column(Integer, comment="所属部门")
auth_data = Column(Text, comment="部门权限数据")
def to_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class AuthRule(common_db.Base):
__tablename__ = "auth_rule"
id = Column(Integer, primary_key=True, comment="权限规则id")
name = Column(String(32), comment="权限规则名称")
category1 = Column(String(64), comment="一级分类")
category2 = Column(String(64), comment="二级分类")
def to_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
2023-03-22 09:24:16 +08:00
class UserFile(common_db.Base):
__tablename__ = "user_file"
id = Column(Integer, primary_key=True, comment="权限规则id")
user = Column(String(255), comment="用户名")
name = Column(String(255), comment="文件名")