import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MainPostApplyForm, MainPostApplyQuery, MainPostApplyVO } from './types';

export function listPostManage(query: MainPostApplyQuery): AxiosPromise<MainPostApplyVO[]> {
  return request({
    url: '/main/postApply/list',
    method: 'get',
    params: query
  });
}

export function getPostManage(id: string | number): AxiosPromise<MainPostApplyVO> {
  return request({
    url: '/main/postApply/' + id,
    method: 'get'
  });
}

export function addPostManage(data: MainPostApplyForm) {
  return request({
    url: '/main/postApply/add',
    method: 'post',
    data
  });
}

export function updatePostManage(data: MainPostApplyForm) {
  return request({
    url: '/main/postApply/edit',
    method: 'put',
    data
  });
}

export function publishPostManage(id: string | number) {
  return request({
    url: '/main/postApply/publish/' + id,
    method: 'post'
  });
}

export function unpublishPostManage(id: string | number) {
  return request({
    url: '/main/postApply/unpublish/' + id,
    method: 'post'
  });
}

export function delPostManage(id: string | number | Array<string | number>) {
  return request({
    url: '/main/postApply/' + id,
    method: 'delete'
  });
}
