添加后台启动脚本和修改域名
This commit is contained in:
131
backend/swagger-devices.js
Normal file
131
backend/swagger-devices.js
Normal file
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* 设备管理模块 Swagger 文档
|
||||
* @file swagger-devices.js
|
||||
* @description 设备管理相关的 Swagger API 文档定义
|
||||
*/
|
||||
|
||||
// 设备管理相关的 API 路径定义
|
||||
const devicesPaths = {
|
||||
'/api/devices': {
|
||||
get: {
|
||||
summary: '获取所有设备',
|
||||
tags: ['设备管理'],
|
||||
parameters: [
|
||||
{ $ref: '#/components/parameters/PageParam' },
|
||||
{ $ref: '#/components/parameters/LimitParam' },
|
||||
{ $ref: '#/components/parameters/SearchParam' }
|
||||
],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' }
|
||||
}
|
||||
},
|
||||
post: {
|
||||
summary: '创建设备',
|
||||
tags: ['设备管理'],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: { $ref: '#/components/schemas/DeviceInput' }
|
||||
}
|
||||
}
|
||||
},
|
||||
responses: {
|
||||
201: { $ref: '#/components/responses/Created' },
|
||||
400: { $ref: '#/components/responses/BadRequest' }
|
||||
}
|
||||
}
|
||||
},
|
||||
'/api/devices/{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: { $ref: '#/components/schemas/DeviceInput' }
|
||||
}
|
||||
}
|
||||
},
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' },
|
||||
404: { $ref: '#/components/responses/NotFound' }
|
||||
}
|
||||
},
|
||||
delete: {
|
||||
summary: '删除设备',
|
||||
tags: ['设备管理'],
|
||||
parameters: [{ $ref: '#/components/parameters/IdParam' }],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' },
|
||||
404: { $ref: '#/components/responses/NotFound' }
|
||||
}
|
||||
}
|
||||
},
|
||||
'/api/devices/stats/status': {
|
||||
get: {
|
||||
summary: '获取设备状态统计',
|
||||
tags: ['设备管理'],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' }
|
||||
}
|
||||
}
|
||||
},
|
||||
'/api/devices/stats/type': {
|
||||
get: {
|
||||
summary: '获取设备类型统计',
|
||||
tags: ['设备管理'],
|
||||
responses: {
|
||||
200: { $ref: '#/components/responses/Success' }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 设备管理相关的数据模型定义
|
||||
const devicesSchemas = {
|
||||
Device: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'integer', description: '设备ID' },
|
||||
deviceId: { type: 'string', description: '设备编号' },
|
||||
name: { type: 'string', description: '设备名称' },
|
||||
type: { type: 'string', description: '设备类型' },
|
||||
status: { type: 'string', enum: ['online', 'offline', 'fault'], description: '设备状态' },
|
||||
batteryLevel: { type: 'integer', description: '电池电量' },
|
||||
location: { type: 'string', description: '位置信息' },
|
||||
farmId: { type: 'integer', description: '养殖场ID' },
|
||||
animalId: { type: 'integer', description: '绑定的动物ID' },
|
||||
createdAt: { type: 'string', format: 'date-time', description: '创建时间' },
|
||||
updatedAt: { type: 'string', format: 'date-time', description: '更新时间' }
|
||||
}
|
||||
},
|
||||
DeviceInput: {
|
||||
type: 'object',
|
||||
required: ['deviceId', 'name', 'type'],
|
||||
properties: {
|
||||
deviceId: { type: 'string', description: '设备编号' },
|
||||
name: { type: 'string', description: '设备名称' },
|
||||
type: { type: 'string', description: '设备类型' },
|
||||
farmId: { type: 'integer', description: '养殖场ID' },
|
||||
animalId: { type: 'integer', description: '绑定的动物ID' }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
devicesPaths,
|
||||
devicesSchemas
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user