f938ca6c00
添加角色基于访问控制(RBAC)相关接口: 1. API 代理路由 - api.v3.rbac.roles._index.tsx: 角色列表和创建 - api.v3.rbac.roles.$roleId.tsx: 角色详情、更新和删除 - api.v3.rbac.roles.$roleId.users.tsx: 角色用户关联管理 - api.v3.rbac.users.$userId.roles.tsx: 用户角色列表 - api.v3.rbac.users.$userId.roles.$roleId.tsx: 用户角色分配 2. 模拟数据服务 - rbac-mock-data.server.ts: 提供模拟角色和用户角色数据 - 支持 CRUD 操作 - 包含预置的系统管理员、开发者等角色 接口功能: - ✅ 获取角色列表(支持分页和搜索) - ✅ 获取角色详情 - ✅ 创建、更新、删除角色 - ✅ 获取角色的用户列表 - ✅ 为用户分配/移除角色 注:当前使用模拟数据,待后端接口完善后切换到真实 API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
801 B
TypeScript
31 lines
801 B
TypeScript
/**
|
|
* RBAC API 代理 - 移除用户角色
|
|
* DELETE /api/v3/rbac/users/:userId/roles/:roleId
|
|
*/
|
|
|
|
import { json, type LoaderFunctionArgs } from "@remix-run/node";
|
|
import { removeUserRole } from "~/services/rbac-mock-data.server";
|
|
|
|
// DELETE - 移除用户角色
|
|
export async function action({ params }: LoaderFunctionArgs) {
|
|
const userId = parseInt(params.userId || '0');
|
|
const roleId = parseInt(params.roleId || '0');
|
|
|
|
console.log('📡 [API Route] DELETE /api/v3/rbac/users/' + userId + '/roles/' + roleId);
|
|
|
|
// 使用共享Mock数据移除角色
|
|
const success = removeUserRole(userId, roleId);
|
|
|
|
if (success) {
|
|
|
|
return json({
|
|
code: 200,
|
|
message: '用户角色移除成功'
|
|
});
|
|
}
|
|
|
|
return json({
|
|
detail: '用户角色关联不存在'
|
|
}, { status: 404 });
|
|
}
|