import { axios } from '@/utils/request'
import { stringify } from 'qs'

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getModelPage (parameter) {
  return axios({
    url: '/act/model/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * add func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function addModel (parameter) {
  return axios({
    url: '/act/model',
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateModel (parameter) {
  return axios({
    url: '/act/model',
    method: 'PUT',
    data: parameter
  })
}

/**
 * fetch single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchModel (parameter) {
  return axios({
    url: '/act/model/' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * fetch single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deployModel (parameter) {
  return axios({
    url: '/act/deploy/' + parameter.id,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * sync
 * @returns {*}
 */
export function sync () {
  return axios({
    url: '/act/sync',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * query list func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function queryModel (parameter) {
  return axios({
    url: '/act/model?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteModels (parameter) {
  return axios({
    url: '/act/model',
    method: 'DELETE',
    data: parameter
  })
}

/**
 * delete single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteModel (parameter) {
  return axios({
    url: '/act/model/' + parameter.id,
    method: 'DELETE',
    data: parameter
  })
}
