更新swag
This commit is contained in:
302
src/api/feed.js
302
src/api/feed.js
@@ -3,7 +3,14 @@ import {PaginationDTO, Response} from '../enums';
|
||||
|
||||
// --- Typedefs for Feed Management ---
|
||||
|
||||
// --- NutrientRawMaterial ---
|
||||
// --- Nutrient ---
|
||||
|
||||
/**
|
||||
* @typedef {object} NutrientRawMaterialDTO
|
||||
* @property {number} id - 原料ID
|
||||
* @property {string} name - 原料名称
|
||||
* @property {number} value - 该原料中此营养素的含量
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} NutrientResponse
|
||||
@@ -13,13 +20,6 @@ import {PaginationDTO, Response} from '../enums';
|
||||
* @property {Array<NutrientRawMaterialDTO>} raw_materials - 包含此营养的原料列表
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} NutrientRawMaterialDTO
|
||||
* @property {number} id - 原料ID
|
||||
* @property {string} name - 原料名称
|
||||
* @property {number} value - 该原料中此营养素的含量
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ListNutrientResponse
|
||||
* @property {Array<NutrientResponse>} list
|
||||
@@ -212,98 +212,6 @@ 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 ---
|
||||
|
||||
/**
|
||||
@@ -360,6 +268,50 @@ export const deleteRecipe = (id) => {
|
||||
* @property {string} [description] - 描述
|
||||
*/
|
||||
|
||||
// --- 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] - 配方原料组成
|
||||
*/
|
||||
|
||||
|
||||
// --- API Functions ---
|
||||
|
||||
@@ -565,98 +517,6 @@ 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 ---
|
||||
|
||||
/**
|
||||
@@ -715,6 +575,54 @@ export const updateRawMaterialNutrients = (id, data) => {
|
||||
return http.put(`/api/v1/feed/raw-materials/${id}/nutrients`, data);
|
||||
};
|
||||
|
||||
// --- 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}`);
|
||||
};
|
||||
|
||||
|
||||
export const FeedApi = {
|
||||
getNutrients,
|
||||
@@ -738,15 +646,15 @@ export const FeedApi = {
|
||||
updatePigType,
|
||||
deletePigType,
|
||||
updatePigTypeNutrientRequirements,
|
||||
getRecipes,
|
||||
createRecipe,
|
||||
getRecipeById,
|
||||
updateRecipe,
|
||||
deleteRecipe,
|
||||
getRawMaterials,
|
||||
createRawMaterial,
|
||||
getRawMaterialById,
|
||||
updateRawMaterial,
|
||||
deleteRawMaterial,
|
||||
updateRawMaterialNutrients,
|
||||
getRecipes,
|
||||
createRecipe,
|
||||
getRecipeById,
|
||||
updateRecipe,
|
||||
deleteRecipe,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user