/*
 * @Author: Badguy
 * @Date: 2022-04-13 14:35:17
 * @LastEditTime: 2022-05-13 09:26:03
 * @LastEditors: your name
 * @Description: 数据整合接口
 * have a nice day!
 */

import request from '@/utils/axiosReq'
import { ElMessage } from 'element-plus'

export function GeneralDataReception(params) {
  return request({
    url: '/openApi/generalDataReception',
    method: 'post',
    headers: {
      'content-type': 'application/json',
    },
    data: params,
  })
}

export function Query(params) {
  return request({
    url: '/openApi/query',
    method: 'post',
    headers: {
      'content-type': 'application/json',
    },
    data: params,
  })
}

//服务管理-启动
export function Start(params) {
  return request({
    url: '/openApi/start',
    method: 'post',
    headers: {
      'content-type': 'application/json',
    },
    data: params,
  })
}

//服务管理-停止
export function Stop(params) {
  return request({
    url: '/openApi/stop',
    method: 'post',
    headers: {
      'content-type': 'application/json',
    },
    data: params,
  })
}

export async function myQuery(id, ...dataContent) {
  const params = {
    id,
    dataContent,
  }
  try {
    const result = await Query(params)
    if (Number(result.code) === 0) {
      return result.returnData.listValues
    } else {
      ElMessage.error(result.message ?? '失败')
      return Promise.reject(result.message)
    }
  } catch (error) {
    return Promise.reject(error)
  }
}