sysmodule.py 1.7 KB

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