import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CreditLevelVO, CreditLevelForm, CreditLevelQuery } from '@/api/customer/creditLevel/types';

/**
 * 查询信用等级配置列表
 * @param query
 * @returns {*}
 */

export const listCreditLevel = (query?: CreditLevelQuery): AxiosPromise<CreditLevelVO[]> => {
  return request({
    url: '/system/creditLevel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询信用等级配置详细
 * @param id
 */
export const getCreditLevel = (id: string | number): AxiosPromise<CreditLevelVO> => {
  return request({
    url: '/system/creditLevel/' + id,
    method: 'get'
  });
};

/**
 * 新增信用等级配置
 * @param data
 */
export const addCreditLevel = (data: CreditLevelForm) => {
  return request({
    url: '/system/creditLevel',
    method: 'post',
    data: data
  });
};

/**
 * 修改信用等级配置
 * @param data
 */
export const updateCreditLevel = (data: CreditLevelForm) => {
  return request({
    url: '/system/creditLevel',
    method: 'put',
    data: data
  });
};

/**
 * 删除信用等级配置
 * @param id
 */
export const delCreditLevel = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/creditLevel/' + id,
    method: 'delete'
  });
};

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