import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TypeVO, TypeForm, TypeQuery } from '@/api/system/business/type/types';

/**
 * 查询权益类型树列表
 * @param query
 * @returns {*}
 */

export const listType = (query?: TypeQuery): AxiosPromise<TypeVO[]> => {
  return request({
    url: '/business/type/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询权益类型树详细
 * @param id
 */
export const getType = (id: string | number): AxiosPromise<TypeVO> => {
  return request({
    url: '/business/type/' + id,
    method: 'get'
  });
};

/**
 * 新增权益类型树
 * @param data
 */
export const addType = (data: TypeForm) => {
  return request({
    url: '/business/type',
    method: 'post',
    data: data
  });
};

/**
 * 修改权益类型树
 * @param data
 */
export const updateType = (data: TypeForm) => {
  return request({
    url: '/business/type',
    method: 'put',
    data: data
  });
};

/**
 * 删除权益类型树
 * @param id
 */
export const delType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/type/' + id,
    method: 'delete'
  });
};
/**
 * 查询父级
 * @param id
 */
export const selectGiftTypeParentList = (): AxiosPromise<TypeVO> => {
  return request({
    url: '/business/type/selectGiftTypeParentList',
    method: 'get'
  });
};
/**
 * 查询父级下面的子类
 * @param id
 */
export const selectGiftTypeChildList = (id: string | number): AxiosPromise<TypeVO> => {
  return request({
    url: '/business/type/selectGiftTypeChildList/' + id,
    method: 'get'
  });
};
