import { handlePost } from '../tools'

export default ({ service, request, serviceForMock, requestForMock, mock, faker, tools }) => ({
  /**
   * @description 方法名称
   * @param {Object} data 请求携带的信息
   */
  VERIFY_SERVER (url, username, password) {
    return request({
      auth: {
        username: username,
        password: password
      },
      method: 'post',
      url: url + '/Admin/ServerSettingsRequest'
    })
  },

  MODIFY_SERVER (url, username, password, data) {
    return request({
      auth: {
        username: username,
        password: password
      },
      data: data,
      method: 'post',
      url: url + '/Admin/ServerSettingsModify'
    })
  },

  ADD_SERVER: (data) => handlePost(request, data),
  UPDATE_SERVER: (data) => handlePost(request, data),
  REMOVE_SERVER: (data) => handlePost(request, data),

  QUERY_SERVERS () {
    return request({ url: '?query=servers' })
  },

  QUERY_SERVE_MONITORING () {
    return request({ url: '?query=working_subclasses' })
  },
  GET_DEVICE (serveId) {
    return request({ url: '?query=device_list&id=' + serveId })
  },
  GET_DEVICE_STATUS (serveId) {
    return request({ url: '?query=device_status&id=' + serveId })
  },
  ADD_DEVICE: (data) => handlePost(request, data),
  DEL_DEVICE: (data) => handlePost(request, data),
  GET_HSLSERVER_CONFIGURE (url, username, password) {
    return request({
      auth: {
        username: username,
        password: password
      },
      method: 'post',
      url: url + '/Admin/JsonSettingsRequest'
    })
  },
  SET_HSLSERVER_CONFIGURE (url, username, password, data) {
    return request({
      auth: {
        username: username,
        password: password
      },
      data: data,
      method: 'post',
      url: url + '/Admin/JsonSettingsModify'
    })
  },
  SET_DEVICE_CONFIGURE: (data) => handlePost(request, data),
  GET_DEVICE_CONFIGURE (id) {
    return request({ url: '?query=device&id=' + id })
  },
  GET_SERVE_DEVICE_MONITORING (url, username, password) {
    return request({
      auth: {
        username: username,
        password: password
      },
      url: url + '/Edge/DeviceData?data=/'
    })
  },
  GET_ALL_DEVICES () {
    return request({ url: '?query=all_devices' })
  },
  SET_SERVER_EXEC: (data) => handlePost(request, data),
  GET_SERVER_DEVICE_STATUS (url, username, password) {
    return request({
      auth: {
        username: username,
        password: password
      },
      url: url + '/Edge/DeviceData?data=__status'
    })
  }
})
