from ast import List from iti.applications.extensions import db from iti.applications.common.crud import TimeModelMixin from iti.applications.common.utils import BaseSchema from apiflask.fields import String, Integer, DateTime, Nested, List class IotAlertPush(TimeModelMixin, db.Model): """ 告警推送表 """ __tablename__ = "iot_alert_push" id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment="标识") target_name = db.Column(db.String(255), nullable=False, comment="接收对象名称") push_url = db.Column(db.String(2048), nullable=False, comment="告警推送URL") alert_level = db.Column(db.String(255), nullable=False, comment="告警等级") status = db.Column(db.Integer, nullable=False, default=1, comment="状态 1-启用,0-禁用") class IotAlertPushSchema(BaseSchema): """ 告警推送表响应结构 """ class Meta: name = "IotAlertPush" id = Integer() target_name = String() push_url = String() alert_level = List(Integer()) status = Integer() created_at = DateTime(format="%Y-%m-%d %H:%M:%S") updated_at = DateTime(format="%Y-%m-%d %H:%M:%S")