daily/Models/DepartmentModel.py

19 lines
791 B
Python
Raw Permalink Normal View History

2023-03-01 16:04:43 +08:00
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)
2023-06-30 13:39:24 +08:00
sub_type = Column(String(255), comment="二级分类")
2023-07-06 00:52:27 +08:00
index = Column(Integer, comment="索引")
2023-03-01 16:04:43 +08:00
def to_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}