import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GroupFunctionMenuVO, GroupFunctionMenuForm, GroupFunctionMenuQuery } from '@/api/system/groupFunctionMenu/types';

/**
 * 查询组和功能菜单关联列表
 * @param query
 * @returns {*}
 */

export const listGroupFunctionMenu = (query?: GroupFunctionMenuQuery): AxiosPromise<GroupFunctionMenuVO[]> => {
  return request({
    url: '/system/groupFunctionMenu/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询组和功能菜单关联详细
 * @param groupId
 */
export const getGroupFunctionMenu = (groupId: string | number): AxiosPromise<GroupFunctionMenuVO> => {
  return request({
    url: '/system/groupFunctionMenu/' + groupId,
    method: 'get'
  });
};

/**
 * 新增组和功能菜单关联
 * @param data
 */
export const addGroupFunctionMenu = (data: GroupFunctionMenuForm) => {
  return request({
    url: '/system/groupFunctionMenu',
    method: 'post',
    data: data
  });
};

/**
 * 修改组和功能菜单关联
 * @param data
 */
export const updateGroupFunctionMenu = (data: GroupFunctionMenuForm) => {
  return request({
    url: '/system/groupFunctionMenu',
    method: 'put',
    data: data
  });
};

/**
 * 删除组和功能菜单关联
 * @param groupId
 */
export const delGroupFunctionMenu = (groupId: string | number | Array<string | number>) => {
  return request({
    url: '/system/groupFunctionMenu/' + groupId,
    method: 'delete'
  });
};
