import request from '@/utils/request'

// ========== 端口池 ==========
export function listPort(query) {
  return request({ url: '/admin/smsPort/port/list', method: 'get', params: query })
}

export function listPortByApi(apiId) {
  return request({ url: '/admin/smsPort/port/listByApi/' + apiId, method: 'get' })
}

export function addPort(data) {
  return request({ url: '/admin/smsPort/port', method: 'post', data })
}

export function updatePort(data) {
  return request({ url: '/admin/smsPort/port', method: 'put', data })
}

export function delPort(portId) {
  return request({ url: '/admin/smsPort/port/' + portId, method: 'delete' })
}

// ========== 端口分配 ==========
export function listAssign(query) {
  return request({ url: '/admin/smsPort/assign/list', method: 'get', params: query })
}

export function addAssign(data) {
  return request({ url: '/admin/smsPort/assign', method: 'post', data })
}

export function updateAssign(data) {
  return request({ url: '/admin/smsPort/assign', method: 'put', data })
}

export function delAssign(id) {
  return request({ url: '/admin/smsPort/assign/' + id, method: 'delete' })
}

// ========== 设备管理 ==========
export function listDevice(query) {
  return request({ url: '/admin/smsPort/device/list', method: 'get', params: query })
}

export function getDevice(deviceId) {
  return request({ url: '/admin/smsPort/device/' + deviceId, method: 'get' })
}

export function addDevice(data) {
  return request({ url: '/admin/smsPort/device', method: 'post', data })
}

export function updateDevice(data) {
  return request({ url: '/admin/smsPort/device', method: 'put', data })
}

export function delDevice(deviceId) {
  return request({ url: '/admin/smsPort/device/' + deviceId, method: 'delete' })
}

export function assignDevice(deviceId, companyUserId) {
  return request({ url: '/admin/smsPort/device/assign', method: 'put', params: { deviceId, companyUserId } })
}

// ========== 手机卡管理 ==========
export function listCard(query) {
  return request({ url: '/admin/smsPort/card/list', method: 'get', params: query })
}

export function getCard(cardId) {
  return request({ url: '/admin/smsPort/card/' + cardId, method: 'get' })
}

export function addCard(data) {
  return request({ url: '/admin/smsPort/card', method: 'post', data })
}

export function updateCard(data) {
  return request({ url: '/admin/smsPort/card', method: 'put', data })
}

export function delCard(cardId) {
  return request({ url: '/admin/smsPort/card/' + cardId, method: 'delete' })
}

// ========== 中间件 ==========
export function listMiddleware(query) {
  return request({ url: '/admin/smsPort/middleware/list', method: 'get', params: query })
}

export function getMiddlewareByApi(apiId) {
  return request({ url: '/admin/smsPort/middleware/byApi/' + apiId, method: 'get' })
}

export function addMiddleware(data) {
  return request({ url: '/admin/smsPort/middleware', method: 'post', data })
}

export function updateMiddleware(data) {
  return request({ url: '/admin/smsPort/middleware', method: 'put', data })
}

export function delMiddleware(id) {
  return request({ url: '/admin/smsPort/middleware/' + id, method: 'delete' })
}
