import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ComPostVO, ComPostForm, ComPostQuery } from '@/api/company/comPost/types';

/**
 * 查询岗位信息列表
 * @param query
 * @returns {*}
 */

export const listComPost = (query?: ComPostQuery): AxiosPromise<ComPostVO[]> => {
  return request({
    url: '/system/comPost/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询岗位信息详细
 * @param postId
 */
export const getComPost = (postId: string | number): AxiosPromise<ComPostVO> => {
  return request({
    url: '/system/comPost/' + postId,
    method: 'get'
  });
};

/**
 * 新增岗位信息
 * @param data
 */
export const addComPost = (data: ComPostForm) => {
  return request({
    url: '/system/comPost',
    method: 'post',
    data: data
  });
};

/**
 * 修改岗位信息
 * @param data
 */
export const updateComPost = (data: ComPostForm) => {
  return request({
    url: '/system/comPost',
    method: 'put',
    data: data
  });
};

/**
 * 删除岗位信息
 * @param postId
 */
export const delComPost = (postId: string | number | Array<string | number>) => {
  return request({
    url: '/system/comPost/' + postId,
    method: 'delete'
  });
};

export function changeStatus(id: string | number, status: string) {
  const data = {
    id,
    status
  };
  return request({
    url: '/system/comPost/changeStatus',
    method: 'put',
    data: data
  });
}
