/**
 * KRA - Authority Button API Service
 */
import request from '@/utils/request';
import type { ApiResponse } from '@/types/api';

/** 获取角色按钮权限 */
export const getAuthorityBtn = (data: { authorityId: number | string; menuID: number }) => {
  return request.post<ApiResponse<any>>('/authorityBtn/getAuthorityBtn', {
    ...data,
    authorityId: Number(data.authorityId),
  });
};

/** 设置角色按钮权限 */
export const setAuthorityBtn = (data: { authorityId: number | string; menuID: number; selected: string[] }) => {
  return request.post<ApiResponse<any>>('/authorityBtn/setAuthorityBtn', {
    ...data,
    authorityId: Number(data.authorityId),
  });
};

/** 检查是否可以移除按钮权限 */
export const canRemoveAuthorityBtn = (params: { ID: number }) => {
  return request.post<ApiResponse<any>>('/authorityBtn/canRemoveAuthorityBtn', undefined, { params });
};

export default {
  getAuthorityBtn,
  setAuthorityBtn,
  canRemoveAuthorityBtn,
};
