更新swag
This commit is contained in:
@@ -2648,6 +2648,64 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/feed/pig-types/{id}/nutrient-requirements": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "根据猪类型ID,替换其所有的营养需求信息。这是一个覆盖操作。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"饲料管理"
|
||||
],
|
||||
"summary": "全量更新猪类型的营养需求",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "猪类型ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "新的营养需求列表",
|
||||
"name": "nutrientRequirements",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.UpdatePigTypeNutrientRequirementsRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "业务码为200代表更新成功",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/controller.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/dto.PigTypeResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/feed/raw-materials": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -3139,6 +3197,7 @@
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
7,
|
||||
-1,
|
||||
0,
|
||||
1,
|
||||
@@ -3148,12 +3207,12 @@
|
||||
5,
|
||||
-1,
|
||||
5,
|
||||
6,
|
||||
7
|
||||
6
|
||||
],
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"x-enum-varnames": [
|
||||
"_numLevels",
|
||||
"DebugLevel",
|
||||
"InfoLevel",
|
||||
"WarnLevel",
|
||||
@@ -3163,8 +3222,7 @@
|
||||
"FatalLevel",
|
||||
"_minLevel",
|
||||
"_maxLevel",
|
||||
"InvalidLevel",
|
||||
"_numLevels"
|
||||
"InvalidLevel"
|
||||
],
|
||||
"name": "level",
|
||||
"in": "query"
|
||||
@@ -7759,6 +7817,28 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.PigNutrientRequirementItem": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"nutrient_id"
|
||||
],
|
||||
"properties": {
|
||||
"max_requirement": {
|
||||
"description": "最高营养需求量",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"min_requirement": {
|
||||
"description": "最低营养需求量",
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"nutrient_id": {
|
||||
"description": "营养素ID",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.PigPurchaseDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -8928,6 +9008,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.UpdatePigTypeNutrientRequirementsRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"nutrient_requirements"
|
||||
],
|
||||
"properties": {
|
||||
"nutrient_requirements": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dto.PigNutrientRequirementItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.UpdatePigTypeRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -9312,10 +9406,10 @@
|
||||
"models.Operator": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"\u003C",
|
||||
"\u003C=",
|
||||
"\u003E",
|
||||
"\u003E=",
|
||||
"\u003c",
|
||||
"\u003c=",
|
||||
"\u003e",
|
||||
"\u003e=",
|
||||
"=",
|
||||
"!="
|
||||
],
|
||||
@@ -9700,6 +9794,7 @@
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"enum": [
|
||||
7,
|
||||
-1,
|
||||
0,
|
||||
1,
|
||||
@@ -9709,10 +9804,10 @@
|
||||
5,
|
||||
-1,
|
||||
5,
|
||||
6,
|
||||
7
|
||||
6
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"_numLevels",
|
||||
"DebugLevel",
|
||||
"InfoLevel",
|
||||
"WarnLevel",
|
||||
@@ -9722,8 +9817,7 @@
|
||||
"FatalLevel",
|
||||
"_minLevel",
|
||||
"_maxLevel",
|
||||
"InvalidLevel",
|
||||
"_numLevels"
|
||||
"InvalidLevel"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
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