修改api.js
This commit is contained in:
@@ -2,6 +2,13 @@ import http from '../utils/http';
|
||||
|
||||
// --- Typedefs ---
|
||||
|
||||
/**
|
||||
* @typedef {object} Response
|
||||
* @property {number} code - 业务状态码
|
||||
* @property {object} [data] - 业务数据
|
||||
* @property {string} [message] - 提示信息
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {('自繁'|'外购')} PigBatchOriginType
|
||||
*/
|
||||
@@ -15,15 +22,15 @@ import http from '../utils/http';
|
||||
* @property {number} id - 批次ID
|
||||
* @property {string} batch_number - 批次编号
|
||||
* @property {PigBatchOriginType} origin_type - 批次来源
|
||||
* @property {string} start_date - 批次开始日期
|
||||
* @property {string} [start_date] - 批次开始日期
|
||||
* @property {string} [end_date] - 批次结束日期
|
||||
* @property {number} initial_count - 初始数量
|
||||
* @property {PigBatchStatus} status - 批次状态
|
||||
* @property {boolean} is_active - 是否活跃
|
||||
* @property {string} create_time - 创建时间
|
||||
* @property {string} update_time - 更新时间
|
||||
* @property {number} currentTotalQuantity - 当前总数
|
||||
* @property {number} currentTotalPigsInPens - 当前存栏总数
|
||||
* @property {number} current_total_quantity - 当前总数
|
||||
* @property {number} current_total_pigs_in_pens - 当前存栏总数
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -57,54 +64,54 @@ import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* @typedef {object} BuyPigsRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 买入猪只数量
|
||||
* @property {number} unitPrice - 单价
|
||||
* @property {number} totalPrice - 总价
|
||||
* @property {string} traderName - 交易方名称
|
||||
* @property {string} tradeDate - 交易日期
|
||||
* @property {number} unit_price - 单价
|
||||
* @property {number} total_price - 总价
|
||||
* @property {string} trader_name - 交易方名称
|
||||
* @property {string} trade_date - 交易日期
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} SellPigsRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 卖出猪只数量
|
||||
* @property {number} unitPrice - 单价
|
||||
* @property {number} totalPrice - 总价
|
||||
* @property {string} traderName - 交易方名称
|
||||
* @property {string} tradeDate - 交易日期
|
||||
* @property {number} unit_price - 单价
|
||||
* @property {number} total_price - 总价
|
||||
* @property {string} trader_name - 交易方名称
|
||||
* @property {string} trade_date - 交易日期
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} MovePigsIntoPenRequest
|
||||
* @property {number} toPenID - 目标猪栏ID
|
||||
* @property {number} to_pen_id - 目标猪栏ID
|
||||
* @property {number} quantity - 移入猪只数量
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} TransferPigsWithinBatchRequest
|
||||
* @property {number} fromPenID - 源猪栏ID
|
||||
* @property {number} toPenID - 目标猪栏ID
|
||||
* @property {number} from_pen_id - 源猪栏ID
|
||||
* @property {number} to_pen_id - 目标猪栏ID
|
||||
* @property {number} quantity - 调栏猪只数量
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} TransferPigsAcrossBatchesRequest
|
||||
* @property {number} fromPenID - 源猪栏ID
|
||||
* @property {number} destBatchID - 目标猪批次ID
|
||||
* @property {number} toPenID - 目标猪栏ID
|
||||
* @property {number} dest_batch_id - 目标猪批次ID
|
||||
* @property {number} from_pen_id - 源猪栏ID
|
||||
* @property {number} to_pen_id - 目标猪栏ID
|
||||
* @property {number} quantity - 调栏猪只数量
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ReclassifyPenToNewBatchRequest
|
||||
* @property {number} penID - 待划拨的猪栏ID
|
||||
* @property {number} toBatchID - 目标猪批次ID
|
||||
* @property {number} pen_id - 待划拨的猪栏ID
|
||||
* @property {number} to_batch_id - 目标猪批次ID
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
@@ -114,53 +121,53 @@ import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* @typedef {object} RecordSickPigsRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 病猪数量
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatmentLocation - 治疗地点
|
||||
* @property {string} happenedAt - 发生时间
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatment_location - 治疗地点
|
||||
* @property {string} happened_at - 发生时间
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RecordSickPigRecoveryRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 康复猪数量
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatmentLocation - 治疗地点
|
||||
* @property {string} happenedAt - 发生时间
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatment_location - 治疗地点
|
||||
* @property {string} happened_at - 发生时间
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RecordSickPigDeathRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 死亡猪数量
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatmentLocation - 治疗地点
|
||||
* @property {string} happenedAt - 发生时间
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatment_location - 治疗地点
|
||||
* @property {string} happened_at - 发生时间
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RecordSickPigCullRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 淘汰猪数量
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatmentLocation - 治疗地点
|
||||
* @property {string} happenedAt - 发生时间
|
||||
* @property {PigBatchSickPigTreatmentLocation} treatment_location - 治疗地点
|
||||
* @property {string} happened_at - 发生时间
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RecordDeathRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 死亡猪数量
|
||||
* @property {string} happenedAt - 发生时间
|
||||
* @property {string} happened_at - 发生时间
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RecordCullRequest
|
||||
* @property {number} penID - 猪栏ID
|
||||
* @property {number} pen_id - 猪栏ID
|
||||
* @property {number} quantity - 淘汰猪数量
|
||||
* @property {string} happenedAt - 发生时间
|
||||
* @property {string} happened_at - 发生时间
|
||||
* @property {string} [remarks] - 备注
|
||||
*/
|
||||
|
||||
@@ -190,7 +197,10 @@ import http from '../utils/http';
|
||||
* @returns {Promise<Array<PigBatchResponseDTO>>}
|
||||
*/
|
||||
export const getPigBatches = (params) => {
|
||||
return http.get('/api/v1/pig-batches', { params });
|
||||
const newParams = {
|
||||
is_active: params.is_active,
|
||||
};
|
||||
return http.get('/api/v1/pig-batches', { params: newParams });
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -224,7 +234,7 @@ export const updatePigBatch = (id, batchData) => {
|
||||
/**
|
||||
* 根据ID删除一个猪批次
|
||||
* @param {number} id - 猪批次ID
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const deletePigBatch = (id) => {
|
||||
return http.delete(`/api/v1/pig-batches/${id}`);
|
||||
@@ -236,7 +246,7 @@ export const deletePigBatch = (id) => {
|
||||
* 为猪批次分配空栏
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {AssignEmptyPensToBatchRequest} pensData - 待分配的猪栏ID列表
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const assignPensToBatch = (id, pensData) => {
|
||||
return http.post(`/api/v1/pig-batches/assign-pens/${id}`, pensData);
|
||||
@@ -246,7 +256,7 @@ export const assignPensToBatch = (id, pensData) => {
|
||||
* 从猪批次移除空栏
|
||||
* @param {number} penID - 待移除的猪栏ID
|
||||
* @param {number} batchID - 猪批次ID
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const removePenFromBatch = (penID, batchID) => {
|
||||
return http.delete(`/api/v1/pig-batches/remove-pen/${penID}/${batchID}`);
|
||||
@@ -256,7 +266,7 @@ export const removePenFromBatch = (penID, batchID) => {
|
||||
* 处理买猪的业务逻辑
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {BuyPigsRequest} buyData - 买猪请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const buyPigsForBatch = (id, buyData) => {
|
||||
return http.post(`/api/v1/pig-batches/buy-pigs/${id}`, buyData);
|
||||
@@ -266,7 +276,7 @@ export const buyPigsForBatch = (id, buyData) => {
|
||||
* 处理卖猪的业务逻辑
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {SellPigsRequest} sellData - 卖猪请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const sellPigsFromBatch = (id, sellData) => {
|
||||
return http.post(`/api/v1/pig-batches/sell-pigs/${id}`, sellData);
|
||||
@@ -276,7 +286,7 @@ export const sellPigsFromBatch = (id, sellData) => {
|
||||
* 将猪只从“虚拟库存”移入指定猪栏
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {MovePigsIntoPenRequest} moveData - 移入猪只请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const movePigsIntoPen = (id, moveData) => {
|
||||
return http.post(`/api/v1/pig-batches/move-pigs-into-pen/${id}`, moveData);
|
||||
@@ -286,7 +296,7 @@ export const movePigsIntoPen = (id, moveData) => {
|
||||
* 群内调栏
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {TransferPigsWithinBatchRequest} transferData - 群内调栏请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const transferPigsWithinBatch = (id, transferData) => {
|
||||
return http.post(`/api/v1/pig-batches/transfer-within-batch/${id}`, transferData);
|
||||
@@ -296,7 +306,7 @@ export const transferPigsWithinBatch = (id, transferData) => {
|
||||
* 跨猪群调栏
|
||||
* @param {number} sourceBatchID - 源猪批次ID
|
||||
* @param {TransferPigsAcrossBatchesRequest} transferData - 跨群调栏请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const transferPigsAcrossBatches = (sourceBatchID, transferData) => {
|
||||
return http.post(`/api/v1/pig-batches/transfer-across-batches/${sourceBatchID}`, transferData);
|
||||
@@ -306,7 +316,7 @@ export const transferPigsAcrossBatches = (sourceBatchID, transferData) => {
|
||||
* 将猪栏划拨到新批次
|
||||
* @param {number} fromBatchID - 源猪批次ID
|
||||
* @param {ReclassifyPenToNewBatchRequest} reclassifyData - 划拨请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const reclassifyPenToNewBatch = (fromBatchID, reclassifyData) => {
|
||||
return http.post(`/api/v1/pig-batches/reclassify-pen/${fromBatchID}`, reclassifyData);
|
||||
@@ -318,7 +328,7 @@ export const reclassifyPenToNewBatch = (fromBatchID, reclassifyData) => {
|
||||
* 记录新增病猪事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {RecordSickPigsRequest} sickData - 记录病猪请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const recordSickPigsInBatch = (id, sickData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pigs/${id}`, sickData);
|
||||
@@ -328,7 +338,7 @@ export const recordSickPigsInBatch = (id, sickData) => {
|
||||
* 记录病猪康复事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {RecordSickPigRecoveryRequest} recoveryData - 记录病猪康复请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const recordSickPigRecoveryInBatch = (id, recoveryData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pig-recovery/${id}`, recoveryData);
|
||||
@@ -338,7 +348,7 @@ export const recordSickPigRecoveryInBatch = (id, recoveryData) => {
|
||||
* 记录病猪死亡事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {RecordSickPigDeathRequest} deathData - 记录病猪死亡请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const recordSickPigDeathInBatch = (id, deathData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pig-death/${id}`, deathData);
|
||||
@@ -348,7 +358,7 @@ export const recordSickPigDeathInBatch = (id, deathData) => {
|
||||
* 记录病猪淘汰事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {RecordSickPigCullRequest} cullData - 记录病猪淘汰请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const recordSickPigCullInBatch = (id, cullData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pig-cull/${id}`, cullData);
|
||||
@@ -358,7 +368,7 @@ export const recordSickPigCullInBatch = (id, cullData) => {
|
||||
* 记录正常猪只死亡事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {RecordDeathRequest} deathData - 记录正常猪只死亡请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const recordDeathInBatch = (id, deathData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-death/${id}`, deathData);
|
||||
@@ -368,7 +378,7 @@ export const recordDeathInBatch = (id, deathData) => {
|
||||
* 记录正常猪只淘汰事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {RecordCullRequest} cullData - 记录正常猪只淘汰请求信息
|
||||
* @returns {Promise<*>}
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export const recordCullInBatch = (id, cullData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-cull/${id}`, cullData);
|
||||
@@ -391,3 +401,27 @@ export const getAllPens = () => {
|
||||
export const getAllPigHouses = () => {
|
||||
return http.get('/api/v1/pig-houses');
|
||||
};
|
||||
|
||||
export const PigBatchApi = {
|
||||
getPigBatches,
|
||||
createPigBatch,
|
||||
getPigBatchById,
|
||||
updatePigBatch,
|
||||
deletePigBatch,
|
||||
assignPensToBatch,
|
||||
removePenFromBatch,
|
||||
buyPigsForBatch,
|
||||
sellPigsFromBatch,
|
||||
movePigsIntoPen,
|
||||
transferPigsWithinBatch,
|
||||
transferPigsAcrossBatches,
|
||||
reclassifyPenToNewBatch,
|
||||
recordSickPigsInBatch,
|
||||
recordSickPigRecoveryInBatch,
|
||||
recordSickPigDeathInBatch,
|
||||
recordSickPigCullInBatch,
|
||||
recordDeathInBatch,
|
||||
recordCullInBatch,
|
||||
getAllPens,
|
||||
getAllPigHouses,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user