125 lines
3.6 KiB
JavaScript
125 lines
3.6 KiB
JavaScript
/**
|
|
* 养殖场管理模块 Swagger 文档
|
|
* @file swagger-farms.js
|
|
* @description 养殖场管理相关的 Swagger API 文档定义
|
|
*/
|
|
|
|
// 养殖场管理相关的 API 路径定义
|
|
const farmsPaths = {
|
|
'/api/farms': {
|
|
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/FarmInput' }
|
|
}
|
|
}
|
|
},
|
|
responses: {
|
|
201: { $ref: '#/components/responses/Created' },
|
|
400: { $ref: '#/components/responses/BadRequest' }
|
|
}
|
|
}
|
|
},
|
|
'/api/farms/{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/FarmInput' }
|
|
}
|
|
}
|
|
},
|
|
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/farms/search': {
|
|
get: {
|
|
summary: '搜索养殖场',
|
|
tags: ['养殖场管理'],
|
|
parameters: [
|
|
{ $ref: '#/components/parameters/SearchParam' }
|
|
],
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// 养殖场管理相关的数据模型定义
|
|
const farmsSchemas = {
|
|
Farm: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer', description: '养殖场ID' },
|
|
name: { type: 'string', description: '养殖场名称' },
|
|
address: { type: 'string', description: '地址' },
|
|
contact: { type: 'string', description: '联系人' },
|
|
phone: { type: 'string', description: '联系电话' },
|
|
area: { type: 'number', description: '面积(平方米)' },
|
|
capacity: { type: 'integer', description: '容量(头)' },
|
|
createdAt: { type: 'string', format: 'date-time', description: '创建时间' },
|
|
updatedAt: { type: 'string', format: 'date-time', description: '更新时间' }
|
|
}
|
|
},
|
|
FarmInput: {
|
|
type: 'object',
|
|
required: ['name'],
|
|
properties: {
|
|
name: { type: 'string', description: '养殖场名称' },
|
|
address: { type: 'string', description: '地址' },
|
|
contact: { type: 'string', description: '联系人' },
|
|
phone: { type: 'string', description: '联系电话' },
|
|
area: { type: 'number', description: '面积(平方米)' },
|
|
capacity: { type: 'integer', description: '容量(头)' }
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
farmsPaths,
|
|
farmsSchemas
|
|
};
|
|
|