更新swag

This commit is contained in:
2025-11-24 13:44:41 +08:00
parent cd27d2242d
commit 72ea3fe634
2 changed files with 537 additions and 0 deletions

View File

@@ -212,6 +212,98 @@ import {PaginationDTO, Response} from '../enums';
* @property {Array<PigNutrientRequirementItem>} nutrient_requirements - 新的营养需求列表
*/
// --- Recipe ---
/**
* @typedef {object} RecipeIngredientDto
* @property {number} raw_material_id - 原料ID
* @property {number} [percentage] - 原料在配方中的百分比 (0-1之间)
*/
/**
* @typedef {object} RecipeResponse
* @property {number} id
* @property {string} name
* @property {string} description
* @property {Array<RecipeIngredientDto>} recipe_ingredients
*/
/**
* @typedef {object} ListRecipeResponse
* @property {Array<RecipeResponse>} list
* @property {PaginationDTO} pagination
*/
/**
* @typedef {object} RecipesParams
* @property {string} [name] - 按名称模糊查询
* @property {string} [order_by] - 排序字段,例如 "id DESC"
* @property {number} [page]
* @property {number} [page_size]
*/
/**
* @typedef {object} CreateRecipeRequest
* @property {string} name - 配方名称
* @property {string} [description] - 配方描述
* @property {Array<RecipeIngredientDto>} [recipe_ingredients] - 配方原料组成
*/
/**
* @typedef {object} UpdateRecipeRequest
* @property {string} name - 配方名称
* @property {string} [description] - 配方描述
* @property {Array<RecipeIngredientDto>} [recipe_ingredients] - 配方原料组成
*/
// --- Recipe ---
/**
* 获取配方列表
* @param {RecipesParams} params - 查询参数
* @returns {Promise<Response<ListRecipeResponse>>}
*/
export const getRecipes = (params) => {
return http.get('/api/v1/feed/recipes', {params});
};
/**
* 创建配方
* @param {CreateRecipeRequest} data - 请求体
* @returns {Promise<Response<RecipeResponse>>}
*/
export const createRecipe = (data) => {
return http.post('/api/v1/feed/recipes', data);
};
/**
* 获取配方详情
* @param {number} id - 配方ID
* @returns {Promise<Response<RecipeResponse>>}
*/
export const getRecipeById = (id) => {
return http.get(`/api/v1/feed/recipes/${id}`);
};
/**
* 更新配方
* @param {number} id - 配方ID
* @param {UpdateRecipeRequest} data - 请求体
* @returns {Promise<Response<RecipeResponse>>}
*/
export const updateRecipe = (id, data) => {
return http.put(`/api/v1/feed/recipes/${id}`, data);
};
/**
* 删除配方
* @param {number} id - 配方ID
* @returns {Promise<Response>}
*/
export const deleteRecipe = (id) => {
return http.delete(`/api/v1/feed/recipes/${id}`);
};
// --- RawMaterial ---
/**
@@ -473,6 +565,98 @@ export const updatePigTypeNutrientRequirements = (id, data) => {
return http.put(`/api/v1/feed/pig-types/${id}/nutrient-requirements`, data);
};
// --- Recipe ---
/**
* @typedef {object} RecipeIngredientDto
* @property {number} raw_material_id - 原料ID
* @property {number} [percentage] - 原料在配方中的百分比 (0-1之间)
*/
/**
* @typedef {object} RecipeResponse
* @property {number} id
* @property {string} name
* @property {string} description
* @property {Array<RecipeIngredientDto>} recipe_ingredients
*/
/**
* @typedef {object} ListRecipeResponse
* @property {Array<RecipeResponse>} list
* @property {PaginationDTO} pagination
*/
/**
* @typedef {object} RecipesParams
* @property {string} [name] - 按名称模糊查询
* @property {string} [order_by] - 排序字段,例如 "id DESC"
* @property {number} [page]
* @property {number} [page_size]
*/
/**
* @typedef {object} CreateRecipeRequest
* @property {string} name - 配方名称
* @property {string} [description] - 配方描述
* @property {Array<RecipeIngredientDto>} [recipe_ingredients] - 配方原料组成
*/
/**
* @typedef {object} UpdateRecipeRequest
* @property {string} name - 配方名称
* @property {string} [description] - 配方描述
* @property {Array<RecipeIngredientDto>} [recipe_ingredients] - 配方原料组成
*/
// --- Recipe ---
/**
* 获取配方列表
* @param {RecipesParams} params - 查询参数
* @returns {Promise<Response<ListRecipeResponse>>}
*/
export const getRecipes = (params) => {
return http.get('/api/v1/feed/recipes', {params});
};
/**
* 创建配方
* @param {CreateRecipeRequest} data - 请求体
* @returns {Promise<Response<RecipeResponse>>}
*/
export const createRecipe = (data) => {
return http.post('/api/v1/feed/recipes', data);
};
/**
* 获取配方详情
* @param {number} id - 配方ID
* @returns {Promise<Response<RecipeResponse>>}
*/
export const getRecipeById = (id) => {
return http.get(`/api/v1/feed/recipes/${id}`);
};
/**
* 更新配方
* @param {number} id - 配方ID
* @param {UpdateRecipeRequest} data - 请求体
* @returns {Promise<Response<RecipeResponse>>}
*/
export const updateRecipe = (id, data) => {
return http.put(`/api/v1/feed/recipes/${id}`, data);
};
/**
* 删除配方
* @param {number} id - 配方ID
* @returns {Promise<Response>}
*/
export const deleteRecipe = (id) => {
return http.delete(`/api/v1/feed/recipes/${id}`);
};
// --- RawMaterial ---
/**
@@ -554,6 +738,11 @@ export const FeedApi = {
updatePigType,
deletePigType,
updatePigTypeNutrientRequirements,
getRecipes,
createRecipe,
getRecipeById,
updateRecipe,
deleteRecipe,
getRawMaterials,
createRawMaterial,
getRawMaterialById,