import { handlePost } from '../tools'

export default ({ service, request, serviceForMock, requestForMock, mock, faker, tools }) => ({
  /**
   * @description 方法名称
   * @param {Object} data 请求携带的信息
   */

  ADD_NODE: (data) => handlePost(request, data),
  UPDATE_NODE: (data) => handlePost(request, data),
  REMOVE_NODE: (data) => handlePost(request, data),

  QUERY_NODES () {
    return request({ url: '?query=nodes' })
  },

  QUERY_WORKING_SUBCLASSES () {
    return request({ url: '?query=working_subclasses' })
  },

  QUERY_CODES (workingSubclass) {
    return request({ url: '?query=codes&working_subclass=' + workingSubclass })
  },

  QUERY_NODE_DATA ({
    workingSubclass,
    startTime,
    endTime,
    code
  } = {}) {
    let url = '?query=node_data&working_subclass=' + workingSubclass + '&start_time=' + startTime + '&end_time=' + endTime
    if (code) {
      url += `&code=${code}`
    }
    return request({
      url: url,
      timeout: 60000
    })
  }
})
