修改api.js
This commit is contained in:
		| @@ -1,5 +1,12 @@ | ||||
| import http from '../utils/http'; | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} Response | ||||
|  * @property {number} code - 业务状态码 | ||||
|  * @property {object} [data] - 业务数据 | ||||
|  * @property {string} [message] - 提示信息 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} AreaControllerResponse | ||||
|  * @property {number} id | ||||
| @@ -67,8 +74,16 @@ export const updateAreaController = (id, areaControllerData) => { | ||||
| /** | ||||
|  * 根据ID删除一个区域主控(软删除) | ||||
|  * @param {string} id - 区域主控ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| export const deleteAreaController = (id) => { | ||||
|   return http.delete(`/api/v1/area-controllers/${id}`); | ||||
| }; | ||||
|  | ||||
| export const AreaControllerApi = { | ||||
|   list: getAreaControllers, | ||||
|   create: createAreaController, | ||||
|   getById: getAreaControllerById, | ||||
|   update: updateAreaController, | ||||
|   delete: deleteAreaController, | ||||
| }; | ||||
|   | ||||
| @@ -2,6 +2,13 @@ import http from '../utils/http'; | ||||
|  | ||||
| // --- Typedefs --- | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} Response | ||||
|  * @property {number} code - 业务状态码 | ||||
|  * @property {object} [data] - 业务数据 | ||||
|  * @property {string} [message] - 提示信息 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} DeviceResponse | ||||
|  * @property {number} id | ||||
| @@ -109,7 +116,7 @@ export const updateDevice = (id, deviceData) => { | ||||
| /** | ||||
|  * 根据设备ID删除一个设备(软删除) | ||||
|  * @param {string} id - 设备ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| export const deleteDevice = (id) => { | ||||
|   return http.delete(`/api/v1/devices/${id}`); | ||||
| @@ -119,7 +126,7 @@ export const deleteDevice = (id) => { | ||||
|  * 根据设备ID和指定的动作(开启或关闭)来手动控制设备 | ||||
|  * @param {string} id - 设备ID | ||||
|  * @param {ManualControlDeviceRequest} manualControlData - 手动控制指令 | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| export const manualControlDevice = (id, manualControlData) => { | ||||
|   return http.post(`/api/v1/devices/manual-control/${id}`, manualControlData); | ||||
| @@ -167,7 +174,7 @@ export const updateAreaController = (id, areaControllerData) => { | ||||
| /** | ||||
|  * 根据ID删除一个区域主控 | ||||
|  * @param {string} id - 区域主控ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| export const deleteAreaController = (id) => { | ||||
|   return http.delete(`/api/v1/area-controllers/${id}`); | ||||
|   | ||||
| @@ -1,5 +1,12 @@ | ||||
| import http from '../utils/http'; | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} Response | ||||
|  * @property {number} code - 业务状态码 | ||||
|  * @property {object} [data] - 业务数据 | ||||
|  * @property {string} [message] - 提示信息 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {('执行器'|'传感器')} DeviceCategory | ||||
|  */ | ||||
| @@ -68,7 +75,7 @@ const createDeviceTemplate = (deviceTemplateData) => { | ||||
|  | ||||
| /** | ||||
|  * 根据设备模板ID获取单个设备模板的详细信息 | ||||
|  * @param {string} id - 设备模板ID | ||||
|  * @param {number} id - 设备模板ID | ||||
|  * @returns {Promise<DeviceTemplateResponse>} | ||||
|  */ | ||||
| const getDeviceTemplateById = (id) => { | ||||
| @@ -77,7 +84,7 @@ const getDeviceTemplateById = (id) => { | ||||
|  | ||||
| /** | ||||
|  * 根据设备模板ID更新一个已存在的设备模板信息 | ||||
|  * @param {string} id - 设备模板ID | ||||
|  * @param {number} id - 设备模板ID | ||||
|  * @param {UpdateDeviceTemplateRequest} deviceTemplateData - 要更新的设备模板信息 | ||||
|  * @returns {Promise<DeviceTemplateResponse>} | ||||
|  */ | ||||
| @@ -87,8 +94,8 @@ const updateDeviceTemplate = (id, deviceTemplateData) => { | ||||
|  | ||||
| /** | ||||
|  * 根据设备模板ID删除一个设备模板(软删除) | ||||
|  * @param {string} id - 设备模板ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @param {number} id - 设备模板ID | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| const deleteDeviceTemplate = (id) => { | ||||
|   return http.delete(`/api/v1/device-templates/${id}`); | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PaginationDTO | ||||
|  * @property {number} page | ||||
|  * @property {number} pageSize | ||||
|  * @property {number} page_size | ||||
|  * @property {number} total | ||||
|  */ | ||||
|  | ||||
| @@ -27,7 +27,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} DeviceCommandLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [device_id] | ||||
|  * @property {string} [start_time] | ||||
| @@ -69,7 +69,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} FeedUsageRecordsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pen_id] | ||||
|  * @property {number} [feed_formula_id] | ||||
| @@ -111,7 +111,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} MedicationLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pig_batch_id] | ||||
|  * @property {number} [medication_id] | ||||
| @@ -154,7 +154,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} NotificationsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {string} [start_time] | ||||
|  * @property {string} [end_time] | ||||
| @@ -187,7 +187,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PendingCollectionsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [device_id] | ||||
|  * @property {string} [status] | ||||
| @@ -223,7 +223,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PigBatchLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pig_batch_id] | ||||
|  * @property {string} [change_type] | ||||
| @@ -256,7 +256,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PigPurchasesParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pig_batch_id] | ||||
|  * @property {string} [supplier] | ||||
| @@ -289,7 +289,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PigSalesParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pig_batch_id] | ||||
|  * @property {string} [buyer] | ||||
| @@ -332,7 +332,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PigSickLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pig_batch_id] | ||||
|  * @property {number} [pen_id] | ||||
| @@ -371,7 +371,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PigTransferLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pig_batch_id] | ||||
|  * @property {number} [pen_id] | ||||
| @@ -390,6 +390,7 @@ import http from '../utils/http'; | ||||
|  * @typedef {object} PlanExecutionLogDTO | ||||
|  * @property {number} id | ||||
|  * @property {number} plan_id | ||||
|  * @property {string} plan_name | ||||
|  * @property {ExecutionStatus} status | ||||
|  * @property {string} started_at | ||||
|  * @property {string} ended_at | ||||
| @@ -407,7 +408,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PlanExecutionLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [plan_id] | ||||
|  * @property {string} [status] | ||||
| @@ -443,7 +444,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} RawMaterialPurchasesParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [raw_material_id] | ||||
|  * @property {string} [supplier] | ||||
| @@ -475,7 +476,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} RawMaterialStockLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [raw_material_id] | ||||
|  * @property {string} [source_type] | ||||
| @@ -506,7 +507,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} SensorDataParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [device_id] | ||||
|  * @property {string} [sensor_type] | ||||
| @@ -544,7 +545,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} TaskExecutionLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [plan_execution_log_id] | ||||
|  * @property {number} [task_id] | ||||
| @@ -582,7 +583,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} UserActionLogsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [user_id] | ||||
|  * @property {string} [username] | ||||
| @@ -611,7 +612,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} WeighingBatchesParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [pig_batch_id] | ||||
|  * @property {string} [start_time] | ||||
| @@ -640,7 +641,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} WeighingRecordsParams | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [weighing_batch_id] | ||||
|  * @property {number} [pen_id] | ||||
| @@ -663,7 +664,10 @@ export const ZapcoreLevel = { | ||||
|   DPanic: 3, | ||||
|   Panic: 4, | ||||
|   Fatal: 5, | ||||
|   _minLevel: -1, | ||||
|   _maxLevel: 5, | ||||
|   Invalid: 6, | ||||
|   _numLevels: 7, | ||||
| }; | ||||
|  | ||||
| // --- Functions --- | ||||
| @@ -682,7 +686,8 @@ const processResponse = (responseData) => { | ||||
|  * @returns {Promise<{list: Array<DeviceCommandLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getDeviceCommandLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/device-command-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/device-command-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -692,7 +697,8 @@ export const getDeviceCommandLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<FeedUsageRecordDTO>, total: number}>} | ||||
|  */ | ||||
| export const getFeedUsageRecords = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/feed-usage-records', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/feed-usage-records', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -702,7 +708,8 @@ export const getFeedUsageRecords = async (params) => { | ||||
|  * @returns {Promise<{list: Array<MedicationLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getMedicationLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/medication-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/medication-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -712,7 +719,8 @@ export const getMedicationLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<NotificationDTO>, total: number}>} | ||||
|  */ | ||||
| export const getNotifications = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/notifications', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/notifications', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -722,7 +730,8 @@ export const getNotifications = async (params) => { | ||||
|  * @returns {Promise<{list: Array<PendingCollectionDTO>, total: number}>} | ||||
|  */ | ||||
| export const getPendingCollections = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/pending-collections', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/pending-collections', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -732,7 +741,8 @@ export const getPendingCollections = async (params) => { | ||||
|  * @returns {Promise<{list: Array<PigBatchLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getPigBatchLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-batch-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-batch-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -742,7 +752,8 @@ export const getPigBatchLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<PigPurchaseDTO>, total: number}>} | ||||
|  */ | ||||
| export const getPigPurchases = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-purchases', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-purchases', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -752,7 +763,8 @@ export const getPigPurchases = async (params) => { | ||||
|  * @returns {Promise<{list: Array<PigSaleDTO>, total: number}>} | ||||
|  */ | ||||
| export const getPigSales = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-sales', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-sales', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -762,7 +774,8 @@ export const getPigSales = async (params) => { | ||||
|  * @returns {Promise<{list: Array<PigSickLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getPigSickLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-sick-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-sick-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -772,7 +785,8 @@ export const getPigSickLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<PigTransferLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getPigTransferLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-transfer-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/pig-transfer-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -782,7 +796,8 @@ export const getPigTransferLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<PlanExecutionLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getPlanExecutionLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/plan-execution-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/plan-execution-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -792,7 +807,8 @@ export const getPlanExecutionLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<RawMaterialPurchaseDTO>, total: number}>} | ||||
|  */ | ||||
| export const getRawMaterialPurchases = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/raw-material-purchases', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/raw-material-purchases', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -802,7 +818,8 @@ export const getRawMaterialPurchases = async (params) => { | ||||
|  * @returns {Promise<{list: Array<RawMaterialStockLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getRawMaterialStockLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/raw-material-stock-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/raw-material-stock-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -812,7 +829,8 @@ export const getRawMaterialStockLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<SensorDataDTO>, total: number}>} | ||||
|  */ | ||||
| export const getSensorData = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/sensor-data', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/sensor-data', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -822,7 +840,8 @@ export const getSensorData = async (params) => { | ||||
|  * @returns {Promise<{list: Array<TaskExecutionLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getTaskExecutionLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/task-execution-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/task-execution-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -832,7 +851,8 @@ export const getTaskExecutionLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<UserActionLogDTO>, total: number}>} | ||||
|  */ | ||||
| export const getUserActionLogs = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/user-action-logs', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/user-action-logs', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -842,7 +862,8 @@ export const getUserActionLogs = async (params) => { | ||||
|  * @returns {Promise<{list: Array<WeighingBatchDTO>, total: number}>} | ||||
|  */ | ||||
| export const getWeighingBatches = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/weighing-batches', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/weighing-batches', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| @@ -852,6 +873,28 @@ export const getWeighingBatches = async (params) => { | ||||
|  * @returns {Promise<{list: Array<WeighingRecordDTO>, total: number}>} | ||||
|  */ | ||||
| export const getWeighingRecords = async (params) => { | ||||
|   const responseData = await http.get('/api/v1/monitor/weighing-records', { params }); | ||||
|   const newParams = { ...params, page_size: params.page_size }; | ||||
|   const responseData = await http.get('/api/v1/monitor/weighing-records', { params: newParams }); | ||||
|   return processResponse(responseData); | ||||
| }; | ||||
|  | ||||
| export const MonitorApi = { | ||||
|   getDeviceCommandLogs, | ||||
|   getFeedUsageRecords, | ||||
|   getMedicationLogs, | ||||
|   getNotifications, | ||||
|   getPendingCollections, | ||||
|   getPigBatchLogs, | ||||
|   getPigPurchases, | ||||
|   getPigSales, | ||||
|   getPigSickLogs, | ||||
|   getPigTransferLogs, | ||||
|   getPlanExecutionLogs, | ||||
|   getRawMaterialPurchases, | ||||
|   getRawMaterialStockLogs, | ||||
|   getSensorData, | ||||
|   getTaskExecutionLogs, | ||||
|   getUserActionLogs, | ||||
|   getWeighingBatches, | ||||
|   getWeighingRecords, | ||||
| }; | ||||
|   | ||||
| @@ -1,5 +1,12 @@ | ||||
| import http from '../utils/http'; | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} Response | ||||
|  * @property {number} code - 业务状态码 | ||||
|  * @property {object} [data] - 业务数据 | ||||
|  * @property {string} [message] - 提示信息 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} PenResponse | ||||
|  * @property {number} id | ||||
| @@ -70,7 +77,7 @@ export const updatePen = (id, penData) => { | ||||
| /** | ||||
|  * 根据ID删除一个猪栏 | ||||
|  * @param {number} id - 猪栏ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| export const deletePen = (id) => { | ||||
|   return http.delete(`/api/v1/pens/${id}`); | ||||
| @@ -85,3 +92,12 @@ export const deletePen = (id) => { | ||||
| export const updatePenStatus = (id, statusData) => { | ||||
|   return http.put(`/api/v1/pens/${id}/status`, statusData); | ||||
| }; | ||||
|  | ||||
| export const PenApi = { | ||||
|   getPens, | ||||
|   createPen, | ||||
|   getPenById, | ||||
|   updatePen, | ||||
|   deletePen, | ||||
|   updatePenStatus, | ||||
| }; | ||||
|   | ||||
| @@ -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, | ||||
| }; | ||||
|   | ||||
| @@ -1,5 +1,12 @@ | ||||
| import http from '../utils/http'; | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} Response | ||||
|  * @property {number} code - 业务状态码 | ||||
|  * @property {object} [data] - 业务数据 | ||||
|  * @property {string} [message] - 提示信息 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} PigHouseResponse | ||||
|  * @property {number} id | ||||
| @@ -58,8 +65,16 @@ export const updatePigHouse = (id, pigHouseData) => { | ||||
| /** | ||||
|  * 根据ID删除一个猪舍 | ||||
|  * @param {number} id - 猪舍ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| export const deletePigHouse = (id) => { | ||||
|   return http.delete(`/api/v1/pig-houses/${id}`); | ||||
| }; | ||||
|  | ||||
| export const PigHouseApi = { | ||||
|   getPigHouses, | ||||
|   createPigHouse, | ||||
|   getPigHouseById, | ||||
|   updatePigHouse, | ||||
|   deletePigHouse, | ||||
| }; | ||||
|   | ||||
| @@ -106,17 +106,28 @@ import http from '../utils/http'; | ||||
|  * @property {string} updated_at | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} Response | ||||
|  * @property {number} code - 业务状态码 | ||||
|  * @property {object} [data] - 业务数据 | ||||
|  * @property {string} [message] - 提示信息 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * 获取所有计划的列表 | ||||
|  * @param {object} params - 查询参数 | ||||
|  * @param {number} [params.page] - 页码 | ||||
|  * @param {number} [params.pageSize] - 每页大小 | ||||
|  * @param {('所有任务'|'自定义任务'|'系统任务')} [params.planType] - 计划类型 | ||||
|  * @param {number} [params.page_size] - 每页大小 | ||||
|  * @param {('所有任务'|'自定义任务'|'系统任务')} [params.plan_type] - 计划类型 | ||||
|  * @returns {Promise<ListPlansResponse>} | ||||
|  */ | ||||
| const getPlans = (params) => { | ||||
|   return http.get('/api/v1/plans', { params }); | ||||
|   const newParams = { | ||||
|     page: params.page, | ||||
|     page_size: params.page_size, | ||||
|     plan_type: params.plan_type, | ||||
|   }; | ||||
|   return http.get('/api/v1/plans', { params: newParams }); | ||||
| }; | ||||
|  | ||||
| /** | ||||
| @@ -150,7 +161,7 @@ const updatePlan = (id, planData) => { | ||||
| /** | ||||
|  * 根据计划ID删除计划。(软删除)系统计划不允许删除。 | ||||
|  * @param {number} id - 计划ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| const deletePlan = (id) => { | ||||
|   return http.delete(`/api/v1/plans/${id}`); | ||||
| @@ -159,7 +170,7 @@ const deletePlan = (id) => { | ||||
| /** | ||||
|  * 根据计划ID启动一个计划的执行。系统计划不允许手动启动。 | ||||
|  * @param {number} id - 计划ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| const startPlan = (id) => { | ||||
|   return http.post(`/api/v1/plans/${id}/start`); | ||||
| @@ -168,7 +179,7 @@ const startPlan = (id) => { | ||||
| /** | ||||
|  * 根据计划ID停止一个正在执行的计划。系统计划不能被停止。 | ||||
|  * @param {number} id - 计划ID | ||||
|  * @returns {Promise<*>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| const stopPlan = (id) => { | ||||
|   return http.post(`/api/v1/plans/${id}/stop`); | ||||
|   | ||||
| @@ -48,7 +48,7 @@ import http from '../utils/http'; | ||||
| /** | ||||
|  * @typedef {object} PaginationDTO | ||||
|  * @property {number} page | ||||
|  * @property {number} pageSize | ||||
|  * @property {number} page_size | ||||
|  * @property {number} total | ||||
|  */ | ||||
|  | ||||
| @@ -64,7 +64,7 @@ import http from '../utils/http'; | ||||
|  * @property {string} [end_time] | ||||
|  * @property {string} [order_by] | ||||
|  * @property {number} [page] | ||||
|  * @property {number} [pageSize] | ||||
|  * @property {number} [page_size] | ||||
|  * @property {string} [start_time] | ||||
|  * @property {string} [status] | ||||
|  * @property {number} [user_id] | ||||
| @@ -80,6 +80,13 @@ import http from '../utils/http'; | ||||
|  * @property {NotifierType} type - Type 指定要测试的通知渠道 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * @typedef {object} Response | ||||
|  * @property {number} code - 业务状态码 | ||||
|  * @property {object} [data] - 业务数据 | ||||
|  * @property {string} [message] - 提示信息 | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * 创建一个新用户 | ||||
|  * @param {CreateUserRequest} userData - 用户信息 | ||||
| @@ -99,20 +106,30 @@ const login = (credentials) => { | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * 获取指定用户的操作历史 | ||||
|  * @param {number} id - 用户ID | ||||
|  * 获取用户操作日志列表 | ||||
|  * @param {UserHistoryParams} params - 查询参数 | ||||
|  * @returns {Promise<ListUserActionLogResponse>} | ||||
|  */ | ||||
| const getUserHistory = (id, params) => { | ||||
|   return http.get(`/api/v1/users/${id}/history`, { params }); | ||||
| const getUserActionLogs = (params) => { | ||||
|   const newParams = { | ||||
|     action_type: params.action_type, | ||||
|     end_time: params.end_time, | ||||
|     order_by: params.order_by, | ||||
|     page: params.page, | ||||
|     page_size: params.page_size, | ||||
|     start_time: params.start_time, | ||||
|     status: params.status, | ||||
|     user_id: params.user_id, | ||||
|     username: params.username, | ||||
|   }; | ||||
|   return http.get('/api/v1/monitor/user-action-logs', { params: newParams }); | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * 发送测试通知 | ||||
|  * @param {number} id - 用户ID | ||||
|  * @param {SendTestNotificationRequest} data - 请求体 | ||||
|  * @returns {Promise<string>} | ||||
|  * @returns {Promise<Response>} | ||||
|  */ | ||||
| const sendTestNotification = (id, data) => { | ||||
|   return http.post(`/api/v1/users/${id}/notifications/test`, data); | ||||
| @@ -121,6 +138,6 @@ const sendTestNotification = (id, data) => { | ||||
| export const UserApi = { | ||||
|   createUser, | ||||
|   login, | ||||
|   getUserHistory, | ||||
|   getUserActionLogs, | ||||
|   sendTestNotification, | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user