menu_model.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from datetime import datetime
  2. from sqlalchemy import Column, Integer, String, DateTime, Table, ForeignKey, UniqueConstraint
  3. from app.models.base_model import Base
  4. class WebMenuModel(Base):
  5. __tablename__ = 'web_menu'
  6. id = Column(Integer, primary_key=True, index=True)
  7. title = Column(String(128))
  8. describe = Column(String(1000))
  9. desc = Column(String(1000))
  10. icon = Column(String(16))
  11. img = Column(String(255))
  12. rank = Column(Integer)
  13. def to_dict(self):
  14. return {
  15. 'id': self.id,
  16. 'title': self.title,
  17. 'icon': self.icon,
  18. 'img': self.img,
  19. 'desc': self.desc,
  20. 'dialog': self.describe
  21. }
  22. def __repr__(self):
  23. return '<Role name:%r description:%r iconCls:%r seq:%r>\n' \
  24. % (self.NAME, self.DESCRIPTION, self.ICONCLS, self.SEQ)
  25. class MenuCapacityModel(Base):
  26. __tablename__ = 'menu_capacity'
  27. __table_args__ = (UniqueConstraint('menu_id', 'capacity_id', name='menu_capacity_id_ix'),)
  28. id = Column(Integer, primary_key=True, index=True)
  29. menu_id = Column(Integer)
  30. capacity_id = Column(String(36))
  31. capacity_type = Column(Integer)
  32. chat_id = Column(String(36))
  33. chat_type = Column(String(36))