import { AxiosResponseData, IPageResponseData, pageSize } from "@/api/types/requests"
import { request } from "@/utils/service"
import { AuthRolesPermissions } from "@/api/rolePermissions/types/RolePermissions"
type ApiType = AuthRolesPermissions
const apiName = "authRolesPermission"
const upperName = "AuthRolesPermissions"
export function addRolePermissions(data: ApiType) {
  return request<AxiosResponseData<boolean>>({
    url: "/" + apiName + "/add" + upperName,
    method: "POST",
    data: data,
    withCredentials: true
  })
}
export function changePermissions(newData: ApiType) {
  return request<AxiosResponseData<string>>({
    url: "/" + apiName + "/change" + upperName,
    method: "POST",
    data: newData,
    withCredentials: true
  })
}
export function deletePermissions(roleId: number, permissionId: number) {
  return request<AxiosResponseData<boolean>>({
    url: "/" + apiName + "/del" + upperName,
    method: "GET",
    params: {
      roleId: roleId,
      permissionId: permissionId
    },
    withCredentials: true
  })
}
export function get(page: number) {
  return request<AxiosResponseData<IPageResponseData<ApiType>>>({
    url: "/" + apiName + "/get" + upperName,
    method: "GET",
    params: {
      page: page,
      num: pageSize
    },
    withCredentials: true
  })
}
export function status(id: number, status: boolean) {
  return request<AxiosResponseData<string>>({
    url: "/" + apiName + "/change" + upperName + "Stats",
    method: "GET",
    params: {
      authPermissionId: id,
      status: status
    },
    withCredentials: true
  })
}
