97 lines
2.7 KiB
JavaScript
97 lines
2.7 KiB
JavaScript
/**
|
|
* 智能预警模块 Swagger 文档
|
|
* @file swagger-smart-alerts.js
|
|
* @description 智能预警相关的 Swagger API 文档定义
|
|
*/
|
|
|
|
// 智能预警相关的 API 路径定义
|
|
const smartAlertsPaths = {
|
|
'/api/smart-alerts': {
|
|
get: {
|
|
summary: '获取所有智能预警',
|
|
tags: ['智能预警'],
|
|
parameters: [
|
|
{ $ref: '#/components/parameters/PageParam' },
|
|
{ $ref: '#/components/parameters/LimitParam' },
|
|
{ $ref: '#/components/parameters/SearchParam' }
|
|
],
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' }
|
|
}
|
|
}
|
|
},
|
|
'/api/smart-alerts/{id}': {
|
|
get: {
|
|
summary: '根据ID获取智能预警',
|
|
tags: ['智能预警'],
|
|
parameters: [{ $ref: '#/components/parameters/IdParam' }],
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' },
|
|
404: { $ref: '#/components/responses/NotFound' }
|
|
}
|
|
},
|
|
put: {
|
|
summary: '更新智能预警状态',
|
|
tags: ['智能预警'],
|
|
parameters: [{ $ref: '#/components/parameters/IdParam' }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
status: {
|
|
type: 'string',
|
|
enum: ['pending', 'processing', 'resolved', 'ignored'],
|
|
description: '预警状态'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' },
|
|
404: { $ref: '#/components/responses/NotFound' }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// 智能预警相关的数据模型定义
|
|
const smartAlertsSchemas = {
|
|
SmartAlert: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer', description: '智能预警ID' },
|
|
alertType: {
|
|
type: 'string',
|
|
enum: ['battery', 'offline', 'temperature', 'movement', 'wear'],
|
|
description: '预警类型'
|
|
},
|
|
alertLevel: {
|
|
type: 'string',
|
|
enum: ['high', 'medium', 'low'],
|
|
description: '预警级别'
|
|
},
|
|
status: {
|
|
type: 'string',
|
|
enum: ['pending', 'processing', 'resolved', 'ignored'],
|
|
description: '预警状态'
|
|
},
|
|
deviceId: { type: 'string', description: '设备编号' },
|
|
animalId: { type: 'integer', description: '动物ID' },
|
|
message: { type: 'string', description: '预警消息' },
|
|
createdAt: { type: 'string', format: 'date-time', description: '创建时间' },
|
|
updatedAt: { type: 'string', format: 'date-time', description: '更新时间' }
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
smartAlertsPaths,
|
|
smartAlertsSchemas
|
|
};
|
|
|