You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iTi-Flask/iti/applications/models/iot/iot_endpoint.py

61 lines
2.1 KiB
Python

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
class IotEndpoint(db.Model, TimeModelMixin):
"""
采集端信息表
"""
__tablename__ = "iot_endpoint"
id = db.Column(
db.Integer,
primary_key=True,
autoincrement=True,
comment="标识",
)
endpoint_name = db.Column(db.String(255), nullable=False, unique=True, comment="采集端名称")
endpoint_number = db.Column(db.String(20), nullable=False, comment="采集端编号")
description = db.Column(db.Text, nullable=True, comment="采集端描述")
ip = db.Column(db.String(255), nullable=False, comment="采集端IP")
port = db.Column(db.String(255), nullable=False, comment="采集端端口")
opc_url_temp = db.Column(db.String(1024), nullable=False, comment="OPC URL模板")
brand_name = db.Column(db.String(255), nullable=False, comment="品牌名称")
specification_model = db.Column(db.String(255), nullable=False, comment="规格型号")
is_online = db.Column(db.Integer, nullable=False, default=0, comment="在线状态 0:离线 1:在线")
status = db.Column(db.Integer, nullable=False, default=0, comment="状态 0:停用 1:运行中 2:维修中")
class IotEndpointSchema(BaseSchema):
"""
采集端信息表响应结构
"""
class Meta:
name = "IotEndpoint"
id = Integer()
endpoint_name = String()
endpoint_number = String()
description = String()
ip = String()
port = String()
opc_url_temp = String()
brand_name = String()
specification_model = String()
is_online = Integer()
status = Integer()
created_at = DateTime(format="%Y-%m-%d %H:%M:%S")
updated_at = DateTime(format="%Y-%m-%d %H:%M:%S")
class IotEndpointSimpleSchema(BaseSchema):
"""
采集端信息表联合查询响应结构
"""
class Meta:
name = "IotEndpoint"
endpoint_name = String()
endpoint_number = String()