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

const api = {
  getPage: 'community/user/list',
  getDetail: 'community/user/',
  deleteOne: 'community/user/',
  deleteBatch: 'community/user/batch/delete',
  save: 'community/user/',
  changeAllowPush: '/community/user/allow/push/',
  changeAllowSpeak: '/community/user/allow/speak/',
}

export default api

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(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 changeAllowPush(id, allowPush) {
  return axios({
    url: api.changeAllowPush + id + '/'+ allowPush,
    method: 'get',
    useFullLoading: true
  })
}
/**
 * 允许发言修改
 * @param id
 */
export function changeAllowSpeak(id, allowSpeak) {
  return axios({
    url: api.changeAllowSpeak + id + '/'+ allowSpeak,
    method: 'get',
    useFullLoading: true
  })
}