from sqlalchemy import Column, String, Boolean, ForeignKey, Enum, Text, DateTime, func, Integer from Schemas.UserSchemas import DepartmentTypeEnum from Utils.SqlAlchemyUtils import Base class Department(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(Enum(DepartmentTypeEnum, values_callable=lambda x: [e.value for e in x]), nullable=False) sub_type = Column(String(255), comment="二级分类") index = Column(Integer, comment="索引") def to_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}