import server from '@/utils/request'

interface Addobj{
    name:String	            //菜单名称
    mark:String	            //功能描述
    component:String        //对应路由组件component
    path:String	            //对应路由path
    status:String|Number	  //状态
    sort:String|Number	    //排序
    icon:String	            //菜单图标
    type:String	            //菜单类型: 系统-1，目录-2，页面-3
    parentId:String	        //父级菜单id
    pkId?:String
}

//新增
export function addmenu(data:Addobj) {
  return server.request({
    url: '/resource/menu/add',
    method: 'post',
    data
  })
}

//修改
export function update(data:Addobj) {
  return server.request({
    url: '/resource/menu/update',
    method: 'post',
    data
  })
}

//删除
export function delmenu(menuId:String) {
  return server.request({
    url: '/resource/menu/del',
    method: 'post',
    data:{
      menuId
    }
  })
}

//新增接口权限

interface AddTnter{
  code:String	            //资源编码：页面:操作   权限标识符
  name:String	            //接口名称
  menuId:String	          //菜单ID
  allow:String	          //允许访问路径，gateway-允许网关访问，private-不允许网关访问
  uri:String	            //uri路径
  requestType:String	    //请求方式：GET/POST/DEL/PUSH
  mark:String	            //接口描述
  pkId?:String
}

export function addInter(data:AddTnter) {
  return server.request({
    url: '/resource/permission/add',
    method: 'post',
    data
  })
}

//修改
export function updateInter(data:AddTnter) {
  return server.request({
    url: '/resource/permission/update',
    method: 'post',
    data
  })
}
//删除
export function delInter(permissionId:String) {
  return server.request({
    url: '/resource/permission/del',
    method: 'post',
    data:{
      permissionId
    }
  })
}

//查询
export function getInter(menuId:String) {
  return server.request({
    url: '/resource/permission/list',
    method: 'get',
    params:{
      menuId
    }
  })
}