import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { HandoverVO, HandoverForm, HandoverQuery } from '@/api/residenceService/handover/types';

/**
 * 查询交接班列表
 * @param query
 * @returns {*}
 */

export const listHandover = (query?: HandoverQuery): AxiosPromise<HandoverVO[]> => {
  return request({
    url: '/residential/handover/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询交接班详细
 * @param id
 */
export const getHandover = (id: string | number): AxiosPromise<HandoverVO> => {
  return request({
    url: '/residential/handover/' + id,
    method: 'get'
  });
};

/**
 * 新增交接班
 * @param data
 */
export const addHandover = (data: HandoverForm) => {
  return request({
    url: '/residential/handover',
    method: 'post',
    data
  });
};

/**
 * 修改交接班
 * @param data
 */
export const updateHandover = (data: HandoverForm) => {
  return request({
    url: '/residential/handover',
    method: 'put',
    data: data
  });
};

/**
 * 删除交接班
 * @param id
 */
export const delHandover = (id: string | number | Array<string | number>) => {
  return request({
    url: '/residential/handover/' + id,
    method: 'delete'
  });
};
