更新swag
This commit is contained in:
284
src/api/feed.js
284
src/api/feed.js
@@ -200,6 +200,18 @@ import {PaginationDTO, Response} from '../enums';
|
||||
* @property {number} [daily_feed_intake]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 ---
|
||||
|
||||
/**
|
||||
@@ -451,6 +463,277 @@ 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);
|
||||
};
|
||||
|
||||
// --- 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] - 描述
|
||||
*/
|
||||
|
||||
|
||||
// --- 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);
|
||||
};
|
||||
|
||||
// --- RawMaterial ---
|
||||
|
||||
/**
|
||||
@@ -531,6 +814,7 @@ export const FeedApi = {
|
||||
getPigTypeById,
|
||||
updatePigType,
|
||||
deletePigType,
|
||||
updatePigTypeNutrientRequirements, // 新增的 API 方法
|
||||
getRawMaterials,
|
||||
createRawMaterial,
|
||||
getRawMaterialById,
|
||||
|
||||
Reference in New Issue
Block a user