import { http2 } from "@/utils/request.js"

// ========== 后台菜单管理 ==========

/** 获取后台菜单列表 */
export const getWebRoutsList = (params) => {
  return http2.get('/api/v1/admin/server/web_routs/list', { params })
}

/** 新增后台菜单 */
export const addWebRouts = (data) => {
  return http2.post('/api/v1/admin/server/web_routs/add', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改后台菜单 */
export const updateWebRouts = (data) => {
  return http2.post('/api/v1/admin/server/web_routs/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除后台菜单 */
export const deleteWebRouts = (data) => {
  return http2.delete('/api/v1/admin/server/web_routs/delete', {
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// ========== 后台菜单权限管理 ==========

/** 获取后台菜单权限列表 */
export const getWebRoutsPermissionList = (params) => {
  return http2.get('/api/v1/admin/server/web_routs/permission/list', { params })
}

/** 新增后台菜单权限 */
export const addWebRoutsPermission = (data) => {
  return http2.post('/api/v1/admin/server/web_routs/permission/add', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改后台菜单权限 */
export const updateWebRoutsPermission = (data) => {
  return http2.post('/api/v1/admin/server/web_routs/permission/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除后台菜单权限 */
export const deleteWebRoutsPermission = (data) => {
  return http2.delete('/api/v1/admin/server/web_routs/permission/delete', {
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 获取当前用户的后台菜单权限树 */
export const getMyWebRoutsPermission = () => {
  return http2.get('/api/v1/admin/server/web_routs/my')
}
