import request from "@/utils/request";

// 查询选择器列表
export function getSelectorList(data, token) {
  return request({
    url: `/shenyu/selector?pluginId=5&currentPage=${data.currentPage}&pageSize=${data.pageSize}&name=${data.name}`,
    headers: {
      "X-Access-Token": token,
    },
    method: "get",
  });
}

// 查询选择器列表
export function addSelector(data, token) {
  return request({
    url: `/shenyu/selector`,
    headers: {
      "X-Access-Token": token,
    },
    method: "post",
    data: data,
  });
}

// 查询选择器列表
export function updateSelector(data, token) {
  return request({
    url: `/shenyu/selector/${data.id}`,
    headers: {
      "X-Access-Token": token,
    },
    method: "PUT",
    data: data,
  });
}

// 查询选择器列表
export function getRuleList(data, token) {
  return request({
    url: `/shenyu/rule?pluginId=5&selectorId=${data.selectorId}&currentPage=${data.currentPage}&pageSize=${data.pageSize}&name=${data.name}`,
    headers: {
      "X-Access-Token": token,
    },
    method: "get",
  });
}

// 查询选择器列表
export function syncProxyData(token) {
  return request({
    url: `/shenyu/plugin/syncPluginData/5`,
    headers: {
      "X-Access-Token": token,
    },
    method: "put",
  });
}

// 删除选择器规则
export function deleteRule(data, token) {
  return request({
    url: "/shenyu/rule/batch",
    headers: {
      "X-Access-Token": token,
    },
    method: "DELETE",
    data: data,
  });
}

// 删除选择器
export function deleteSelector(data, token) {
  return request({
    url: "/shenyu/selector/batch",
    headers: {
      "X-Access-Token": token,
    },
    method: "DELETE",
    data: data,
  });
}

export async function getShenyuToken() {
  return await request({
    url: "/shenyu/platform/login?userName=admin&password=123456",
    method: "get",
  });
}


// 查询选择器列表
export function getOperatorList(token) {
  return request({
    url: `/shenyu/shenyu-dict/all/operator`,
    headers: {
      "X-Access-Token": token,
    },
    method: "get",
  });
}

// 查询选择器列表
export function getMatchModeList(token) {
  return request({
    url: `/shenyu/shenyu-dict/all/matchMode`,
    headers: {
      "X-Access-Token": token,
    },
    method: "get",
  });
}

// 查询选择器列表
export function getParamTypeList(token) {
  return request({
    url: `/shenyu/shenyu-dict/all/paramType`,
    headers: {
      "X-Access-Token": token,
    },
    method: "get",
  });
}

// 查询选择器列表
export function getPluginHandleList(token) {
  return request({
    url: `/shenyu/plugin-handle/all/5/1`,
    headers: {
      "X-Access-Token": token,
    },
    method: "get",
  });
}
