diff --git a/docs/swagger.json b/docs/swagger.json index 93b73087..6908f5fb 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3140,6 +3140,52 @@ } } }, + "/api/v1/feed/recipes/generate-from-all-materials/{pig_type_id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据指定的猪类型ID,使用系统中所有可用的原料,自动计算并创建一个成本最优的配方。", + "produces": [ + "application/json" + ], + "tags": [ + "饲料管理-配方" + ], + "summary": "使用系统中所有可用的原料一键生成配方", + "parameters": [ + { + "type": "integer", + "description": "猪类型ID", + "name": "pig_type_id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "业务码为201代表创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.GenerateRecipeResponse" + } + } + } + ] + } + } + } + } + }, "/api/v1/feed/recipes/{id}": { "get": { "security": [ @@ -3664,7 +3710,6 @@ }, { "enum": [ - 7, -1, 0, 1, @@ -3674,12 +3719,12 @@ 5, -1, 5, - 6 + 6, + 7 ], "type": "integer", "format": "int32", "x-enum-varnames": [ - "_numLevels", "DebugLevel", "InfoLevel", "WarnLevel", @@ -3689,7 +3734,8 @@ "FatalLevel", "_minLevel", "_maxLevel", - "InvalidLevel" + "InvalidLevel", + "_numLevels" ], "name": "level", "in": "query" @@ -7434,6 +7480,23 @@ } } }, + "dto.GenerateRecipeResponse": { + "type": "object", + "properties": { + "description": { + "description": "新生成的配方描述", + "type": "string" + }, + "id": { + "description": "新生成的配方ID", + "type": "integer" + }, + "name": { + "description": "新生成的配方名称", + "type": "string" + } + } + }, "dto.HistoricalAlarmDTO": { "type": "object", "properties": { @@ -10518,7 +10581,6 @@ "type": "integer", "format": "int32", "enum": [ - 7, -1, 0, 1, @@ -10528,10 +10590,10 @@ 5, -1, 5, - 6 + 6, + 7 ], "x-enum-varnames": [ - "_numLevels", "DebugLevel", "InfoLevel", "WarnLevel", @@ -10541,7 +10603,8 @@ "FatalLevel", "_minLevel", "_maxLevel", - "InvalidLevel" + "InvalidLevel", + "_numLevels" ] } }, diff --git a/src/api/feed.js b/src/api/feed.js index 6b417d2c..7531017c 100644 --- a/src/api/feed.js +++ b/src/api/feed.js @@ -317,6 +317,13 @@ import {PaginationDTO, Response} from '../enums'; * @property {Array} [recipe_ingredients] - 配方原料组成 */ +/** + * @typedef {object} GenerateRecipeResponse + * @property {number} id - 新生成的配方ID + * @property {string} name - 新生成的配方名称 + * @property {string} description - 新生成的配方描述 + */ + // --- API Functions --- @@ -628,6 +635,15 @@ export const deleteRecipe = (id) => { return http.delete(`/api/v1/feed/recipes/${id}`); }; +/** + * 使用系统中所有可用的原料一键生成配方 + * @param {number} pigTypeId - 猪类型ID + * @returns {Promise>} + */ +export const generateRecipeFromAllMaterials = (pigTypeId) => { + return http.post(`/api/v1/feed/recipes/generate-from-all-materials/${pigTypeId}`); +}; + export const FeedApi = { getNutrients, @@ -662,4 +678,5 @@ export const FeedApi = { getRecipeById, updateRecipe, deleteRecipe, + generateRecipeFromAllMaterials, };