添加后台启动脚本和修改域名
This commit is contained in:
117
backend/swagger-alerts.js
Normal file
117
backend/swagger-alerts.js
Normal file
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* 预警管理模块 Swagger 文档
|
||||
* @file swagger-alerts.js
|
||||
* @description 预警管理相关的 Swagger API 文档定义
|
||||
*/
|
||||
|
||||
// 预警管理相关的 API 路径定义
|
||||
const alertsPaths = {
|
||||
'/api/alerts': {
|
||||
get: {
|
||||
summary: '获取所有预警',
|
||||
tags: ['预警管理'],
|
||||
parameters: [
|
||||
{ $ref: '#/components/parameters/PageParam' },
|
||||
{ $ref: '#/components/parameters/LimitParam' },
|
||||
{ $ref: '#/components/parameters/SearchParam' }
|
||||
],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' }
|
||||
}
|
||||
}
|
||||
},
|
||||
'/api/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' }
|
||||
}
|
||||
}
|
||||
},
|
||||
'/api/alerts/stats/type': {
|
||||
get: {
|
||||
summary: '获取预警类型统计',
|
||||
tags: ['预警管理'],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' }
|
||||
}
|
||||
}
|
||||
},
|
||||
'/api/alerts/stats/level': {
|
||||
get: {
|
||||
summary: '获取预警级别统计',
|
||||
tags: ['预警管理'],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' }
|
||||
}
|
||||
}
|
||||
},
|
||||
'/api/alerts/stats/status': {
|
||||
get: {
|
||||
summary: '获取预警状态统计',
|
||||
tags: ['预警管理'],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 预警管理相关的数据模型定义
|
||||
const alertSchemas = {
|
||||
Alert: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'integer', description: '预警ID' },
|
||||
type: { type: 'string', description: '预警类型' },
|
||||
level: { type: 'string', enum: ['high', 'medium', 'low'], description: '预警级别' },
|
||||
status: {
|
||||
type: 'string',
|
||||
enum: ['pending', 'processing', 'resolved', 'ignored'],
|
||||
description: '预警状态'
|
||||
},
|
||||
title: { type: 'string', description: '预警标题' },
|
||||
message: { type: 'string', description: '预警消息' },
|
||||
deviceId: { type: 'integer', description: '设备ID' },
|
||||
animalId: { type: 'integer', description: '动物ID' },
|
||||
farmId: { type: 'integer', description: '养殖场ID' },
|
||||
createdAt: { type: 'string', format: 'date-time', description: '创建时间' },
|
||||
updatedAt: { type: 'string', format: 'date-time', description: '更新时间' }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
alertsPaths,
|
||||
alertSchemas
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user