import request from '@/config/axios'

export interface PermissionAssignUserRoleReqVO {
  userId: number
  roleIds: number[]
}

export interface PermissionAssignRoleMenuReqVO {
  roleId: number
  menuIds: number[]
}

export interface PermissionAssignRoleDataScopeReqVO {
  roleId: number
  dataScope: number
  dataScopeDeptIds: number[]
}

export interface PermissionAssignRoleCourseScopeReqVO {
  roleId: number
  dataScopeCourseIds: number[]
}

export interface PermissionAssignRoleBlocklyScopeReqVO {
  roleId: number
  dataScopeBlocklyIds: number[]
}

export interface PermissionAssignRoleAiCourseScopeReqVO {
  roleId: number
  dataScopeAiCourseIds: number[]
}

export interface PermissionAssignRoleWebScopeReqVO {
  roleId: number
  dataScopeWebRoute: String[]
  dataScopeCourseIds: number[]
  dataScopeBlocklyIds: number[]
  dataScopeAiCourseIds: number[]
}
export interface PermissionAssignRoleWebMenuScopeReqVO {
  roleId: number
  dataScopeWebRoute: String[]
  dataScopeWebMenuRoute: String[]
}

// 查询角色拥有的菜单权限
export const getRoleMenuList = async (roleId: number) => {
  return await request.get({ url: '/system/permission/list-role-menus?roleId=' + roleId })
}

// 赋予角色菜单权限
export const assignRoleMenu = async (data: PermissionAssignRoleMenuReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-menu', data })
}

// 赋予角色数据权限
export const assignRoleDataScope = async (data: PermissionAssignRoleDataScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-data-scope', data })
}

// 赋予角色课程权限
export const assignRoleCourseScope = async (data: PermissionAssignRoleCourseScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-course-scope', data })
}

// 赋予角色blockly课程权限
export const assignRoleBlocklyScope = async (data: PermissionAssignRoleBlocklyScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-blockly-scope', data })
}

// 赋予角色Ai实验课课程权限
export const assignRoleAiCourseScope = async (data: PermissionAssignRoleAiCourseScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-aiCourse-scope', data })
}

// 赋予角色Web路由权限
export const assignRoleWebScope = async (data: PermissionAssignRoleWebScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-web-scope', data })
}

// 赋予角色Web菜单权限
export const assignRoleWebMenuScope = async (data: PermissionAssignRoleWebMenuScopeReqVO) => {
  return await request.post({ url: '/system/permission/assign-role-web-menu-scope', data })
}


// 查询用户拥有的角色数组
export const getUserRoleList = async (userId: number) => {
  return await request.get({ url: '/system/permission/list-user-roles?userId=' + userId })
}

// 赋予用户角色
export const assignUserRole = async (data: PermissionAssignUserRoleReqVO) => {
  return await request.post({ url: '/system/permission/assign-user-role', data })
}
