import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RankGroupVO, RankGroupForm, RankGroupQuery } from '@/api/system/rankGroup/types';

/**
 * 查询排名分组列表
 * @param query
 * @returns {*}
 */

export const listRankGroup = (query?: RankGroupQuery): AxiosPromise<RankGroupVO[]> => {
  return request({
    url: '/system/rankGroup/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询排名分组树列表
 */
export const treeListRankGroup = (query?: RankGroupQuery): AxiosPromise<RankGroupVO[]> => {
  return request({
    url: '/system/rankGroup/treeList',
    method: 'get',
    params: query
  });
};

/**
 * 查询排名分组详细
 * @param rgId
 */
export const getRankGroup = (rgId: string | number): AxiosPromise<RankGroupVO> => {
  return request({
    url: '/system/rankGroup/' + rgId,
    method: 'get'
  });
};

/**
 * 新增排名分组
 * @param data
 */
export const addRankGroup = (data: RankGroupForm) => {
  return request({
    url: '/system/rankGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改排名分组
 * @param data
 */
export const updateRankGroup = (data: RankGroupForm) => {
  return request({
    url: '/system/rankGroup',
    method: 'put',
    data: data
  });
};

/**
 * 删除排名分组
 * @param rgId
 */
export const delRankGroup = (rgId: string | number | Array<string | number>) => {
  return request({
    url: '/system/rankGroup/' + rgId,
    method: 'delete'
  });
};
