from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime, Table, ForeignKey, UniqueConstraint
from app.models.base_model import Base



class WebMenuModel(Base):
    __tablename__ = 'web_menu'
    id = Column(Integer, primary_key=True, index=True)
    title = Column(String(128))
    describe = Column(String(1000))
    desc = Column(String(1000))
    icon = Column(String(16))
    img = Column(String(255))
    rank = Column(Integer)


    def to_dict(self):
        return {
            'id': self.id,
            'title': self.title,
            'icon': self.icon,
            'img': self.img,
            'desc': self.desc,
            'dialog': self.describe
        }

    def __repr__(self):
        return '<Role name:%r description:%r iconCls:%r seq:%r>\n' \
            % (self.NAME, self.DESCRIPTION, self.ICONCLS, self.SEQ)


class MenuCapacityModel(Base):
    __tablename__ = 'menu_capacity'
    __table_args__ = (UniqueConstraint('menu_id', 'capacity_id', name='menu_capacity_id_ix'),)
    id = Column(Integer, primary_key=True, index=True)
    menu_id = Column(Integer)
    capacity_id = Column(String(36))
    capacity_type = Column(Integer)
    chat_id = Column(String(36))
    chat_type = Column(String(36))

