import request from '@/utils/axiosReq'
import { CommonQueryResult } from '~/common'

export function Query<T = any>(params): Promise<CommonQueryResult<T>> {
  return request({
    url: '/openApi/query',
    method: 'post',
    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 {
      return Promise.reject(result.message)
    }
  } catch (error) {
    return Promise.reject(error)
  }
}

export function GeneralDataReception(params): Promise<CommonQueryResult> {
  return request({
    url: '/openApi/generalDataReception',
    method: 'post',
    data: params,
  })
}
