This commit is contained in:
2025-10-04 01:31:35 +08:00
parent 8d9e4286b0
commit 740e14e6cc
9 changed files with 264 additions and 38 deletions

View File

@@ -807,6 +807,59 @@ const docTemplate = `{
}
}
},
"/api/v1/pens/{id}/status": {
"put": {
"description": "更新指定猪栏的当前状态",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"猪场管理"
],
"summary": "更新猪栏状态",
"parameters": [
{
"type": "integer",
"description": "猪栏ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "新的猪栏状态",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UpdatePenStatusRequest"
}
}
],
"responses": {
"200": {
"description": "更新成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.PenResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/pig-batches": {
"get": {
"description": "获取所有猪批次的列表,支持按活跃状态筛选",
@@ -1136,7 +1189,7 @@ const docTemplate = `{
}
},
"409": {
"description": "业务逻辑冲突 (如猪栏已被用)",
"description": "业务逻辑冲突 (如猪栏已被使用)",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -1937,8 +1990,7 @@ const docTemplate = `{
"required": [
"capacity",
"house_id",
"pen_number",
"status"
"pen_number"
],
"properties": {
"capacity": {
@@ -1949,9 +2001,6 @@ const docTemplate = `{
},
"pen_number": {
"type": "string"
},
"status": {
"$ref": "#/definitions/models.PenStatus"
}
}
},
@@ -2616,7 +2665,44 @@ const docTemplate = `{
"type": "string"
},
"status": {
"$ref": "#/definitions/models.PenStatus"
"description": "添加oneof校验",
"enum": [
"空闲",
"使用中",
"病猪栏",
"康复栏",
"清洗消毒",
"维修中"
],
"allOf": [
{
"$ref": "#/definitions/models.PenStatus"
}
]
}
}
},
"dto.UpdatePenStatusRequest": {
"type": "object",
"required": [
"status"
],
"properties": {
"status": {
"enum": [
"空闲",
"使用中",
"病猪栏",
"康复栏",
"清洗消毒",
"维修中"
],
"allOf": [
{
"$ref": "#/definitions/models.PenStatus"
}
],
"example": "病猪栏"
}
}
},
@@ -2693,7 +2779,7 @@ const docTemplate = `{
"type": "string",
"enum": [
"空闲",
"占用",
"使用中",
"病猪栏",
"康复栏",
"清洗消毒",

View File

@@ -796,6 +796,59 @@
}
}
},
"/api/v1/pens/{id}/status": {
"put": {
"description": "更新指定猪栏的当前状态",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"猪场管理"
],
"summary": "更新猪栏状态",
"parameters": [
{
"type": "integer",
"description": "猪栏ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "新的猪栏状态",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UpdatePenStatusRequest"
}
}
],
"responses": {
"200": {
"description": "更新成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.PenResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/pig-batches": {
"get": {
"description": "获取所有猪批次的列表,支持按活跃状态筛选",
@@ -1125,7 +1178,7 @@
}
},
"409": {
"description": "业务逻辑冲突 (如猪栏已被用)",
"description": "业务逻辑冲突 (如猪栏已被使用)",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -1926,8 +1979,7 @@
"required": [
"capacity",
"house_id",
"pen_number",
"status"
"pen_number"
],
"properties": {
"capacity": {
@@ -1938,9 +1990,6 @@
},
"pen_number": {
"type": "string"
},
"status": {
"$ref": "#/definitions/models.PenStatus"
}
}
},
@@ -2605,7 +2654,44 @@
"type": "string"
},
"status": {
"$ref": "#/definitions/models.PenStatus"
"description": "添加oneof校验",
"enum": [
"空闲",
"使用中",
"病猪栏",
"康复栏",
"清洗消毒",
"维修中"
],
"allOf": [
{
"$ref": "#/definitions/models.PenStatus"
}
]
}
}
},
"dto.UpdatePenStatusRequest": {
"type": "object",
"required": [
"status"
],
"properties": {
"status": {
"enum": [
"空闲",
"使用中",
"病猪栏",
"康复栏",
"清洗消毒",
"维修中"
],
"allOf": [
{
"$ref": "#/definitions/models.PenStatus"
}
],
"example": "病猪栏"
}
}
},
@@ -2682,7 +2768,7 @@
"type": "string",
"enum": [
"空闲",
"占用",
"使用中",
"病猪栏",
"康复栏",
"清洗消毒",

View File

@@ -132,13 +132,10 @@ definitions:
type: integer
pen_number:
type: string
status:
$ref: '#/definitions/models.PenStatus'
required:
- capacity
- house_id
- pen_number
- status
type: object
dto.CreatePigHouseRequest:
properties:
@@ -578,13 +575,38 @@ definitions:
pen_number:
type: string
status:
$ref: '#/definitions/models.PenStatus'
allOf:
- $ref: '#/definitions/models.PenStatus'
description: 添加oneof校验
enum:
- 空闲
- 使用中
- 病猪栏
- 康复栏
- 清洗消毒
- 维修中
required:
- capacity
- house_id
- pen_number
- status
type: object
dto.UpdatePenStatusRequest:
properties:
status:
allOf:
- $ref: '#/definitions/models.PenStatus'
enum:
- 空闲
- 使用中
- 病猪栏
- 康复栏
- 清洗消毒
- 维修中
example: 病猪栏
required:
- status
type: object
dto.UpdatePigHouseRequest:
properties:
description:
@@ -634,7 +656,7 @@ definitions:
models.PenStatus:
enum:
- 空闲
- 占用
- 使用中
- 病猪栏
- 康复栏
- 清洗消毒
@@ -1268,6 +1290,38 @@ paths:
summary: 更新猪栏
tags:
- 猪场管理
/api/v1/pens/{id}/status:
put:
consumes:
- application/json
description: 更新指定猪栏的当前状态
parameters:
- description: 猪栏ID
in: path
name: id
required: true
type: integer
- description: 新的猪栏状态
in: body
name: body
required: true
schema:
$ref: '#/definitions/dto.UpdatePenStatusRequest'
produces:
- application/json
responses:
"200":
description: 更新成功
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.PenResponse'
type: object
summary: 更新猪栏状态
tags:
- 猪场管理
/api/v1/pig-batches:
get:
description: 获取所有猪批次的列表,支持按活跃状态筛选
@@ -1473,7 +1527,7 @@ paths:
schema:
$ref: '#/definitions/controller.Response'
"409":
description: 业务逻辑冲突 (如猪栏已被用)
description: 业务逻辑冲突 (如猪栏已被使用)
schema:
$ref: '#/definitions/controller.Response'
"500":