import axios from '../bc-libs/api.request'

/**
 * 通过id查询方法
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getBasicUkeyById = id => {
  return axios.request({
    url: 'bcDigitalAuth/api/v1/basicUkey/'+id,
    method: 'get'
  })
}

/**
 * 分页查询方法
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getBasicUkeyPage = parmas => {
  return axios.request({
    url: 'bcDigitalAuth/api/v1/basicUkey/page',
    params:parmas,
    method: 'get'
  })
}

/**
 * 根据参数查询列表
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getBasicUkeyList = parmas => {
  return axios.request({
    url: 'bcDigitalAuth/api/v1/basicUkey/list',
    params:parmas,
    method: 'get'
  })
}

/**
 * 新增
 * @param params
 * @returns {Promise<any>}
 */
export const addBasicUkey = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: 'bcDigitalAuth/api/v1/basicUkey/add',
      method: 'POST',
      data: params,
    }).then(response => {
      resolve(response.data);
    }).catch(err => {
      reject(err)
    })
  })
}

/**
 * 修改
 * @param params
 * @returns {Promise<any>}
 */
export const editBasicUkey = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: 'bcDigitalAuth/api/v1/basicUkey/merge',
      method: 'POST',
      data: params,
    }).then(response => {
      resolve(response.data);
    }).catch(err => {
      reject(err)
    })
  })
}

/**
 * 删除
 * @param id
 * @returns {Promise<any>}
 */
export const deleteBasicUkey = (id) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: 'bcDigitalAuth/api/v1/basicUkey/delete/'+id,
      method: 'POST',
    }).then(response => {
      resolve(response.data);
    }).catch(err => {
      reject(err)
    })
  })
}

/**
 * 检测UKey
 * @param params
 * @returns {Promise<any>}
 */
export const checkBasicUkey = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: 'bcDigitalAuth/api/v1/basicUkey/checkUkey',
      method: 'POST',
      data: params,
    }).then(response => {
      resolve(response.data);
    }).catch(err => {
      reject(err)
    })
  })
}
