import {axios} from '@/util/axios/request'

const api = {
  getPage: '/saas/company/getPage',
  getDetail: '/saas/company/',
  deleteOne: '/saas/company/',
  deleteBatch: '/saas/company/batchDelete',
  save: '/saas/company/',
  add: '/saas/company',
  getAllSaasAppModuleByType: '/saas/app/module/type/',
  getAllSaaSBusiness: '/saas/business/tree',

  getResource: '/saas/company/resource/',
  init: '/saas/company/init',
  modify: '/saas/company/modify',
  clear: '/saas/company/clear/'
}

export default api

export function getResource(id) {
  return axios({
    url: api.getResource + id,
    method: 'get',
    useFullLoading: true
  })
}

export function init(data) {
  return axios({
    url: api.init,
    method: 'post',
    data: data,
    useFullLoading: true
  })
}

export function modify(data) {
  return axios({
    url: api.modify,
    method: 'put',
    data: data,
    useFullLoading: true
  })
}

export function clear(id) {
  return axios({
    url: api.clear + id,
    method: 'delete',
    useFullLoading: true
  })
}

export function getAllSaaSBusiness() {
  return axios({
    url: api.getAllSaaSBusiness,
    method: 'get'
  })
}

export function getAllSaasAppModuleByType(type) {
  return axios({
    url: api.getAllSaasAppModuleByType + type,
    method: 'get'
  })
}

export function getPage(parameter) {
  return axios({
    url: api.getPage,
    method: 'post',
    data: parameter,
    useFullLoading: true
  })
}

export function getDetail(id) {
  return axios({
    url: api.getDetail + id,
    method: 'get',
    useFullLoading: true
  })
}

export function deleteOne(id) {
  return axios({
    url: api.deleteOne + id,
    method: 'delete',
  })
}

export function deleteBatch(ids) {
  return axios({
    url: api.deleteBatch,
    method: 'post',
    data: ids
  })
}

export function save(data) {
  return axios({
    url: api.save,
    method: 'put',
    data: data
  })
}

export function add(data) {
  return axios({
    url: api.add,
    method: 'post',
    data: data
  })
}