role.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import datetime
  4. from sqlalchemy import Integer, Column, String, DateTime, Text, UniqueConstraint
  5. from db.base import Base
  6. class Role(Base):
  7. """角色
  8. """
  9. id = Column(Integer, primary_key=True, autoincrement=True)
  10. name = Column(String(128), nullable=False)
  11. remark = Column(String(255), nullable=True)
  12. platform = Column(String(50), nullable=True, comment="平台")
  13. permission_codes = Column(Text, nullable=True, comment="权限集合")
  14. creator_id = Column(Integer, comment="创建人ID")
  15. creator_name = Column(String(32), comment="创建人名称")
  16. created_at = Column(DateTime, default=datetime.datetime.now)
  17. editor_id = Column(Integer, comment="最后编辑人ID")
  18. editor_name = Column(String(32), comment="最后编辑人名称")
  19. updated_at = Column(DateTime,
  20. default=datetime.datetime.now,
  21. onupdate=datetime.datetime.now)
  22. __tablename__ = "sys_role"
  23. __table_args__ = (UniqueConstraint("name", name="uix_sysrole_name"),)
  24. class Permission(Base):
  25. """权限表
  26. """
  27. id = Column(Integer, primary_key=True, autoincrement=True)
  28. name = Column(String(128), nullable=False)
  29. codename = Column(String(255), nullable=True, comment="权限代码")
  30. remark = Column(String(255), nullable=True)
  31. api = Column(String(255), nullable=True)
  32. method = Column(String(255), nullable=True)
  33. platform = Column(String(50), nullable=True, comment="平台")
  34. order = Column(Integer, nullable=True, comment="排序字段", default=0)
  35. __tablename__ = "sys_permission"
  36. __table_args__ = (UniqueConstraint("name", name="uix_sysperms_name"),)