import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CrmGiftIssueRecordForm, CrmGiftIssueRecordQuery, CrmGiftIssueRecordVO } from '@/api/oa/crm/crmGiftIssueRecord/types';

/**
 * 查询礼品发放记录列表
 * @param query
 * @returns {*}
 */

export const listCrmGiftIssueRecord = (query?: CrmGiftIssueRecordQuery): AxiosPromise<CrmGiftIssueRecordVO[]> => {
  return request({
    url: '/oa/crm/crmGiftIssueRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询礼品发放记录详细
 * @param issueRecordId
 */
export const getCrmGiftIssueRecord = (issueRecordId: string | number): AxiosPromise<CrmGiftIssueRecordVO> => {
  return request({
    url: '/oa/crm/crmGiftIssueRecord/' + issueRecordId,
    method: 'get'
  });
};

/**
 * 新增礼品发放记录
 * @param data
 */
export const addCrmGiftIssueRecord = (data: CrmGiftIssueRecordForm) => {
  return request({
    url: '/oa/crm/crmGiftIssueRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改礼品发放记录
 * @param data
 */
export const updateCrmGiftIssueRecord = (data: CrmGiftIssueRecordForm) => {
  return request({
    url: '/oa/crm/crmGiftIssueRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除礼品发放记录
 * @param issueRecordId
 */
export const delCrmGiftIssueRecord = (issueRecordId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/crm/crmGiftIssueRecord/' + issueRecordId,
    method: 'delete'
  });
};

/**
 * 下拉框查询礼品发放记录列表
 * @param query
 * @returns {*}
 */
export function getCrmGiftIssueRecordList(query) {
  return request({
    url: '/oa/crm/crmGiftIssueRecord/getCrmGiftIssueRecordList',
    method: 'get',
    params: query
  });
}
