更新后端api
This commit is contained in:
26
.gitignore
vendored
26
.gitignore
vendored
@@ -1,12 +1,22 @@
|
||||
# ---> Vue
|
||||
# gitignore template for Vue.js projects
|
||||
#
|
||||
# Recommended template: Node.gitignore
|
||||
# Logs
|
||||
npm-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# TODO: where does this rule come from?
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# Build output
|
||||
dist/
|
||||
|
||||
# Environment variables
|
||||
.env*
|
||||
*.local
|
||||
|
||||
# IDE config
|
||||
.idea/
|
||||
|
||||
# Docs
|
||||
docs/_book
|
||||
|
||||
# TODO: where does this rule come from?
|
||||
# Tests
|
||||
test/
|
||||
|
||||
.idea/
|
||||
5519
docs/swagger.json
5519
docs/swagger.json
File diff suppressed because it is too large
Load Diff
14
node_modules/.package-lock.json
generated
vendored
14
node_modules/.package-lock.json
generated
vendored
@@ -9676,6 +9676,20 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.12.0",
|
||||
"resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-7.12.0.tgz",
|
||||
|
||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -9718,6 +9718,20 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.12.0",
|
||||
"resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-7.12.0.tgz",
|
||||
|
||||
46
src/api/areaController.js
Normal file
46
src/api/areaController.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 获取系统中所有区域主控的列表
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getAreaControllers = () => {
|
||||
return http.get('/api/v1/area-controllers');
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据提供的信息创建一个新区域主控
|
||||
* @param {object} areaControllerData - 区域主控信息,对应 dto.CreateAreaControllerRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const createAreaController = (areaControllerData) => {
|
||||
return http.post('/api/v1/area-controllers', areaControllerData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID获取单个区域主控的详细信息
|
||||
* @param {string} id - 区域主控ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getAreaControllerById = (id) => {
|
||||
return http.get(`/api/v1/area-controllers/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID更新一个已存在的区域主控信息
|
||||
* @param {string} id - 区域主控ID
|
||||
* @param {object} areaControllerData - 要更新的区域主控信息,对应 dto.UpdateAreaControllerRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updateAreaController = (id, areaControllerData) => {
|
||||
return http.put(`/api/v1/area-controllers/${id}`, areaControllerData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID删除一个区域主控(软删除)
|
||||
* @param {string} id - 区域主控ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deleteAreaController = (id) => {
|
||||
return http.delete(`/api/v1/area-controllers/${id}`);
|
||||
};
|
||||
@@ -1,101 +1,56 @@
|
||||
import http from '../utils/http.js';
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 区域主控管理API
|
||||
* 获取系统中所有设备的列表
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export class AreaControllerApi {
|
||||
/**
|
||||
* 获取区域主控列表
|
||||
* @returns {Promise} 区域主控列表
|
||||
*/
|
||||
static list() {
|
||||
return http.get('/api/v1/area-controllers');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新区域主控
|
||||
* @param {Object} areaControllerData 区域主控数据
|
||||
* @returns {Promise} 创建结果
|
||||
*/
|
||||
static create(areaControllerData) {
|
||||
return http.post('/api/v1/area-controllers', areaControllerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域主控详情
|
||||
* @param {string|number} id 区域主控ID
|
||||
* @returns {Promise} 区域主控详情
|
||||
*/
|
||||
static get(id) {
|
||||
return http.get(`/api/v1/area-controllers/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新区域主控信息
|
||||
* @param {string|number} id 区域主控ID
|
||||
* @param {Object} areaControllerData 区域主控数据
|
||||
* @returns {Promise} 更新结果
|
||||
*/
|
||||
static update(id, areaControllerData) {
|
||||
return http.put(`/api/v1/area-controllers/${id}`, areaControllerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除区域主控
|
||||
* @param {string|number} id 区域主控ID
|
||||
* @returns {Promise} 删除结果
|
||||
*/
|
||||
static delete(id) {
|
||||
return http.delete(`/api/v1/area-controllers/${id}`);
|
||||
}
|
||||
}
|
||||
export const getDevices = () => {
|
||||
return http.get('/api/v1/devices');
|
||||
};
|
||||
|
||||
/**
|
||||
* 普通设备管理API
|
||||
* 根据提供的信息创建一个新设备
|
||||
* @param {object} deviceData - 设备信息,对应 dto.CreateDeviceRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export class DeviceApi {
|
||||
/**
|
||||
* 获取设备列表
|
||||
* @returns {Promise} 设备列表
|
||||
*/
|
||||
static list() {
|
||||
return http.get('/api/v1/devices');
|
||||
}
|
||||
export const createDevice = (deviceData) => {
|
||||
return http.post('/api/v1/devices', deviceData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建新设备
|
||||
* @param {Object} deviceData 设备数据
|
||||
* @returns {Promise} 创建结果
|
||||
*/
|
||||
static create(deviceData) {
|
||||
return http.post('/api/v1/devices', deviceData);
|
||||
}
|
||||
/**
|
||||
* 根据设备ID获取单个设备的详细信息
|
||||
* @param {string} id - 设备ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getDeviceById = (id) => {
|
||||
return http.get(`/api/v1/devices/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取设备详情
|
||||
* @param {string|number} id 设备ID
|
||||
* @returns {Promise} 设备详情
|
||||
*/
|
||||
static get(id) {
|
||||
return http.get(`/api/v1/devices/${id}`);
|
||||
}
|
||||
/**
|
||||
* 根据设备ID更新一个已存在的设备信息
|
||||
* @param {string} id - 设备ID
|
||||
* @param {object} deviceData - 要更新的设备信息,对应 dto.UpdateDeviceRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updateDevice = (id, deviceData) => {
|
||||
return http.put(`/api/v1/devices/${id}`, deviceData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新设备信息
|
||||
* @param {string|number} id 设备ID
|
||||
* @param {Object} deviceData 设备数据
|
||||
* @returns {Promise} 更新结果
|
||||
*/
|
||||
static update(id, deviceData) {
|
||||
return http.put(`/api/v1/devices/${id}`, deviceData);
|
||||
}
|
||||
/**
|
||||
* 根据设备ID删除一个设备(软删除)
|
||||
* @param {string} id - 设备ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deleteDevice = (id) => {
|
||||
return http.delete(`/api/v1/devices/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除设备
|
||||
* @param {string|number} id 设备ID
|
||||
* @returns {Promise} 删除结果
|
||||
*/
|
||||
static delete(id) {
|
||||
return http.delete(`/api/v1/devices/${id}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据设备ID和指定的动作(开启或关闭)来手动控制设备
|
||||
* @param {string} id - 设备ID
|
||||
* @param {object} manualControlData - 手动控制指令,对应 dto.ManualControlDeviceRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const manualControlDevice = (id, manualControlData) => {
|
||||
return http.post(`/api/v1/devices/manual-control/${id}`, manualControlData);
|
||||
};
|
||||
|
||||
@@ -1,53 +1,46 @@
|
||||
import http from '../utils/http.js';
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 设备模板管理API
|
||||
* 获取系统中所有设备模板的列表
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export class DeviceTemplateApi {
|
||||
/**
|
||||
* 获取设备模板列表
|
||||
* @returns {Promise} 设备模板列表
|
||||
*/
|
||||
static list() {
|
||||
return http.get('/api/v1/device-templates');
|
||||
}
|
||||
export const getDeviceTemplates = () => {
|
||||
return http.get('/api/v1/device-templates');
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建新设备模板
|
||||
* @param {Object} deviceTemplateData 设备模板数据
|
||||
* @returns {Promise} 创建结果
|
||||
*/
|
||||
static create(deviceTemplateData) {
|
||||
return http.post('/api/v1/device-templates', deviceTemplateData);
|
||||
}
|
||||
/**
|
||||
* 根据提供的信息创建一个新设备模板
|
||||
* @param {object} deviceTemplateData - 设备模板信息,对应 dto.CreateDeviceTemplateRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const createDeviceTemplate = (deviceTemplateData) => {
|
||||
return http.post('/api/v1/device-templates', deviceTemplateData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取设备模板详情
|
||||
* @param {string|number} id 设备模板ID
|
||||
* @returns {Promise} 设备模板详情
|
||||
*/
|
||||
static get(id) {
|
||||
return http.get(`/api/v1/device-templates/${id}`);
|
||||
}
|
||||
/**
|
||||
* 根据设备模板ID获取单个设备模板的详细信息
|
||||
* @param {string} id - 设备模板ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getDeviceTemplateById = (id) => {
|
||||
return http.get(`/api/v1/device-templates/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新设备模板信息
|
||||
* @param {string|number} id 设备模板ID
|
||||
* @param {Object} deviceTemplateData 设备模板数据
|
||||
* @returns {Promise} 更新结果
|
||||
*/
|
||||
static update(id, deviceTemplateData) {
|
||||
return http.put(`/api/v1/device-templates/${id}`, deviceTemplateData);
|
||||
}
|
||||
/**
|
||||
* 根据设备模板ID更新一个已存在的设备模板信息
|
||||
* @param {string} id - 设备模板ID
|
||||
* @param {object} deviceTemplateData - 要更新的设备模板信息,对应 dto.UpdateDeviceTemplateRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updateDeviceTemplate = (id, deviceTemplateData) => {
|
||||
return http.put(`/api/v1/device-templates/${id}`, deviceTemplateData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除设备模板
|
||||
* @param {string|number} id 设备模板ID
|
||||
* @returns {Promise} 删除结果
|
||||
*/
|
||||
static delete(id) {
|
||||
return http.delete(`/api/v1/device-templates/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default DeviceTemplateApi;
|
||||
/**
|
||||
* 根据设备模板ID删除一个设备模板(软删除)
|
||||
* @param {string} id - 设备模板ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deleteDeviceTemplate = (id) => {
|
||||
return http.delete(`/api/v1/device-templates/${id}`);
|
||||
};
|
||||
|
||||
154
src/api/monitor.js
Normal file
154
src/api/monitor.js
Normal file
@@ -0,0 +1,154 @@
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 获取设备命令日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getDeviceCommandLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/device-command-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取饲料使用记录列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getFeedUsageRecords = (params) => {
|
||||
return http.get('/api/v1/monitor/feed-usage-records', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取用药记录列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getMedicationLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/medication-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取待采集请求列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPendingCollections = (params) => {
|
||||
return http.get('/api/v1/monitor/pending-collections', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取猪批次日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigBatchLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/pig-batch-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取猪只采购记录列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigPurchases = (params) => {
|
||||
return http.get('/api/v1/monitor/pig-purchases', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取猪只售卖记录列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigSales = (params) => {
|
||||
return http.get('/api/v1/monitor/pig-sales', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取病猪日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigSickLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/pig-sick-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取猪只迁移日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigTransferLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/pig-transfer-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取计划执行日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPlanExecutionLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/plan-execution-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取原料采购记录列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getRawMaterialPurchases = (params) => {
|
||||
return http.get('/api/v1/monitor/raw-material-purchases', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取原料库存日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getRawMaterialStockLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/raw-material-stock-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取传感器数据列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getSensorData = (params) => {
|
||||
return http.get('/api/v1/monitor/sensor-data', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取任务执行日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getTaskExecutionLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/task-execution-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取用户操作日志列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getUserActionLogs = (params) => {
|
||||
return http.get('/api/v1/monitor/user-action-logs', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取批次称重记录列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getWeighingBatches = (params) => {
|
||||
return http.get('/api/v1/monitor/weighing-batches', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取单次称重记录列表
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getWeighingRecords = (params) => {
|
||||
return http.get('/api/v1/monitor/weighing-records', { params });
|
||||
};
|
||||
56
src/api/pen.js
Normal file
56
src/api/pen.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 获取所有猪栏的列表
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPens = () => {
|
||||
return http.get('/api/v1/pens');
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建一个新的猪栏
|
||||
* @param {object} penData - 猪栏信息,对应 dto.CreatePenRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const createPen = (penData) => {
|
||||
return http.post('/api/v1/pens', penData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID获取单个猪栏信息
|
||||
* @param {number} id - 猪栏ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPenById = (id) => {
|
||||
return http.get(`/api/v1/pens/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新一个已存在的猪栏信息
|
||||
* @param {number} id - 猪栏ID
|
||||
* @param {object} penData - 猪栏信息,对应 dto.UpdatePenRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updatePen = (id, penData) => {
|
||||
return http.put(`/api/v1/pens/${id}`, penData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID删除一个猪栏
|
||||
* @param {number} id - 猪栏ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deletePen = (id) => {
|
||||
return http.delete(`/api/v1/pens/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新指定猪栏的当前状态
|
||||
* @param {number} id - 猪栏ID
|
||||
* @param {object} statusData - 新的猪栏状态,对应 dto.UpdatePenStatusRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updatePenStatus = (id, statusData) => {
|
||||
return http.put(`/api/v1/pens/${id}/status`, statusData);
|
||||
};
|
||||
193
src/api/pigBatch.js
Normal file
193
src/api/pigBatch.js
Normal file
@@ -0,0 +1,193 @@
|
||||
import http from '../utils/http';
|
||||
|
||||
// --- 猪批次基础操作 ---
|
||||
|
||||
/**
|
||||
* 获取所有猪批次的列表
|
||||
* @param {object} params - 查询参数,例如 { is_active: true }
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigBatches = (params) => {
|
||||
return http.get('/api/v1/pig-batches', { params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建一个新的猪批次
|
||||
* @param {object} batchData - 猪批次信息,对应 dto.PigBatchCreateDTO
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const createPigBatch = (batchData) => {
|
||||
return http.post('/api/v1/pig-batches', batchData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID获取单个猪批次信息
|
||||
* @param {number} id - 猪批次ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigBatchById = (id) => {
|
||||
return http.get(`/api/v1/pig-batches/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新一个已存在的猪批次信息
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} batchData - 猪批次信息,对应 dto.PigBatchUpdateDTO
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updatePigBatch = (id, batchData) => {
|
||||
return http.put(`/api/v1/pig-batches/${id}`, batchData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID删除一个猪批次
|
||||
* @param {number} id - 猪批次ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deletePigBatch = (id) => {
|
||||
return http.delete(`/api/v1/pig-batches/${id}`);
|
||||
};
|
||||
|
||||
// --- 猪批次业务操作 ---
|
||||
|
||||
/**
|
||||
* 为猪批次分配空栏
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} pensData - 待分配的猪栏ID列表,对应 dto.AssignEmptyPensToBatchRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const assignPensToBatch = (id, pensData) => {
|
||||
return http.post(`/api/v1/pig-batches/assign-pens/${id}`, pensData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 从猪批次移除空栏
|
||||
* @param {number} batchID - 猪批次ID
|
||||
* @param {number} penID - 待移除的猪栏ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const removePenFromBatch = (batchID, penID) => {
|
||||
return http.delete(`/api/v1/pig-batches/remove-pen/${penID}/${batchID}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理买猪的业务逻辑
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} buyData - 买猪请求信息,对应 dto.BuyPigsRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const buyPigsForBatch = (id, buyData) => {
|
||||
return http.post(`/api/v1/pig-batches/buy-pigs/${id}`, buyData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理卖猪的业务逻辑
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} sellData - 卖猪请求信息,对应 dto.SellPigsRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const sellPigsFromBatch = (id, sellData) => {
|
||||
return http.post(`/api/v1/pig-batches/sell-pigs/${id}`, sellData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 将猪只从“虚拟库存”移入指定猪栏
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} moveData - 移入猪只请求信息,对应 dto.MovePigsIntoPenRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const movePigsIntoPen = (id, moveData) => {
|
||||
return http.post(`/api/v1/pig-batches/move-pigs-into-pen/${id}`, moveData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 群内调栏
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} transferData - 群内调栏请求信息,对应 dto.TransferPigsWithinBatchRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const transferPigsWithinBatch = (id, transferData) => {
|
||||
return http.post(`/api/v1/pig-batches/transfer-within-batch/${id}`, transferData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 跨猪群调栏
|
||||
* @param {number} sourceBatchID - 源猪批次ID
|
||||
* @param {object} transferData - 跨群调栏请求信息,对应 dto.TransferPigsAcrossBatchesRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const transferPigsAcrossBatches = (sourceBatchID, transferData) => {
|
||||
return http.post(`/api/v1/pig-batches/transfer-across-batches/${sourceBatchID}`, transferData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 将猪栏划拨到新批次
|
||||
* @param {number} fromBatchID - 源猪批次ID
|
||||
* @param {object} reclassifyData - 划拨请求信息,对应 dto.ReclassifyPenToNewBatchRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const reclassifyPenToNewBatch = (fromBatchID, reclassifyData) => {
|
||||
return http.post(`/api/v1/pig-batches/reclassify-pen/${fromBatchID}`, reclassifyData);
|
||||
};
|
||||
|
||||
// --- 猪只数量变更记录 ---
|
||||
|
||||
/**
|
||||
* 记录新增病猪事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} sickData - 记录病猪请求信息,对应 dto.RecordSickPigsRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const recordSickPigsInBatch = (id, sickData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pigs/${id}`, sickData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 记录病猪康复事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} recoveryData - 记录病猪康复请求信息,对应 dto.RecordSickPigRecoveryRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const recordSickPigRecoveryInBatch = (id, recoveryData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pig-recovery/${id}`, recoveryData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 记录病猪死亡事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} deathData - 记录病猪死亡请求信息,对应 dto.RecordSickPigDeathRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const recordSickPigDeathInBatch = (id, deathData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pig-death/${id}`, deathData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 记录病猪淘汰事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} cullData - 记录病猪淘汰请求信息,对应 dto.RecordSickPigCullRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const recordSickPigCullInBatch = (id, cullData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-sick-pig-cull/${id}`, cullData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 记录正常猪只死亡事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} deathData - 记录正常猪只死亡请求信息,对应 dto.RecordDeathRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const recordDeathInBatch = (id, deathData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-death/${id}`, deathData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 记录正常猪只淘汰事件
|
||||
* @param {number} id - 猪批次ID
|
||||
* @param {object} cullData - 记录正常猪只淘汰请求信息,对应 dto.RecordCullRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const recordCullInBatch = (id, cullData) => {
|
||||
return http.post(`/api/v1/pig-batches/record-cull/${id}`, cullData);
|
||||
};
|
||||
46
src/api/pigHouse.js
Normal file
46
src/api/pigHouse.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 获取所有猪舍的列表
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigHouses = () => {
|
||||
return http.get('/api/v1/pig-houses');
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建一个新的猪舍
|
||||
* @param {object} pigHouseData - 猪舍信息,对应 dto.CreatePigHouseRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const createPigHouse = (pigHouseData) => {
|
||||
return http.post('/api/v1/pig-houses', pigHouseData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID获取单个猪舍信息
|
||||
* @param {number} id - 猪舍ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPigHouseById = (id) => {
|
||||
return http.get(`/api/v1/pig-houses/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新一个已存在的猪舍信息
|
||||
* @param {number} id - 猪舍ID
|
||||
* @param {object} pigHouseData - 猪舍信息,对应 dto.UpdatePigHouseRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updatePigHouse = (id, pigHouseData) => {
|
||||
return http.put(`/api/v1/pig-houses/${id}`, pigHouseData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据ID删除一个猪舍
|
||||
* @param {number} id - 猪舍ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deletePigHouse = (id) => {
|
||||
return http.delete(`/api/v1/pig-houses/${id}`);
|
||||
};
|
||||
117
src/api/plan.js
117
src/api/plan.js
@@ -1,71 +1,64 @@
|
||||
import http from '../utils/http.js';
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 计划管理API
|
||||
* 获取所有计划的列表
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export class PlanApi {
|
||||
/**
|
||||
* 获取计划列表
|
||||
* @returns {Promise} 计划列表
|
||||
*/
|
||||
static list() {
|
||||
return http.get('/api/v1/plans');
|
||||
}
|
||||
export const getPlans = () => {
|
||||
return http.get('/api/v1/plans');
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建新计划
|
||||
* @param {Object} planData 计划数据
|
||||
* @returns {Promise} 创建结果
|
||||
*/
|
||||
static create(planData) {
|
||||
return http.post('/api/v1/plans', planData);
|
||||
}
|
||||
/**
|
||||
* 创建一个新的计划
|
||||
* @param {object} planData - 计划信息,对应 dto.CreatePlanRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const createPlan = (planData) => {
|
||||
return http.post('/api/v1/plans', planData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取计划详情
|
||||
* @param {string|number} id 计划ID
|
||||
* @returns {Promise} 计划详情
|
||||
*/
|
||||
static get(id) {
|
||||
return http.get(`/api/v1/plans/${id}`);
|
||||
}
|
||||
/**
|
||||
* 根据计划ID获取单个计划的详细信息
|
||||
* @param {number} id - 计划ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getPlanById = (id) => {
|
||||
return http.get(`/api/v1/plans/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新计划信息
|
||||
* @param {string|number} id 计划ID
|
||||
* @param {Object} planData 计划数据
|
||||
* @returns {Promise} 更新结果
|
||||
*/
|
||||
static update(id, planData) {
|
||||
return http.put(`/api/v1/plans/${id}`, planData);
|
||||
}
|
||||
/**
|
||||
* 根据计划ID更新计划的详细信息
|
||||
* @param {number} id - 计划ID
|
||||
* @param {object} planData - 更新后的计划信息,对应 dto.UpdatePlanRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updatePlan = (id, planData) => {
|
||||
return http.put(`/api/v1/plans/${id}`, planData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除计划
|
||||
* @param {string|number} id 计划ID
|
||||
* @returns {Promise} 删除结果
|
||||
*/
|
||||
static delete(id) {
|
||||
return http.delete(`/api/v1/plans/${id}`);
|
||||
}
|
||||
/**
|
||||
* 根据计划ID删除计划(软删除)
|
||||
* @param {number} id - 计划ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deletePlan = (id) => {
|
||||
return http.delete(`/api/v1/plans/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 启动计划
|
||||
* @param {string|number} id 计划ID
|
||||
* @returns {Promise} 启动结果
|
||||
*/
|
||||
static start(id) {
|
||||
return http.post(`/api/v1/plans/${id}/start`);
|
||||
}
|
||||
/**
|
||||
* 根据计划ID启动一个计划的执行
|
||||
* @param {number} id - 计划ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const startPlan = (id) => {
|
||||
return http.post(`/api/v1/plans/${id}/start`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 停止计划
|
||||
* @param {string|number} id 计划ID
|
||||
* @returns {Promise} 停止结果
|
||||
*/
|
||||
static stop(id) {
|
||||
return http.post(`/api/v1/plans/${id}/stop`);
|
||||
}
|
||||
}
|
||||
|
||||
export default PlanApi;
|
||||
/**
|
||||
* 根据计划ID停止一个正在执行的计划
|
||||
* @param {number} id - 计划ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const stopPlan = (id) => {
|
||||
return http.post(`/api/v1/plans/${id}/stop`);
|
||||
};
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
import http from '../utils/http.js';
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 用户管理API
|
||||
* 创建一个新用户
|
||||
* @param {object} userData - 用户信息,对应 dto.CreateUserRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export class UserApi {
|
||||
/**
|
||||
* 创建新用户
|
||||
* @param {Object} userData 用户数据
|
||||
* @returns {Promise} 创建结果
|
||||
*/
|
||||
static create(userData) {
|
||||
return http.post('/api/v1/users', userData);
|
||||
}
|
||||
export const createUser = (userData) => {
|
||||
return http.post('/api/v1/users', userData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @param {Object} credentials 登录凭证 {username, password}
|
||||
* @returns {Promise} 登录结果
|
||||
*/
|
||||
static login(credentials) {
|
||||
return http.post('/api/v1/users/login', credentials);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 用户登录
|
||||
* @param {object} credentials - 登录凭证,对应 dto.LoginRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const login = (credentials) => {
|
||||
return http.post('/api/v1/users/login', credentials);
|
||||
};
|
||||
|
||||
export default UserApi;
|
||||
/**
|
||||
* 获取指定用户的操作历史
|
||||
* @param {number} id - 用户ID
|
||||
* @param {object} params - 查询参数
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getUserHistory = (id, params) => {
|
||||
return http.get(`/api/v1/users/${id}/history`, { params });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user