Files
autoAiWorkSys/admin/src/api/profile/pla_account_server.js
张成 34ebad316a 1
2025-12-19 11:40:25 +08:00

204 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 平台账号 API 服务
*/
class PlaAccountServer {
/**
* 分页查询平台账号
* @param {Object} param - 查询参数
* @param {Object} param.seachOption - 搜索条件
* @param {Object} param.pageOption - 分页选项
* @returns {Promise}
*/
page(param) {
return window.framework.http.post('/account/list', param)
}
/**
* 获取账号详情
* @param {Number|String} id - 账号ID
* @returns {Promise}
*/
getById(id) {
return window.framework.http.post('/account/detail', { id })
}
/**
* 通过设备SN码获取账号信息
* @param {String} sn_code - 设备SN码
* @returns {Promise}
*/
getBySnCode(sn_code) {
return window.framework.http.post('/account/getBySnCode', { sn_code })
}
/**
* 新增账号
* @param {Object} row - 账号数据
* @returns {Promise}
*/
add(row) {
return window.framework.http.post('/account/add', row)
}
/**
* 更新账号信息
* @param {Object} row - 账号数据
* @returns {Promise}
*/
update(row) {
return window.framework.http.post('/account/update', row)
}
/**
* 删除账号
* @param {Object} row - 账号数据包含id
* @returns {Promise}
*/
del(row) {
return window.framework.http.post('/account/delete', { id: row.id })
}
/**
* 导出CSV
* @param {Object} param - 查询参数
* @returns {Promise}
*/
exportCsv(param) {
return window.framework.http.post('/account/export', param, { responseType: 'blob' })
}
/**
* 获取账号任务列表
* @param {Number|String} accountId - 账号ID
* @param {Object} param - 查询参数
* @param {Object} param.seachOption - 搜索条件
* @param {Object} param.pageOption - 分页选项
* @returns {Promise}
*/
getTasks(accountId, param) {
const { pageOption } = param || {}
const queryParams = {
id: accountId,
page: pageOption?.page || 1,
pageSize: pageOption?.pageSize || 10
}
return window.framework.http.get(`pla_account/tasks`, queryParams)
}
/**
* 获取账号指令列表
* @param {Number|String} accountId - 账号ID
* @param {Object} param - 查询参数
* @param {Object} param.seachOption - 搜索条件
* @param {Object} param.pageOption - 分页选项
* @returns {Promise}
*/
getCommands(accountId, param) {
const { pageOption } = param || {}
const queryParams = {
id: accountId,
page: pageOption?.page || 1,
pageSize: pageOption?.pageSize || 10
}
return window.framework.http.get(`pla_account/commands`, queryParams)
}
/**
* 执行指令
* @param {Object} param - 指令参数
* @param {Number|String} param.id - 账号ID
* @param {String} param.commandType - 指令类型
* @param {String} param.commandName - 指令名称
* @returns {Promise}
*/
runCommand(param) {
return window.framework.http.post(`pla_account/runCommand`, param)
}
/**
* 获取指令详情
* @param {Number|String} accountId - 账号ID
* @param {Number|String} commandId - 指令ID
* @returns {Promise}
*/
getCommandDetail(accountId, commandId) {
return window.framework.http.get(`pla_account/commandDetail`, {
accountId,
commandId
})
}
/**
* 重试指令
* @param {Number|String} commandId - 指令ID
* @returns {Promise}
*/
retryCommand(commandId) {
return window.framework.http.post(`pla_account/retryCommand`, {
commandId
})
}
/**
* 停止账号的所有任务
* @param {Object} row - 账号数据包含id和sn_code
* @returns {Promise}
*/
stopTasks(row) {
return window.framework.http.post('/account/stopTasks', {
id: row.id,
sn_code: row.sn_code
})
}
/**
* 解析地址并更新经纬度
* @param {Object} param - 参数对象
* @param {Number|String} param.id - 账号ID
* @param {String} param.address - 地址(可选)
* @returns {Promise}
*/
parseLocation(param) {
return window.framework.http.post('/pla_account/parseLocation', param)
}
/**
* 批量解析地址并更新经纬度
* @param {Array<Number|String>} ids - 账号ID数组
* @returns {Promise}
*/
batchParseLocation(ids) {
return window.framework.http.post('/pla_account/batchParseLocation', { ids })
}
/**
* 检查账号授权状态
* @param {Object} param - 参数对象
* @param {Number|String} param.id - 账号ID可选
* @param {String} param.sn_code - 设备SN码可选
* @returns {Promise}
*/
checkAuthorization(param) {
return window.framework.http.post('/account/check-authorization', param)
}
/**
* 更新账号授权信息
* @param {Object} param - 参数对象
* @param {Number|String} param.id - 账号ID
* @param {String} param.authorization_date - 授权日期(可选,不提供则使用当前时间)
* @param {Number} param.authorization_days - 授权天数
* @returns {Promise}
*/
updateAuthorization(param) {
return window.framework.http.post('/account/update-authorization', param)
}
}
export default new PlaAccountServer()