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

const api = {
  getPage: '/saas/app/boot/advertisement/page',
  getDetail: '/saas/app/boot/advertisement/',
  deleteOne: '/saas/app/boot/advertisement/',
  deleteBatch: '/saas/app/boot/advertisement/batch/delete',
  save: '/saas/app/boot/advertisement/',
  changeShowStatus: '/saas/app/boot/advertisement/available/',
  getModuleAdvertisement: '/saas/app/boot/advertisement/module/',
  getModuleAdvertisementCommunity: '/saas/app/boot/advertisement/module/'
}

export default api

export function getPage(parameter) {
  return axios({
    url: api.getPage,
    method: 'post',
    data: parameter
  })
}
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(parameter) {
  return axios({
    url: api.deleteBatch,
    method: 'post',
    data: parameter
  })
}

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

/**
 * 修改启用状态
 * @param id
 */
export function changeShowStatus(status, id) {
  return axios({
    url: api.changeShowStatus + status + '/' + id,
    method: 'get',
    useFullLoading: true
  })
}

export function getModuleAdvertisement(code, param) {
  return axios({
    url: api.getModuleAdvertisement + code,
    method: 'post',
    data: param,
    useFullLoading: false
  })
}

export function getModuleAdvertisementCommunity(code, businessId) {
  return axios({
    url: api.getModuleAdvertisementCommunity + code + '/' + businessId + '/publish/community',
    method: 'get',
    useFullLoading: true
  })
}
