import request from '@/utils/request';
import { BackClauseVO, BackClauseQuery, BackClauseForm } from './types';
import { AxiosPromise } from 'axios';

/**
 * 查询背调条款列表
 */
export const listBackClause = (query: BackClauseQuery): AxiosPromise<BackClauseVO[]> => {
  return request({
    url: '/system/backClause/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询背调条款详细
 */
export const getBackClause = (id: string | number): AxiosPromise<BackClauseVO> => {
  return request({
    url: '/system/backClause/' + id,
    method: 'get'
  });
};

/**
 * 新增背调条款
 */
export const addBackClause = (data: BackClauseForm) => {
  return request({
    url: '/system/backClause',
    method: 'post',
    data: data
  });
};

/**
 * 修改背调条款
 */
export const updateBackClause = (data: BackClauseForm) => {
  return request({
    url: '/system/backClause',
    method: 'put',
    data: data
  });
};

/**
 * 删除背调条款
 */
export const delBackClause = (ids: string | number | Array<string | number>) => {
  return request({
    url: '/system/backClause/' + ids,
    method: 'delete'
  });
};

/**
 * 背调条款状态修改
 */
export const changeBackClauseStatus = (id: string | number, status: string) => {
  const data = {
    id,
    status
  };
  return request({
    url: '/system/backClause/changeStatus',
    method: 'put',
    data: data
  });
};
