import request from "@/utils/request";
import { MenuQuery, MenuVO, MenuForm, RouteVO } from "./model";

class MenuAPI {
  /**
   * 获取路由列表
   */
  static getRoutes() {
    return new Promise((resolve) => {
      resolve([
        {
          path: "/modelMgr",
          component: "Layout",
          redirect: "/modelMgr/index",
          name: "/modelMgr",
          meta: {
            title: "算法分割管理",
            icon: "split",
            hidden: false,
            roles: ["GUEST", "ADMIN", "ADMIN6"],
            alwaysShow: false,
          },
          children: [
            {
              path: "index",
              component: "model/index",
              name: "modelIndex",
              meta: {
                title: "模型管理",
                icon: "user",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "uploadModel",
              component: "model/uploadModel",
              name: "uploadModel",
              meta: {
                title: "上传模型",
                icon: "user",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "modelDetail",
              component: "model/modelDetail",
              name: "modelDetail",
              meta: {
                title: "模型详情",
                icon: "user",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            }
          ],
        },
        {
          path: "/protocol",
          component: "Layout",
          redirect: "/protocol/index",
          name: "/protocol",
          meta: {
            title: "互联协议管理",
            icon: "web",
            hidden: false,
            roles: ["GUEST", "ADMIN", "ADMIN6"],
            alwaysShow: false,
          },
          children: [
            {
              path: "index",
              component: "protocol/index",
              name: "protocolIndex",
              meta: {
                title: "互联协议1",
                icon: "user",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            }
          ],
        },
        {
          path: "/simulationEvaluation",
          component: "Layout",
          redirect: "/simulationEvaluation/index",
          name: "/simulationEvaluation",
          meta: {
            title: "仿真评估",
            icon: "simu",
            hidden: false,
            roles: ["GUEST", "ADMIN", "ADMIN6"],
            alwaysShow: false,
          },
          children: [
            {
              path: "index",
              component: "simulationEvaluation/index",
              name: "simulationEvaluationIndex",
              meta: {
                title: "编译部署",
                icon: "user",
                hidden: false,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "reason",
              component: "simulationEvaluation/reason",
              name: "simulationEvaluationReason",
              meta: {
                title: "推理评估",
                icon: "role",
                hidden: false,
                roles: ["ADMIN6", "GUEST", "ADMIN"],
                keepAlive: true,
                alwaysShow: false,
              },
            },{
              path: "reasonReport",
              component: "simulationEvaluation/reasonReport",
              name: "simulationEvaluationReasonReport",
              meta: {
                title: "评估报告",
                icon: "role",
                hidden: false,
                roles: ["ADMIN6", "GUEST", "ADMIN"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
          ],
        },
        {
          path: "/operatorLibrary",
          component: "Layout",
          redirect: "/operatorLibrary/calculate",
          name: "/operatorLibrary",
          meta: {
            title: "算子库管理",
            icon: "oper",
            hidden: false,
            roles: ["GUEST", "ADMIN", "ADMIN6"],
            alwaysShow: false,
          },
          children: [
            {
              path: "calculate",
              component: "manage/calculate/index",
              name: "calculate",
              meta: {
                title: "算子管理",
                icon: "user",
                hidden: false,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "calculateEdit",
              component: "manage/calculate/edit",
              name: "calculateEdit",
              meta: {
                title: "算子编辑",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "calculateParam",
              component: "manage/calculateParam/index",
              name: "calculateParam",
              meta: {
                title: "算子参数管理",
                icon: "user",
                hidden: false,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "calculateParamEdit",
              component: "manage/calculateParam/edit",
              name: "calculateParamEdit",
              meta: {
                title: "算子参数编辑",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
          ],
        },
        {
          path: "/dataMgr",
          component: "Layout",
          redirect: "/dataMgr/datas",
          name: "/dataMgr",
          meta: {
            title: "数据集管理",
            icon: "db",
            hidden: false,
            roles: ["GUEST", "ADMIN", "ADMIN6"],
            alwaysShow: false,
          },
          children: [
            {
              path: "datas",
              component: "manage/datas/index",
              name: "datas",
              meta: {
                title: "数据集管理",
                icon: "user",
                hidden: false,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "datasEdit",
              component: "manage/datas/edit",
              name: "datasEdit",
              meta: {
                title: "数据集编辑",
                hidden: true,
                roles: ["ADMIN6", "GUEST", "ADMIN"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
          ],
        },
        {
          path: "/tester",
          component: "Layout",
          redirect: "/tester/index",
          name: "/tester",
          meta: {
            title: "算法测试仪管理",
            icon: "test",
            hidden: false,
            roles: ["GUEST", "ADMIN", "ADMIN6"],
            alwaysShow: false,
          },
          children: [
            {
              path: "equipment",
              component: "manage/equipment/index",
              name: "equipment",
              meta: {
                title: "计算设备管理",
                icon: "user",
                hidden: false,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "equipmentEdit",
              component: "manage/equipment/edit",
              name: "equipmentEdit",
              meta: {
                title: "计算设备编辑",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "equipmentEditPcie",
              component: "manage/equipment/editPcie",
              name: "equipmentEditPcie",
              meta: {
                title: "计算PCIE设备",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "equipmentEditNet",
              component: "manage/equipment/editNet",
              name: "equipmentEditNet",
              meta: {
                title: "计算网络设备",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "equipmentView",
              component: "manage/equipment/view",
              name: "equipmentView",
              meta: {
                title: "计算设备查看",
                hidden: true,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "otherTool",
              component: "manage/otherTool/index",
              name: "otherTool",
              meta: {
                title: "第三方工具管理",
                icon: "role",
                hidden: false,
                roles: ["ADMIN6", "GUEST", "ADMIN"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "otherToolEdit",
              component: "manage/otherTool/edit",
              name: "otherToolEdit",
              meta: {
                title: "第三方工具编辑",
                hidden: true,
                roles: ["ADMIN6", "GUEST", "ADMIN"],
                keepAlive: true,
                alwaysShow: false,
              }
            },
            {
              path: "otherToolView",
              component: "manage/otherTool/view",
              name: "otherToolView",
              meta: {
                title: "查看第三方工具",
                hidden: true,
                roles: ["ADMIN6", "GUEST", "ADMIN"],
                keepAlive: true,
                alwaysShow: false,
              }
            },
          ],
        },
        {
          path: "/system",
          component: "Layout",
          redirect: "/system/index",
          name: "/system",
          meta: {
            title: "系统管理",
            icon: "system",
            hidden: false,
            roles: ["GUEST", "ADMIN", "ADMIN6"],
            alwaysShow: false,
          },
          children: [
            {
              path: "user",
              component: "system/user/index",
              name: "User",
              meta: {
                title: "系统管理1",
                icon: "user",
                hidden: false,
                roles: ["ADMIN", "GUEST"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
            {
              path: "role",
              component: "system/role/index",
              name: "Role",
              meta: {
                title: "系统管理2",
                icon: "role",
                hidden: false,
                roles: ["ADMIN6", "GUEST", "ADMIN"],
                keepAlive: true,
                alwaysShow: false,
              },
            },
          ],
        },
      ]);
    });
    /*
    return request<any, RouteVO[]>({
      url: "/api/v1/menus/routes",
      method: "get",
    });*/
  }

  /**
   * 获取菜单树形列表
   *
   * @param queryParams
   */
  static getList(queryParams: MenuQuery) {
    return request<any, MenuVO[]>({
      url: "/api/v1/menus",
      method: "get",
      params: queryParams,
    });
  }

  /**
   * 获取菜单下拉数据源
   */
  static getOptions() {
    return request<any, OptionType[]>({
      url: "/api/v1/menus/options",
      method: "get",
    });
  }

  /**
   * 获取菜单表单数据
   *
   * @param id
   */
  static getFormData(id: number) {
    return request<any, MenuForm>({
      url: "/api/v1/menus/" + id + "/form",
      method: "get",
    });
  }

  /**
   * 添加菜单
   *
   * @param data
   */
  static add(data: MenuForm) {
    return request({
      url: "/api/v1/menus",
      method: "post",
      data: data,
    });
  }

  /**
   * 修改菜单
   *
   * @param id
   * @param data
   */
  static update(id: string, data: MenuForm) {
    return request({
      url: "/api/v1/menus/" + id,
      method: "put",
      data: data,
    });
  }

  /**
   * 删除菜单
   *
   * @param id 菜单ID
   */
  static deleteById(id: number) {
    return request({
      url: "/api/v1/menus/" + id,
      method: "delete",
    });
  }
}

export default MenuAPI;
