2025-11-21 16:09:35 +08:00
|
|
|
|
import http from '../utils/http';
|
2025-11-21 16:46:25 +08:00
|
|
|
|
import {PaginationDTO, Response} from '../enums';
|
2025-11-21 16:09:35 +08:00
|
|
|
|
|
|
|
|
|
|
// --- Typedefs for Feed Management ---
|
|
|
|
|
|
|
2025-11-24 14:01:55 +08:00
|
|
|
|
// --- Nutrient ---
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} NutrientRawMaterialDTO
|
|
|
|
|
|
* @property {number} id - 原料ID
|
|
|
|
|
|
* @property {string} name - 原料名称
|
|
|
|
|
|
* @property {number} value - 该原料中此营养素的含量
|
|
|
|
|
|
*/
|
2025-11-21 16:09:35 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} NutrientResponse
|
|
|
|
|
|
* @property {number} id
|
|
|
|
|
|
* @property {string} name
|
|
|
|
|
|
* @property {string} description
|
2025-11-21 16:46:25 +08:00
|
|
|
|
* @property {Array<NutrientRawMaterialDTO>} raw_materials - 包含此营养的原料列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-11-21 16:09:35 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} ListNutrientResponse
|
|
|
|
|
|
* @property {Array<NutrientResponse>} list
|
|
|
|
|
|
* @property {PaginationDTO} pagination
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} NutrientsParams
|
2025-11-21 17:27:40 +08:00
|
|
|
|
* @property {string} [name] - 按营养名称模糊查询
|
|
|
|
|
|
* @property {string} [raw_material_name] - 按原料名称模糊查询
|
2025-11-21 16:09:35 +08:00
|
|
|
|
* @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
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} ListPigAgeStageResponse
|
|
|
|
|
|
* @property {Array<PigAgeStageResponse>} 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]
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} ListPigBreedResponse
|
|
|
|
|
|
* @property {Array<PigBreedResponse>} 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
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @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<PigNutrientRequirementDTO>} pig_nutrient_requirements
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} ListPigTypeResponse
|
|
|
|
|
|
* @property {Array<PigTypeResponse>} 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]
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-11-22 17:59:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} PigNutrientRequirementItem
|
|
|
|
|
|
* @property {number} nutrient_id - 营养素ID
|
|
|
|
|
|
* @property {number} [min_requirement] - 最低营养需求量
|
|
|
|
|
|
* @property {number} [max_requirement] - 最高营养需求量
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} UpdatePigTypeNutrientRequirementsRequest
|
|
|
|
|
|
* @property {Array<PigNutrientRequirementItem>} nutrient_requirements - 新的营养需求列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// --- RawMaterial ---
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} RawMaterialNutrientItem
|
|
|
|
|
|
* @property {number} nutrient_id - 营养素ID
|
|
|
|
|
|
* @property {number} value - 含量值,必须大于等于0
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} UpdateRawMaterialNutrientsRequest
|
|
|
|
|
|
* @property {Array<RawMaterialNutrientItem>} nutrients
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} RawMaterialNutrientDTO
|
|
|
|
|
|
* @property {number} id
|
|
|
|
|
|
* @property {number} nutrient_id
|
|
|
|
|
|
* @property {string} nutrient_name
|
|
|
|
|
|
* @property {number} value
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} RawMaterialResponse
|
|
|
|
|
|
* @property {number} id
|
|
|
|
|
|
* @property {string} name
|
|
|
|
|
|
* @property {string} description
|
|
|
|
|
|
* @property {Array<RawMaterialNutrientDTO>} raw_material_nutrients
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} ListRawMaterialResponse
|
|
|
|
|
|
* @property {Array<RawMaterialResponse>} list
|
|
|
|
|
|
* @property {PaginationDTO} pagination
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @typedef {object} RawMaterialsParams
|
|
|
|
|
|
* @property {string} [name] - 按原料名称模糊查询
|
|
|
|
|
|
* @property {string} [nutrient_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] - 描述
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-11-24 14:01:55 +08:00
|
|
|
|
// --- 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] - 配方原料组成
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-11-22 17:59:06 +08:00
|
|
|
|
|
|
|
|
|
|
// --- API Functions ---
|
|
|
|
|
|
|
|
|
|
|
|
// --- Nutrient ---
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取营养种类列表
|
|
|
|
|
|
* @param {NutrientsParams} params - 查询参数
|
|
|
|
|
|
* @returns {Promise<Response<ListNutrientResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getNutrients = (params) => {
|
|
|
|
|
|
return http.get('/api/v1/feed/nutrients', {params});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 创建营养种类
|
|
|
|
|
|
* @param {CreateNutrientRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<NutrientResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const createNutrient = (data) => {
|
|
|
|
|
|
return http.post('/api/v1/feed/nutrients', data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取营养种类详情
|
|
|
|
|
|
* @param {number} id - 营养种类ID
|
|
|
|
|
|
* @returns {Promise<Response<NutrientResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getNutrientById = (id) => {
|
|
|
|
|
|
return http.get(`/api/v1/feed/nutrients/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 更新营养种类
|
|
|
|
|
|
* @param {number} id - 营养种类ID
|
|
|
|
|
|
* @param {UpdateNutrientRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<NutrientResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const updateNutrient = (id, data) => {
|
|
|
|
|
|
return http.put(`/api/v1/feed/nutrients/${id}`, data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除营养种类
|
|
|
|
|
|
* @param {number} id - 营养种类ID
|
|
|
|
|
|
* @returns {Promise<Response>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const deleteNutrient = (id) => {
|
|
|
|
|
|
return http.delete(`/api/v1/feed/nutrients/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// --- PigAgeStage ---
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取猪年龄阶段列表
|
|
|
|
|
|
* @param {PigAgeStagesParams} params - 查询参数
|
|
|
|
|
|
* @returns {Promise<Response<ListPigAgeStageResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getPigAgeStages = (params) => {
|
|
|
|
|
|
return http.get('/api/v1/feed/pig-age-stages', {params});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 创建猪年龄阶段
|
|
|
|
|
|
* @param {CreatePigAgeStageRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<PigAgeStageResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const createPigAgeStage = (data) => {
|
|
|
|
|
|
return http.post('/api/v1/feed/pig-age-stages', data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取猪年龄阶段详情
|
|
|
|
|
|
* @param {number} id - 猪年龄阶段ID
|
|
|
|
|
|
* @returns {Promise<Response<PigAgeStageResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getPigAgeStageById = (id) => {
|
|
|
|
|
|
return http.get(`/api/v1/feed/pig-age-stages/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 更新猪年龄阶段
|
|
|
|
|
|
* @param {number} id - 猪年龄阶段ID
|
|
|
|
|
|
* @param {UpdatePigAgeStageRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<PigAgeStageResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const updatePigAgeStage = (id, data) => {
|
|
|
|
|
|
return http.put(`/api/v1/feed/pig-age-stages/${id}`, data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除猪年龄阶段
|
|
|
|
|
|
* @param {number} id - 猪年龄阶段ID
|
|
|
|
|
|
* @returns {Promise<Response>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const deletePigAgeStage = (id) => {
|
|
|
|
|
|
return http.delete(`/api/v1/feed/pig-age-stages/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// --- PigBreed ---
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取猪品种列表
|
|
|
|
|
|
* @param {PigBreedsParams} params - 查询参数
|
|
|
|
|
|
* @returns {Promise<Response<ListPigBreedResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getPigBreeds = (params) => {
|
|
|
|
|
|
return http.get('/api/v1/feed/pig-breeds', {params});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 创建猪品种
|
|
|
|
|
|
* @param {CreatePigBreedRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<PigBreedResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const createPigBreed = (data) => {
|
|
|
|
|
|
return http.post('/api/v1/feed/pig-breeds', data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取猪品种详情
|
|
|
|
|
|
* @param {number} id - 猪品种ID
|
|
|
|
|
|
* @returns {Promise<Response<PigBreedResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getPigBreedById = (id) => {
|
|
|
|
|
|
return http.get(`/api/v1/feed/pig-breeds/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 更新猪品种
|
|
|
|
|
|
* @param {number} id - 猪品种ID
|
|
|
|
|
|
* @param {UpdatePigBreedRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<PigBreedResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const updatePigBreed = (id, data) => {
|
|
|
|
|
|
return http.put(`/api/v1/feed/pig-breeds/${id}`, data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除猪品种
|
|
|
|
|
|
* @param {number} id - 猪品种ID
|
|
|
|
|
|
* @returns {Promise<Response>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const deletePigBreed = (id) => {
|
|
|
|
|
|
return http.delete(`/api/v1/feed/pig-breeds/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// --- PigType ---
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取猪类型列表
|
|
|
|
|
|
* @param {PigTypesParams} params - 查询参数
|
|
|
|
|
|
* @returns {Promise<Response<ListPigTypeResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getPigTypes = (params) => {
|
|
|
|
|
|
return http.get('/api/v1/feed/pig-types', {params});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 创建猪类型
|
|
|
|
|
|
* @param {CreatePigTypeRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<PigTypeResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const createPigType = (data) => {
|
|
|
|
|
|
return http.post('/api/v1/feed/pig-types', data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取猪类型详情
|
|
|
|
|
|
* @param {number} id - 猪类型ID
|
|
|
|
|
|
* @returns {Promise<Response<PigTypeResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const getPigTypeById = (id) => {
|
|
|
|
|
|
return http.get(`/api/v1/feed/pig-types/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 更新猪类型
|
|
|
|
|
|
* @param {number} id - 猪类型ID
|
|
|
|
|
|
* @param {UpdatePigTypeRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<PigTypeResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const updatePigType = (id, data) => {
|
|
|
|
|
|
return http.put(`/api/v1/feed/pig-types/${id}`, data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除猪类型
|
|
|
|
|
|
* @param {number} id - 猪类型ID
|
|
|
|
|
|
* @returns {Promise<Response>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const deletePigType = (id) => {
|
|
|
|
|
|
return http.delete(`/api/v1/feed/pig-types/${id}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 全量更新猪类型的营养需求
|
|
|
|
|
|
* @param {number} id - 猪类型ID
|
|
|
|
|
|
* @param {UpdatePigTypeNutrientRequirementsRequest} data - 新的营养需求列表
|
|
|
|
|
|
* @returns {Promise<Response<PigTypeResponse>>}
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const updatePigTypeNutrientRequirements = (id, data) => {
|
|
|
|
|
|
return http.put(`/api/v1/feed/pig-types/${id}/nutrient-requirements`, data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-24 14:01:55 +08:00
|
|
|
|
// --- RawMaterial ---
|
2025-11-24 13:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-24 14:01:55 +08:00
|
|
|
|
* 获取原料列表
|
|
|
|
|
|
* @param {RawMaterialsParams} params - 查询参数
|
|
|
|
|
|
* @returns {Promise<Response<ListRawMaterialResponse>>}
|
2025-11-24 13:44:41 +08:00
|
|
|
|
*/
|
2025-11-24 14:01:55 +08:00
|
|
|
|
export const getRawMaterials = (params) => {
|
|
|
|
|
|
return http.get('/api/v1/feed/raw-materials', {params});
|
|
|
|
|
|
};
|
2025-11-24 13:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-24 14:01:55 +08:00
|
|
|
|
* 创建原料
|
|
|
|
|
|
* @param {CreateRawMaterialRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<RawMaterialResponse>>}
|
2025-11-24 13:44:41 +08:00
|
|
|
|
*/
|
2025-11-24 14:01:55 +08:00
|
|
|
|
export const createRawMaterial = (data) => {
|
|
|
|
|
|
return http.post('/api/v1/feed/raw-materials', data);
|
|
|
|
|
|
};
|
2025-11-24 13:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-24 14:01:55 +08:00
|
|
|
|
* 获取原料详情
|
|
|
|
|
|
* @param {number} id - 原料ID
|
|
|
|
|
|
* @returns {Promise<Response<RawMaterialResponse>>}
|
2025-11-24 13:44:41 +08:00
|
|
|
|
*/
|
2025-11-24 14:01:55 +08:00
|
|
|
|
export const getRawMaterialById = (id) => {
|
|
|
|
|
|
return http.get(`/api/v1/feed/raw-materials/${id}`);
|
|
|
|
|
|
};
|
2025-11-24 13:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-24 14:01:55 +08:00
|
|
|
|
* 更新原料
|
|
|
|
|
|
* @param {number} id - 原料ID
|
|
|
|
|
|
* @param {UpdateRawMaterialRequest} data - 请求体
|
|
|
|
|
|
* @returns {Promise<Response<RawMaterialResponse>>}
|
2025-11-24 13:44:41 +08:00
|
|
|
|
*/
|
2025-11-24 14:01:55 +08:00
|
|
|
|
export const updateRawMaterial = (id, data) => {
|
|
|
|
|
|
return http.put(`/api/v1/feed/raw-materials/${id}`, data);
|
|
|
|
|
|
};
|
2025-11-24 13:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-24 14:01:55 +08:00
|
|
|
|
* 删除原料
|
|
|
|
|
|
* @param {number} id - 原料ID
|
|
|
|
|
|
* @returns {Promise<Response>}
|
2025-11-24 13:44:41 +08:00
|
|
|
|
*/
|
2025-11-24 14:01:55 +08:00
|
|
|
|
export const deleteRawMaterial = (id) => {
|
|
|
|
|
|
return http.delete(`/api/v1/feed/raw-materials/${id}`);
|
|
|
|
|
|
};
|
2025-11-24 13:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-24 14:01:55 +08:00
|
|
|
|
* 全量更新原料的营养成分
|
|
|
|
|
|
* @param {number} id - 原料ID
|
|
|
|
|
|
* @param {UpdateRawMaterialNutrientsRequest} data - 新的营养成分列表
|
|
|
|
|
|
* @returns {Promise<Response<RawMaterialResponse>>}
|
2025-11-24 13:44:41 +08:00
|
|
|
|
*/
|
2025-11-24 14:01:55 +08:00
|
|
|
|
export const updateRawMaterialNutrients = (id, data) => {
|
|
|
|
|
|
return http.put(`/api/v1/feed/raw-materials/${id}/nutrients`, data);
|
|
|
|
|
|
};
|
2025-11-24 13:44:41 +08:00
|
|
|
|
|
|
|
|
|
|
// --- 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}`);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-21 16:09:35 +08:00
|
|
|
|
|
|
|
|
|
|
export const FeedApi = {
|
2025-11-21 16:46:25 +08:00
|
|
|
|
getNutrients,
|
|
|
|
|
|
createNutrient,
|
|
|
|
|
|
getNutrientById,
|
|
|
|
|
|
updateNutrient,
|
|
|
|
|
|
deleteNutrient,
|
|
|
|
|
|
getPigAgeStages,
|
|
|
|
|
|
createPigAgeStage,
|
|
|
|
|
|
getPigAgeStageById,
|
|
|
|
|
|
updatePigAgeStage,
|
|
|
|
|
|
deletePigAgeStage,
|
|
|
|
|
|
getPigBreeds,
|
|
|
|
|
|
createPigBreed,
|
|
|
|
|
|
getPigBreedById,
|
|
|
|
|
|
updatePigBreed,
|
|
|
|
|
|
deletePigBreed,
|
|
|
|
|
|
getPigTypes,
|
|
|
|
|
|
createPigType,
|
|
|
|
|
|
getPigTypeById,
|
|
|
|
|
|
updatePigType,
|
|
|
|
|
|
deletePigType,
|
2025-11-22 18:01:32 +08:00
|
|
|
|
updatePigTypeNutrientRequirements,
|
2025-11-21 16:46:25 +08:00
|
|
|
|
getRawMaterials,
|
|
|
|
|
|
createRawMaterial,
|
|
|
|
|
|
getRawMaterialById,
|
|
|
|
|
|
updateRawMaterial,
|
|
|
|
|
|
deleteRawMaterial,
|
2025-11-22 17:00:49 +08:00
|
|
|
|
updateRawMaterialNutrients,
|
2025-11-24 14:01:55 +08:00
|
|
|
|
getRecipes,
|
|
|
|
|
|
createRecipe,
|
|
|
|
|
|
getRecipeById,
|
|
|
|
|
|
updateRecipe,
|
|
|
|
|
|
deleteRecipe,
|
2025-11-21 16:09:35 +08:00
|
|
|
|
};
|