diff --git a/docs/swagger.json b/docs/swagger.json index b3ce30ab..72e3d01e 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1640,6 +1640,1254 @@ } } }, + "/api/v1/feed/nutrients": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有营养种类的列表,支持分页和过滤。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取营养种类列表", + "parameters": [ + { + "type": "string", + "description": "按名称模糊查询", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "排序字段,例如 \"id DESC\"", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListNutrientResponse" + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的营养种类。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "创建营养种类", + "parameters": [ + { + "description": "营养种类信息", + "name": "nutrient", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreateNutrientRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为201代表创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.NutrientResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/feed/nutrients/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个营养种类的详细信息。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取营养种类详情", + "parameters": [ + { + "type": "integer", + "description": "营养种类ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.NutrientResponse" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID更新营养种类信息。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "更新营养种类", + "parameters": [ + { + "type": "integer", + "description": "营养种类ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新后的营养种类信息", + "name": "nutrient", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdateNutrientRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为200代表更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.NutrientResponse" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除营养种类。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "删除营养种类", + "parameters": [ + { + "type": "integer", + "description": "营养种类ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/feed/pig-age-stages": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有猪年龄阶段的列表,支持分页和过滤。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取猪年龄阶段列表", + "parameters": [ + { + "type": "string", + "description": "按名称模糊查询", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "排序字段,例如 \"id DESC\"", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigAgeStageResponse" + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的猪年龄阶段。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "创建猪年龄阶段", + "parameters": [ + { + "description": "猪年龄阶段信息", + "name": "pigAgeStage", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreatePigAgeStageRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为201代表创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigAgeStageResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/feed/pig-age-stages/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个猪年龄阶段的详细信息。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取猪年龄阶段详情", + "parameters": [ + { + "type": "integer", + "description": "猪年龄阶段ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigAgeStageResponse" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID更新猪年龄阶段信息。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "更新猪年龄阶段", + "parameters": [ + { + "type": "integer", + "description": "猪年龄阶段ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新后的猪年龄阶段信息", + "name": "pigAgeStage", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePigAgeStageRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为200代表更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigAgeStageResponse" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除猪年龄阶段。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "删除猪年龄阶段", + "parameters": [ + { + "type": "integer", + "description": "猪年龄阶段ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/feed/pig-breeds": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有猪品种的列表,支持分页和过滤。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取猪品种列表", + "parameters": [ + { + "type": "string", + "description": "按名称模糊查询", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "排序字段,例如 \"id DESC\"", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigBreedResponse" + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的猪品种。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "创建猪品种", + "parameters": [ + { + "description": "猪品种信息", + "name": "pigBreed", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreatePigBreedRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为201代表创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigBreedResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/feed/pig-breeds/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个猪品种的详细信息。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取猪品种详情", + "parameters": [ + { + "type": "integer", + "description": "猪品种ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigBreedResponse" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID更新猪品种信息。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "更新猪品种", + "parameters": [ + { + "type": "integer", + "description": "猪品种ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新后的猪品种信息", + "name": "pigBreed", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePigBreedRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为200代表更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigBreedResponse" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除猪品种。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "删除猪品种", + "parameters": [ + { + "type": "integer", + "description": "猪品种ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/feed/pig-types": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有猪类型的列表,支持分页和过滤。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取猪类型列表", + "parameters": [ + { + "type": "integer", + "description": "关联的猪年龄阶段ID", + "name": "age_stage_id", + "in": "query" + }, + { + "type": "string", + "description": "关联的猪年龄阶段名称 (用于模糊查询)", + "name": "age_stage_name", + "in": "query" + }, + { + "type": "integer", + "description": "关联的猪品种ID", + "name": "breed_id", + "in": "query" + }, + { + "type": "string", + "description": "关联的猪品种名称 (用于模糊查询)", + "name": "breed_name", + "in": "query" + }, + { + "type": "string", + "description": "排序字段,例如 \"id DESC\"", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigTypeResponse" + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的猪类型。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "创建猪类型", + "parameters": [ + { + "description": "猪类型信息", + "name": "pigType", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreatePigTypeRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为201代表创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigTypeResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/feed/pig-types/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个猪类型的详细信息。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取猪类型详情", + "parameters": [ + { + "type": "integer", + "description": "猪类型ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigTypeResponse" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID更新猪类型信息。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "更新猪类型", + "parameters": [ + { + "type": "integer", + "description": "猪类型ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新后的猪类型信息", + "name": "pigType", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePigTypeRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为200代表更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigTypeResponse" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除猪类型。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "删除猪类型", + "parameters": [ + { + "type": "integer", + "description": "猪类型ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/feed/raw-materials": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有原料的列表,支持分页和过滤。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取原料列表", + "parameters": [ + { + "type": "string", + "description": "按名称模糊查询", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "排序字段,例如 \"id DESC\"", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页数量", + "name": "page_size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListRawMaterialResponse" + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的原料。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "创建原料", + "parameters": [ + { + "description": "原料信息", + "name": "rawMaterial", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreateRawMaterialRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为201代表创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.RawMaterialResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/feed/raw-materials/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个原料的详细信息。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "获取原料详情", + "parameters": [ + { + "type": "integer", + "description": "原料ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表成功获取", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.RawMaterialResponse" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID更新原料信息。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "更新原料", + "parameters": [ + { + "type": "integer", + "description": "原料ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "更新后的原料信息", + "name": "rawMaterial", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdateRawMaterialRequest" + } + } + ], + "responses": { + "200": { + "description": "业务码为200代表更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.RawMaterialResponse" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除原料。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理" + ], + "summary": "删除原料", + "parameters": [ + { + "type": "integer", + "description": "原料ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "业务码为200代表删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, "/api/v1/monitor/device-command-logs": { "get": { "security": [ @@ -5168,6 +6416,24 @@ } } }, + "dto.CreateNutrientRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "description": "描述", + "type": "string", + "maxLength": 255 + }, + "name": { + "description": "营养素名称", + "type": "string", + "maxLength": 100 + } + } + }, "dto.CreatePenRequest": { "type": "object", "required": [ @@ -5187,6 +6453,57 @@ } } }, + "dto.CreatePigAgeStageRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "description": "阶段描述", + "type": "string", + "maxLength": 255 + }, + "name": { + "description": "年龄阶段名称", + "type": "string", + "maxLength": 50 + } + } + }, + "dto.CreatePigBreedRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "appearance_features": { + "description": "外貌特征", + "type": "string" + }, + "breed_advantages": { + "description": "品种优点", + "type": "string" + }, + "breed_disadvantages": { + "description": "品种缺点", + "type": "string" + }, + "description": { + "description": "其他描述", + "type": "string" + }, + "name": { + "description": "品种名称", + "type": "string", + "maxLength": 50 + }, + "parent_info": { + "description": "父母信息", + "type": "string" + } + } + }, "dto.CreatePigHouseRequest": { "type": "object", "required": [ @@ -5201,6 +6518,52 @@ } } }, + "dto.CreatePigTypeRequest": { + "type": "object", + "required": [ + "age_stage_id", + "breed_id" + ], + "properties": { + "age_stage_id": { + "description": "关联的猪年龄阶段ID", + "type": "integer" + }, + "breed_id": { + "description": "关联的猪品种ID", + "type": "integer" + }, + "daily_feed_intake": { + "description": "理论日均食量 (g/天)", + "type": "number" + }, + "daily_gain_weight": { + "description": "理论日增重 (g/天)", + "type": "number" + }, + "description": { + "description": "该猪类型的描述或特点", + "type": "string", + "maxLength": 255 + }, + "max_days": { + "description": "该猪类型在该年龄阶段的最大日龄", + "type": "integer" + }, + "max_weight": { + "description": "该猪类型在该年龄阶段的最大体重 (g)", + "type": "number" + }, + "min_days": { + "description": "该猪类型在该年龄阶段的最小日龄", + "type": "integer" + }, + "min_weight": { + "description": "该猪类型在该年龄阶段的最小体重 (g)", + "type": "number" + } + } + }, "dto.CreatePlanRequest": { "type": "object", "required": [ @@ -5247,6 +6610,24 @@ } } }, + "dto.CreateRawMaterialRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "description": "描述", + "type": "string", + "maxLength": 255 + }, + "name": { + "description": "原料名称", + "type": "string", + "maxLength": 100 + } + } + }, "dto.CreateUserRequest": { "type": "object", "required": [ @@ -5544,6 +6925,20 @@ } } }, + "dto.ListNutrientResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.NutrientResponse" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, "dto.ListPendingCollectionResponse": { "type": "object", "properties": { @@ -5558,6 +6953,20 @@ } } }, + "dto.ListPigAgeStageResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigAgeStageResponse" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, "dto.ListPigBatchLogResponse": { "type": "object", "properties": { @@ -5572,6 +6981,20 @@ } } }, + "dto.ListPigBreedResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigBreedResponse" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, "dto.ListPigPurchaseResponse": { "type": "object", "properties": { @@ -5628,6 +7051,20 @@ } } }, + "dto.ListPigTypeResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigTypeResponse" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, "dto.ListPlanExecutionLogResponse": { "type": "object", "properties": { @@ -5657,6 +7094,20 @@ } } }, + "dto.ListRawMaterialResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.RawMaterialResponse" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, "dto.ListSensorDataResponse": { "type": "object", "properties": { @@ -5880,6 +7331,26 @@ } } }, + "dto.NutrientResponse": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + } + }, "dto.PaginationDTO": { "type": "object", "properties": { @@ -5946,6 +7417,26 @@ } } }, + "dto.PigAgeStageResponse": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + } + }, "dto.PigBatchCreateDTO": { "type": "object", "required": [ @@ -6123,6 +7614,38 @@ } } }, + "dto.PigBreedResponse": { + "type": "object", + "properties": { + "appearance_features": { + "type": "string" + }, + "breed_advantages": { + "type": "string" + }, + "breed_disadvantages": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "parent_info": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + } + }, "dto.PigHouseResponse": { "type": "object", "properties": { @@ -6137,6 +7660,35 @@ } } }, + "dto.PigNutrientRequirementDTO": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "max_requirement": { + "description": "最高营养需求量", + "type": "number" + }, + "min_requirement": { + "description": "最低营养需求量", + "type": "number" + }, + "nutrient_id": { + "type": "integer" + }, + "nutrient_name": { + "description": "营养素名称", + "type": "string" + }, + "updated_at": { + "type": "string" + } + } + }, "dto.PigPurchaseDTO": { "type": "object", "properties": { @@ -6295,6 +7847,62 @@ } } }, + "dto.PigTypeResponse": { + "type": "object", + "properties": { + "age_stage_id": { + "type": "integer" + }, + "age_stage_name": { + "description": "猪年龄阶段名称", + "type": "string" + }, + "breed_id": { + "type": "integer" + }, + "breed_name": { + "description": "猪品种名称", + "type": "string" + }, + "created_at": { + "type": "string" + }, + "daily_feed_intake": { + "type": "number" + }, + "daily_gain_weight": { + "type": "number" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "max_days": { + "type": "integer" + }, + "max_weight": { + "type": "number" + }, + "min_days": { + "type": "integer" + }, + "min_weight": { + "type": "number" + }, + "pig_nutrient_requirements": { + "description": "关联的营养需求", + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigNutrientRequirementDTO" + } + }, + "updated_at": { + "type": "string" + } + } + }, "dto.PlanExecutionLogDTO": { "type": "object", "properties": { @@ -6400,6 +8008,58 @@ } } }, + "dto.RawMaterialNutrientDTO": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "nutrient_id": { + "type": "integer" + }, + "nutrient_name": { + "description": "营养素名称", + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "value": { + "description": "营养价值含量", + "type": "number" + } + } + }, + "dto.RawMaterialResponse": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "raw_material_nutrients": { + "description": "关联的营养素信息", + "type": "array", + "items": { + "$ref": "#/definitions/dto.RawMaterialNutrientDTO" + } + }, + "updated_at": { + "type": "string" + } + } + }, "dto.ReclassifyPenToNewBatchRequest": { "type": "object", "required": [ @@ -7056,6 +8716,24 @@ } } }, + "dto.UpdateNutrientRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "description": "描述", + "type": "string", + "maxLength": 255 + }, + "name": { + "description": "营养素名称", + "type": "string", + "maxLength": 100 + } + } + }, "dto.UpdatePenRequest": { "type": "object", "required": [ @@ -7116,6 +8794,57 @@ } } }, + "dto.UpdatePigAgeStageRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "description": "阶段描述", + "type": "string", + "maxLength": 255 + }, + "name": { + "description": "年龄阶段名称", + "type": "string", + "maxLength": 50 + } + } + }, + "dto.UpdatePigBreedRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "appearance_features": { + "description": "外貌特征", + "type": "string" + }, + "breed_advantages": { + "description": "品种优点", + "type": "string" + }, + "breed_disadvantages": { + "description": "品种缺点", + "type": "string" + }, + "description": { + "description": "其他描述", + "type": "string" + }, + "name": { + "description": "品种名称", + "type": "string", + "maxLength": 50 + }, + "parent_info": { + "description": "父母信息", + "type": "string" + } + } + }, "dto.UpdatePigHouseRequest": { "type": "object", "required": [ @@ -7130,6 +8859,52 @@ } } }, + "dto.UpdatePigTypeRequest": { + "type": "object", + "required": [ + "age_stage_id", + "breed_id" + ], + "properties": { + "age_stage_id": { + "description": "关联的猪年龄阶段ID", + "type": "integer" + }, + "breed_id": { + "description": "关联的猪品种ID", + "type": "integer" + }, + "daily_feed_intake": { + "description": "理论日均食量 (g/天)", + "type": "number" + }, + "daily_gain_weight": { + "description": "理论日增重 (g/天)", + "type": "number" + }, + "description": { + "description": "该猪类型的描述或特点", + "type": "string", + "maxLength": 255 + }, + "max_days": { + "description": "该猪类型在该年龄阶段的最大日龄", + "type": "integer" + }, + "max_weight": { + "description": "该猪类型在该年龄阶段的最大体重 (g)", + "type": "number" + }, + "min_days": { + "description": "该猪类型在该年龄阶段的最小日龄", + "type": "integer" + }, + "min_weight": { + "description": "该猪类型在该年龄阶段的最小体重 (g)", + "type": "number" + } + } + }, "dto.UpdatePlanRequest": { "type": "object", "required": [ @@ -7175,6 +8950,24 @@ } } }, + "dto.UpdateRawMaterialRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "description": "描述", + "type": "string", + "maxLength": 255 + }, + "name": { + "description": "原料名称", + "type": "string", + "maxLength": 100 + } + } + }, "dto.UserActionLogDTO": { "type": "object", "properties": { diff --git a/src/api/feed.js b/src/api/feed.js new file mode 100644 index 00000000..9c4bdfea --- /dev/null +++ b/src/api/feed.js @@ -0,0 +1,522 @@ +import http from '../utils/http'; +import { PaginationDTO, Response } from '../enums'; + +// --- Typedefs for Feed Management --- + +// --- Nutrient --- + +/** + * @typedef {object} NutrientResponse + * @property {number} id + * @property {string} name + * @property {string} description + * @property {string} created_at + * @property {string} updated_at + */ + +/** + * @typedef {object} ListNutrientResponse + * @property {Array} list + * @property {PaginationDTO} pagination + */ + +/** + * @typedef {object} NutrientsParams + * @property {string} [name] - 按名称模糊查询 + * @property {string} [order_by] - 排序字段,例如 "id DESC" + * @property {number} [page] + * @property {number} [page_size] + */ + +/** + * @typedef {object} CreateNutrientRequest + * @property {string} name - 营养素名称 + * @property {string} [description] - 描述 + */ + +/** + * @typedef {object} UpdateNutrientRequest + * @property {string} name - 营养素名称 + * @property {string} [description] - 描述 + */ + +// --- PigAgeStage --- + +/** + * @typedef {object} PigAgeStageResponse + * @property {number} id + * @property {string} name + * @property {string} description + * @property {string} created_at + * @property {string} updated_at + */ + +/** + * @typedef {object} ListPigAgeStageResponse + * @property {Array} list + * @property {PaginationDTO} pagination + */ + +/** + * @typedef {object} PigAgeStagesParams + * @property {string} [name] - 按名称模糊查询 + * @property {string} [order_by] - 排序字段,例如 "id DESC" + * @property {number} [page] + * @property {number} [page_size] + */ + +/** + * @typedef {object} CreatePigAgeStageRequest + * @property {string} name - 年龄阶段名称 + * @property {string} [description] - 阶段描述 + */ + +/** + * @typedef {object} UpdatePigAgeStageRequest + * @property {string} name - 年龄阶段名称 + * @property {string} [description] - 阶段描述 + */ + +// --- PigBreed --- + +/** + * @typedef {object} PigBreedResponse + * @property {number} id + * @property {string} name + * @property {string} [description] + * @property {string} [parent_info] + * @property {string} [appearance_features] + * @property {string} [breed_advantages] + * @property {string} [breed_disadvantages] + * @property {string} created_at + * @property {string} updated_at + */ + +/** + * @typedef {object} ListPigBreedResponse + * @property {Array} list + * @property {PaginationDTO} pagination + */ + +/** + * @typedef {object} PigBreedsParams + * @property {string} [name] - 按名称模糊查询 + * @property {string} [order_by] - 排序字段,例如 "id DESC" + * @property {number} [page] + * @property {number} [page_size] + */ + +/** + * @typedef {object} CreatePigBreedRequest + * @property {string} name - 品种名称 + * @property {string} [description] - 其他描述 + * @property {string} [parent_info] - 父母信息 + * @property {string} [appearance_features] - 外貌特征 + * @property {string} [breed_advantages] - 品种优点 + * @property {string} [breed_disadvantages] - 品种缺点 + */ + +/** + * @typedef {object} UpdatePigBreedRequest + * @property {string} name - 品种名称 + * @property {string} [description] - 其他描述 + * @property {string} [parent_info] - 父母信息 + * @property {string} [appearance_features] - 外貌特征 + * @property {string} [breed_advantages] - 品种优点 + * @property {string} [breed_disadvantages] - 品种缺点 + */ + +// --- PigType --- + +/** + * @typedef {object} PigNutrientRequirementDTO + * @property {number} id + * @property {number} nutrient_id + * @property {string} nutrient_name + * @property {number} min_requirement + * @property {number} max_requirement + * @property {string} created_at + * @property {string} updated_at + */ + +/** + * @typedef {object} PigTypeResponse + * @property {number} id + * @property {number} breed_id + * @property {string} breed_name + * @property {number} age_stage_id + * @property {string} age_stage_name + * @property {string} [description] + * @property {number} [min_days] + * @property {number} [max_days] + * @property {number} [min_weight] + * @property {number} [max_weight] + * @property {number} [daily_gain_weight] + * @property {number} [daily_feed_intake] + * @property {Array} pig_nutrient_requirements + * @property {string} created_at + * @property {string} updated_at + */ + +/** + * @typedef {object} ListPigTypeResponse + * @property {Array} list + * @property {PaginationDTO} pagination + */ + +/** + * @typedef {object} PigTypesParams + * @property {number} [age_stage_id] - 关联的猪年龄阶段ID + * @property {string} [age_stage_name] - 关联的猪年龄阶段名称 (用于模糊查询) + * @property {number} [breed_id] - 关联的猪品种ID + * @property {string} [breed_name] - 关联的猪品种名称 (用于模糊查询) + * @property {string} [order_by] - 排序字段,例如 "id DESC" + * @property {number} [page] + * @property {number} [page_size] + */ + +/** + * @typedef {object} CreatePigTypeRequest + * @property {number} breed_id + * @property {number} age_stage_id + * @property {string} [description] + * @property {number} [min_days] + * @property {number} [max_days] + * @property {number} [min_weight] + * @property {number} [max_weight] + * @property {number} [daily_gain_weight] + * @property {number} [daily_feed_intake] + */ + +/** + * @typedef {object} UpdatePigTypeRequest + * @property {number} breed_id + * @property {number} age_stage_id + * @property {string} [description] + * @property {number} [min_days] + * @property {number} [max_days] + * @property {number} [min_weight] + * @property {number} [max_weight] + * @property {number} [daily_gain_weight] + * @property {number} [daily_feed_intake] + */ + +// --- RawMaterial --- + +/** + * @typedef {object} RawMaterialNutrientDTO + * @property {number} id + * @property {number} nutrient_id + * @property {string} nutrient_name + * @property {number} value + * @property {string} created_at + * @property {string} updated_at + */ + +/** + * @typedef {object} RawMaterialResponse + * @property {number} id + * @property {string} name + * @property {string} description + * @property {Array} raw_material_nutrients + * @property {string} created_at + * @property {string} updated_at + */ + +/** + * @typedef {object} ListRawMaterialResponse + * @property {Array} list + * @property {PaginationDTO} pagination + */ + +/** + * @typedef {object} RawMaterialsParams + * @property {string} [name] - 按名称模糊查询 + * @property {string} [order_by] - 排序字段,例如 "id DESC" + * @property {number} [page] + * @property {number} [page_size] + */ + +/** + * @typedef {object} CreateRawMaterialRequest + * @property {string} name - 原料名称 + * @property {string} [description] - 描述 + */ + +/** + * @typedef {object} UpdateRawMaterialRequest + * @property {string} name - 原料名称 + * @property {string} [description] - 描述 + */ + + +// --- API Functions --- + +// --- Nutrient --- + +/** + * 获取营养种类列表 + * @param {NutrientsParams} params - 查询参数 + * @returns {Promise} + */ +export const getNutrients = (params) => { + return http.get('/api/v1/feed/nutrients', { params }); +}; + +/** + * 创建营养种类 + * @param {CreateNutrientRequest} data - 请求体 + * @returns {Promise} + */ +export const createNutrient = (data) => { + return http.post('/api/v1/feed/nutrients', data); +}; + +/** + * 获取营养种类详情 + * @param {number} id - 营养种类ID + * @returns {Promise} + */ +export const getNutrientById = (id) => { + return http.get(`/api/v1/feed/nutrients/${id}`); +}; + +/** + * 更新营养种类 + * @param {number} id - 营养种类ID + * @param {UpdateNutrientRequest} data - 请求体 + * @returns {Promise} + */ +export const updateNutrient = (id, data) => { + return http.put(`/api/v1/feed/nutrients/${id}`, data); +}; + +/** + * 删除营养种类 + * @param {number} id - 营养种类ID + * @returns {Promise} + */ +export const deleteNutrient = (id) => { + return http.delete(`/api/v1/feed/nutrients/${id}`); +}; + +// --- PigAgeStage --- + +/** + * 获取猪年龄阶段列表 + * @param {PigAgeStagesParams} params - 查询参数 + * @returns {Promise} + */ +export const getPigAgeStages = (params) => { + return http.get('/api/v1/feed/pig-age-stages', { params }); +}; + +/** + * 创建猪年龄阶段 + * @param {CreatePigAgeStageRequest} data - 请求体 + * @returns {Promise} + */ +export const createPigAgeStage = (data) => { + return http.post('/api/v1/feed/pig-age-stages', data); +}; + +/** + * 获取猪年龄阶段详情 + * @param {number} id - 猪年龄阶段ID + * @returns {Promise} + */ +export const getPigAgeStageById = (id) => { + return http.get(`/api/v1/feed/pig-age-stages/${id}`); +}; + +/** + * 更新猪年龄阶段 + * @param {number} id - 猪年龄阶段ID + * @param {UpdatePigAgeStageRequest} data - 请求体 + * @returns {Promise} + */ +export const updatePigAgeStage = (id, data) => { + return http.put(`/api/v1/feed/pig-age-stages/${id}`, data); +}; + +/** + * 删除猪年龄阶段 + * @param {number} id - 猪年龄阶段ID + * @returns {Promise} + */ +export const deletePigAgeStage = (id) => { + return http.delete(`/api/v1/feed/pig-age-stages/${id}`); +}; + +// --- PigBreed --- + +/** + * 获取猪品种列表 + * @param {PigBreedsParams} params - 查询参数 + * @returns {Promise} + */ +export const getPigBreeds = (params) => { + return http.get('/api/v1/feed/pig-breeds', { params }); +}; + +/** + * 创建猪品种 + * @param {CreatePigBreedRequest} data - 请求体 + * @returns {Promise} + */ +export const createPigBreed = (data) => { + return http.post('/api/v1/feed/pig-breeds', data); +}; + +/** + * 获取猪品种详情 + * @param {number} id - 猪品种ID + * @returns {Promise} + */ +export const getPigBreedById = (id) => { + return http.get(`/api/v1/feed/pig-breeds/${id}`); +}; + +/** + * 更新猪品种 + * @param {number} id - 猪品种ID + * @param {UpdatePigBreedRequest} data - 请求体 + * @returns {Promise} + */ +export const updatePigBreed = (id, data) => { + return http.put(`/api/v1/feed/pig-breeds/${id}`, data); +}; + +/** + * 删除猪品种 + * @param {number} id - 猪品种ID + * @returns {Promise} + */ +export const deletePigBreed = (id) => { + return http.delete(`/api/v1/feed/pig-breeds/${id}`); +}; + +// --- PigType --- + +/** + * 获取猪类型列表 + * @param {PigTypesParams} params - 查询参数 + * @returns {Promise} + */ +export const getPigTypes = (params) => { + return http.get('/api/v1/feed/pig-types', { params }); +}; + +/** + * 创建猪类型 + * @param {CreatePigTypeRequest} data - 请求体 + * @returns {Promise} + */ +export const createPigType = (data) => { + return http.post('/api/v1/feed/pig-types', data); +}; + +/** + * 获取猪类型详情 + * @param {number} id - 猪类型ID + * @returns {Promise} + */ +export const getPigTypeById = (id) => { + return http.get(`/api/v1/feed/pig-types/${id}`); +}; + +/** + * 更新猪类型 + * @param {number} id - 猪类型ID + * @param {UpdatePigTypeRequest} data - 请求体 + * @returns {Promise} + */ +export const updatePigType = (id, data) => { + return http.put(`/api/v1/feed/pig-types/${id}`, data); +}; + +/** + * 删除猪类型 + * @param {number} id - 猪类型ID + * @returns {Promise} + */ +export const deletePigType = (id) => { + return http.delete(`/api/v1/feed/pig-types/${id}`); +}; + +// --- RawMaterial --- + +/** + * 获取原料列表 + * @param {RawMaterialsParams} params - 查询参数 + * @returns {Promise} + */ +export const getRawMaterials = (params) => { + return http.get('/api/v1/feed/raw-materials', { params }); +}; + +/** + * 创建原料 + * @param {CreateRawMaterialRequest} data - 请求体 + * @returns {Promise} + */ +export const createRawMaterial = (data) => { + return http.post('/api/v1/feed/raw-materials', data); +}; + +/** + * 获取原料详情 + * @param {number} id - 原料ID + * @returns {Promise} + */ +export const getRawMaterialById = (id) => { + return http.get(`/api/v1/feed/raw-materials/${id}`); +}; + +/** + * 更新原料 + * @param {number} id - 原料ID + * @param {UpdateRawMaterialRequest} data - 请求体 + * @returns {Promise} + */ +export const updateRawMaterial = (id, data) => { + return http.put(`/api/v1/feed/raw-materials/${id}`, data); +}; + +/** + * 删除原料 + * @param {number} id - 原料ID + * @returns {Promise} + */ +export const deleteRawMaterial = (id) => { + return http.delete(`/api/v1/feed/raw-materials/${id}`); +}; + + +export const FeedApi = { + getNutrients, + createNutrient, + getNutrientById, + updateNutrient, + deleteNutrient, + getPigAgeStages, + createPigAgeStage, + getPigAgeStageById, + updatePigAgeStage, + deletePigAgeStage, + getPigBreeds, + createPigBreed, + getPigBreedById, + updatePigBreed, + deletePigBreed, + getPigTypes, + createPigType, + getPigTypeById, + updatePigType, + deletePigType, + getRawMaterials, + createRawMaterial, + getRawMaterialById, + updateRawMaterial, + deleteRawMaterial, +}; diff --git a/src/api/index.js b/src/api/index.js index f73709e9..029eb132 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -4,6 +4,7 @@ import { UserApi } from './user.js'; import { AlarmApi } from './alarm.js'; // 导入告警API import { HealthApi } from './health.js'; // 导入健康检查API import { DeviceTemplateApi } from './deviceTemplate.js'; // 导入设备模板API +import { FeedApi } from './feed.js'; // 导入饲料管理API /** * API客户端 @@ -17,8 +18,9 @@ export class ApiClient { this.health = HealthApi; // 添加健康检查API this.alarms = AlarmApi; // 添加告警API this.deviceTemplates = DeviceTemplateApi; // 添加设备模板API + this.feeds = FeedApi; // 添加饲料管理API } } // 导出API客户端实例 -export default new ApiClient(); \ No newline at end of file +export default new ApiClient();