/** * 动物管理模块 Swagger 文档 * @file swagger-animals.js * @description 动物管理相关的 Swagger API 文档定义 */ // 动物管理相关的 API 路径定义 const animalsPaths = { '/api/animals': { get: { summary: '获取所有动物', tags: ['动物管理'], parameters: [ { $ref: '#/components/parameters/PageParam' }, { $ref: '#/components/parameters/LimitParam' }, { $ref: '#/components/parameters/SearchParam' } ], responses: { 200: { $ref: '#/components/responses/Success' } } } }, '/api/animals/public': { get: { summary: '获取所有动物(公开接口)', tags: ['动物管理'], responses: { 200: { $ref: '#/components/responses/Success' } } } }, '/api/animals/binding-info/{collarNumber}': { get: { summary: '获取动物绑定信息', tags: ['动物管理'], parameters: [ { name: 'collarNumber', in: 'path', required: true, schema: { type: 'string' }, description: '项圈编号' } ], responses: { 200: { $ref: '#/components/responses/Success' }, 404: { $ref: '#/components/responses/NotFound' } } } } }; // 动物管理相关的数据模型定义 const animalsSchemas = { Animal: { type: 'object', properties: { id: { type: 'integer', description: '动物ID' }, earNumber: { type: 'string', description: '耳标号' }, collarNumber: { type: 'string', description: '项圈编号' }, name: { type: 'string', description: '动物名称' }, breed: { type: 'string', description: '品种' }, sex: { type: 'string', enum: ['公', '母'], description: '性别' }, birthDate: { type: 'string', format: 'date', description: '出生日期' }, farmId: { type: 'integer', description: '养殖场ID' }, penId: { type: 'integer', description: '圈舍ID' }, status: { type: 'string', description: '状态' }, createdAt: { type: 'string', format: 'date-time', description: '创建时间' }, updatedAt: { type: 'string', format: 'date-time', description: '更新时间' } } }, AnimalBindingInfo: { type: 'object', properties: { basicInfo: { type: 'object', description: '基础信息' }, birthInfo: { type: 'object', description: '出生信息' }, pedigreeInfo: { type: 'object', description: '族谱信息' }, insuranceInfo: { type: 'object', description: '保险信息' }, loanInfo: { type: 'object', description: '贷款信息' }, deviceInfo: { type: 'object', description: '设备信息' }, farmInfo: { type: 'object', description: '农场信息' } } } }; module.exports = { animalsPaths, animalsSchemas };