sysmodule.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import datetime
  4. from sqlalchemy import (Integer, Column, String, BOOLEAN, DateTime,
  5. UniqueConstraint)
  6. from db.base import Base
  7. class SysModule(Base):
  8. id = Column(Integer, primary_key=True, autoincrement=True)
  9. name = Column(String(32), nullable=False, comment="模块名称")
  10. pid = Column(Integer, default=0, comment="上级模块ID")
  11. level = Column(Integer, nullable=False, default=0, comment="模块层级")
  12. creator = Column(Integer, comment="创建人")
  13. editor = Column(Integer, comment="最后编辑人")
  14. created_at = Column(DateTime, default=datetime.datetime.now)
  15. updated_at = Column(DateTime,
  16. default=datetime.datetime.now,
  17. onupdate=datetime.datetime.now)
  18. __table_args__ = (UniqueConstraint("name",
  19. "pid",
  20. "level",
  21. name="uix_name_pid_level"),)
  22. class SysAPI(Base):
  23. id = Column(Integer, primary_key=True, autoincrement=True)
  24. name = Column(String(32), nullable=False, comment="接口名称")
  25. path = Column(String(128), nullable=False, comment="接口路径")
  26. method = Column(String(10), nullable=False, comment="接口方法")
  27. module_id = Column(Integer, nullable=False, comment="所属模块ID")
  28. is_active = Column(BOOLEAN(), default=True, comment="是否激活")
  29. creator = Column(Integer, comment="创建人")
  30. editor = Column(Integer, comment="最后编辑人")
  31. created_at = Column(DateTime, default=datetime.datetime.now)
  32. updated_at = Column(DateTime,
  33. default=datetime.datetime.now,
  34. onupdate=datetime.datetime.now)
  35. __table_args__ = (UniqueConstraint("module_id",
  36. "path",
  37. "method",
  38. name="uix_module_path_method"),)