import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GroupVO, GroupForm, GroupQuery } from '@/api/system/group/types';

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

export const listGroup = (query?: GroupQuery): AxiosPromise<GroupVO[]> => {
  return request({
    url: '/system/group/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分组详细
 * @param id
 */
export const getGroup = (id: string | number): AxiosPromise<GroupVO> => {
  return request({
    url: '/system/group/' + id,
    method: 'get'
  });
};

/**
 * 新增分组
 * @param data
 */
export const addGroup = (data: GroupForm) => {
  return request({
    url: '/system/group',
    method: 'post',
    data: data
  });
};

/**
 * 修改分组
 * @param data
 */
export const updateGroup = (data: GroupForm) => {
  return request({
    url: '/system/group',
    method: 'put',
    data: data
  });
};

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