54 lines
2.2 KiB
Python
54 lines
2.2 KiB
Python
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(128), primary_key=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}
|
|
|
|
|
|
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}
|