forked from iti-framework/iTi-Flask
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.
69 lines
2.2 KiB
Python
69 lines
2.2 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="标识",
|
|
)
|
|
device_id = db.Column(db.Integer, nullable=False, default=0, unique=True, comment="设备ID")
|
|
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="采集端端口")
|
|
brand_name = db.Column(db.String(255), nullable=False, comment="品牌名称")
|
|
specification_model = db.Column(db.String(255), nullable=False, comment="规格型号")
|
|
status = db.Column(db.Integer, nullable=False, default=0, comment="状态 0:停用 1:运行中 2:维修中")
|
|
#关系
|
|
device = db.relationship(
|
|
"IotDevice",
|
|
primaryjoin="foreign(IotEndpoint.device_id) == IotDevice.id",
|
|
)
|
|
|
|
|
|
class IotEndpointSchema(BaseSchema):
|
|
"""
|
|
采集端信息表响应结构
|
|
"""
|
|
class Meta:
|
|
name = "IotEndpoint"
|
|
|
|
id = Integer()
|
|
device_id = Integer()
|
|
endpoint_name = String()
|
|
endpoint_number = String()
|
|
description = String()
|
|
ip = String()
|
|
port = String()
|
|
brand_name = String()
|
|
specification_model = String()
|
|
status = Integer()
|
|
created_at = DateTime(format="%Y-%m-%d %H:%M:%S")
|
|
updated_at = DateTime(format="%Y-%m-%d %H:%M:%S")
|
|
#关系
|
|
device = Nested("IotDeviceSimpleSchema")
|
|
|
|
|
|
class IotEndpointSimpleSchema(BaseSchema):
|
|
"""
|
|
采集端信息表联合查询响应结构
|
|
"""
|
|
class Meta:
|
|
name = "IotEndpoint"
|
|
|
|
id = Integer()
|
|
endpoint_name = String()
|
|
endpoint_number = String()
|
|
#关系
|
|
device = Nested("IotDeviceSimpleSchema") |