增加新接口
This commit is contained in:
1793
docs/swagger.json
1793
docs/swagger.json
File diff suppressed because it is too large
Load Diff
522
src/api/feed.js
Normal file
522
src/api/feed.js
Normal file
@@ -0,0 +1,522 @@
|
||||
import http from '../utils/http';
|
||||
import { PaginationDTO, Response } from '../enums';
|
||||
|
||||
// --- Typedefs for Feed Management ---
|
||||
|
||||
// --- Nutrient ---
|
||||
|
||||
/**
|
||||
* @typedef {object} NutrientResponse
|
||||
* @property {number} id
|
||||
* @property {string} name
|
||||
* @property {string} description
|
||||
* @property {string} created_at
|
||||
* @property {string} updated_at
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ListNutrientResponse
|
||||
* @property {Array<NutrientResponse>} list
|
||||
* @property {PaginationDTO} pagination
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} NutrientsParams
|
||||
* @property {string} [name] - 按名称模糊查询
|
||||
* @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
|
||||
* @property {string} created_at
|
||||
* @property {string} updated_at
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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]
|
||||
* @property {string} created_at
|
||||
* @property {string} updated_at
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @property {string} created_at
|
||||
* @property {string} updated_at
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @property {string} created_at
|
||||
* @property {string} updated_at
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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]
|
||||
*/
|
||||
|
||||
// --- RawMaterial ---
|
||||
|
||||
/**
|
||||
* @typedef {object} RawMaterialNutrientDTO
|
||||
* @property {number} id
|
||||
* @property {number} nutrient_id
|
||||
* @property {string} nutrient_name
|
||||
* @property {number} value
|
||||
* @property {string} created_at
|
||||
* @property {string} updated_at
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RawMaterialResponse
|
||||
* @property {number} id
|
||||
* @property {string} name
|
||||
* @property {string} description
|
||||
* @property {Array<RawMaterialNutrientDTO>} raw_material_nutrients
|
||||
* @property {string} created_at
|
||||
* @property {string} updated_at
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ListRawMaterialResponse
|
||||
* @property {Array<RawMaterialResponse>} list
|
||||
* @property {PaginationDTO} pagination
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RawMaterialsParams
|
||||
* @property {string} [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<ListNutrientResponse>}
|
||||
*/
|
||||
export const getNutrients = (params) => {
|
||||
return http.get('/api/v1/feed/nutrients', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建营养种类
|
||||
* @param {CreateNutrientRequest} data - 请求体
|
||||
* @returns {Promise<NutrientResponse>}
|
||||
*/
|
||||
export const createNutrient = (data) => {
|
||||
return http.post('/api/v1/feed/nutrients', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取营养种类详情
|
||||
* @param {number} id - 营养种类ID
|
||||
* @returns {Promise<NutrientResponse>}
|
||||
*/
|
||||
export const getNutrientById = (id) => {
|
||||
return http.get(`/api/v1/feed/nutrients/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新营养种类
|
||||
* @param {number} id - 营养种类ID
|
||||
* @param {UpdateNutrientRequest} data - 请求体
|
||||
* @returns {Promise<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<ListPigAgeStageResponse>}
|
||||
*/
|
||||
export const getPigAgeStages = (params) => {
|
||||
return http.get('/api/v1/feed/pig-age-stages', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建猪年龄阶段
|
||||
* @param {CreatePigAgeStageRequest} data - 请求体
|
||||
* @returns {Promise<PigAgeStageResponse>}
|
||||
*/
|
||||
export const createPigAgeStage = (data) => {
|
||||
return http.post('/api/v1/feed/pig-age-stages', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取猪年龄阶段详情
|
||||
* @param {number} id - 猪年龄阶段ID
|
||||
* @returns {Promise<PigAgeStageResponse>}
|
||||
*/
|
||||
export const getPigAgeStageById = (id) => {
|
||||
return http.get(`/api/v1/feed/pig-age-stages/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新猪年龄阶段
|
||||
* @param {number} id - 猪年龄阶段ID
|
||||
* @param {UpdatePigAgeStageRequest} data - 请求体
|
||||
* @returns {Promise<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<ListPigBreedResponse>}
|
||||
*/
|
||||
export const getPigBreeds = (params) => {
|
||||
return http.get('/api/v1/feed/pig-breeds', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建猪品种
|
||||
* @param {CreatePigBreedRequest} data - 请求体
|
||||
* @returns {Promise<PigBreedResponse>}
|
||||
*/
|
||||
export const createPigBreed = (data) => {
|
||||
return http.post('/api/v1/feed/pig-breeds', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取猪品种详情
|
||||
* @param {number} id - 猪品种ID
|
||||
* @returns {Promise<PigBreedResponse>}
|
||||
*/
|
||||
export const getPigBreedById = (id) => {
|
||||
return http.get(`/api/v1/feed/pig-breeds/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新猪品种
|
||||
* @param {number} id - 猪品种ID
|
||||
* @param {UpdatePigBreedRequest} data - 请求体
|
||||
* @returns {Promise<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<ListPigTypeResponse>}
|
||||
*/
|
||||
export const getPigTypes = (params) => {
|
||||
return http.get('/api/v1/feed/pig-types', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建猪类型
|
||||
* @param {CreatePigTypeRequest} data - 请求体
|
||||
* @returns {Promise<PigTypeResponse>}
|
||||
*/
|
||||
export const createPigType = (data) => {
|
||||
return http.post('/api/v1/feed/pig-types', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取猪类型详情
|
||||
* @param {number} id - 猪类型ID
|
||||
* @returns {Promise<PigTypeResponse>}
|
||||
*/
|
||||
export const getPigTypeById = (id) => {
|
||||
return http.get(`/api/v1/feed/pig-types/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新猪类型
|
||||
* @param {number} id - 猪类型ID
|
||||
* @param {UpdatePigTypeRequest} data - 请求体
|
||||
* @returns {Promise<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}`);
|
||||
};
|
||||
|
||||
// --- RawMaterial ---
|
||||
|
||||
/**
|
||||
* 获取原料列表
|
||||
* @param {RawMaterialsParams} params - 查询参数
|
||||
* @returns {Promise<ListRawMaterialResponse>}
|
||||
*/
|
||||
export const getRawMaterials = (params) => {
|
||||
return http.get('/api/v1/feed/raw-materials', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建原料
|
||||
* @param {CreateRawMaterialRequest} data - 请求体
|
||||
* @returns {Promise<RawMaterialResponse>}
|
||||
*/
|
||||
export const createRawMaterial = (data) => {
|
||||
return http.post('/api/v1/feed/raw-materials', data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取原料详情
|
||||
* @param {number} id - 原料ID
|
||||
* @returns {Promise<RawMaterialResponse>}
|
||||
*/
|
||||
export const getRawMaterialById = (id) => {
|
||||
return http.get(`/api/v1/feed/raw-materials/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新原料
|
||||
* @param {number} id - 原料ID
|
||||
* @param {UpdateRawMaterialRequest} data - 请求体
|
||||
* @returns {Promise<RawMaterialResponse>}
|
||||
*/
|
||||
export const updateRawMaterial = (id, data) => {
|
||||
return http.put(`/api/v1/feed/raw-materials/${id}`, data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除原料
|
||||
* @param {number} id - 原料ID
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const deleteRawMaterial = (id) => {
|
||||
return http.delete(`/api/v1/feed/raw-materials/${id}`);
|
||||
};
|
||||
|
||||
|
||||
export const FeedApi = {
|
||||
getNutrients,
|
||||
createNutrient,
|
||||
getNutrientById,
|
||||
updateNutrient,
|
||||
deleteNutrient,
|
||||
getPigAgeStages,
|
||||
createPigAgeStage,
|
||||
getPigAgeStageById,
|
||||
updatePigAgeStage,
|
||||
deletePigAgeStage,
|
||||
getPigBreeds,
|
||||
createPigBreed,
|
||||
getPigBreedById,
|
||||
updatePigBreed,
|
||||
deletePigBreed,
|
||||
getPigTypes,
|
||||
createPigType,
|
||||
getPigTypeById,
|
||||
updatePigType,
|
||||
deletePigType,
|
||||
getRawMaterials,
|
||||
createRawMaterial,
|
||||
getRawMaterialById,
|
||||
updateRawMaterial,
|
||||
deleteRawMaterial,
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import { UserApi } from './user.js';
|
||||
import { AlarmApi } from './alarm.js'; // 导入告警API
|
||||
import { HealthApi } from './health.js'; // 导入健康检查API
|
||||
import { DeviceTemplateApi } from './deviceTemplate.js'; // 导入设备模板API
|
||||
import { FeedApi } from './feed.js'; // 导入饲料管理API
|
||||
|
||||
/**
|
||||
* API客户端
|
||||
@@ -17,6 +18,7 @@ export class ApiClient {
|
||||
this.health = HealthApi; // 添加健康检查API
|
||||
this.alarms = AlarmApi; // 添加告警API
|
||||
this.deviceTemplates = DeviceTemplateApi; // 添加设备模板API
|
||||
this.feeds = FeedApi; // 添加饲料管理API
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user