feat(admin): Complete tenant management and module access control system
Major Features: - Tenant management CRUD (list, create, edit, delete, module configuration) - Dynamic module management system (modules table with 8 modules) - Multi-tenant module permission merging (ModuleService) - Module access control middleware (requireModule) - User module permission API (GET /api/v1/auth/me/modules) - Frontend module permission filtering (HomePage + TopNavigation) Module Integration: - RVW module integrated with PromptService (editorial + methodology) - All modules (RVW/PKB/ASL/DC) added authenticate + requireModule middleware - Fixed ReviewTask foreign key constraint (cross-schema issue) - Removed all MOCK_USER_ID, unified to request.user?.userId Prompt Management Enhancements: - Module names displayed in Chinese (RVW -> 智能审稿) - Enhanced version history with view content and rollback features - List page shows both activeVersion and draftVersion columns Database Changes: - Added platform_schema.modules table - Modified tenant_modules table (added index and UUID) - Removed ReviewTask foreign key to public.users (cross-schema fix) - Seeded 8 modules: RVW, PKB, ASL, DC, IIT, AIA, SSA, ST Documentation Updates: - Updated ADMIN module development status - Updated TODO checklist (89% progress) - Updated Prompt management plan (Phase 3.5.5 completed) - Added module authentication specification Files Changed: 80+ Status: All features tested and verified locally Next: User management module development
This commit is contained in:
77
backend/src/modules/admin/routes/tenantRoutes.ts
Normal file
77
backend/src/modules/admin/routes/tenantRoutes.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 租户管理路由
|
||||
*
|
||||
* API前缀: /api/admin/tenants
|
||||
*/
|
||||
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import * as tenantController from '../controllers/tenantController.js';
|
||||
import { authenticate, requirePermission } from '../../../common/auth/auth.middleware.js';
|
||||
|
||||
export async function tenantRoutes(fastify: FastifyInstance) {
|
||||
// ==================== 租户管理 ====================
|
||||
|
||||
// 获取租户列表
|
||||
// GET /api/admin/tenants?type=&status=&search=&page=1&limit=20
|
||||
fastify.get('/', {
|
||||
preHandler: [authenticate, requirePermission('tenant:view')],
|
||||
handler: tenantController.listTenants,
|
||||
});
|
||||
|
||||
// 获取租户详情
|
||||
// GET /api/admin/tenants/:id
|
||||
fastify.get('/:id', {
|
||||
preHandler: [authenticate, requirePermission('tenant:view')],
|
||||
handler: tenantController.getTenant,
|
||||
});
|
||||
|
||||
// 创建租户
|
||||
// POST /api/admin/tenants
|
||||
fastify.post('/', {
|
||||
preHandler: [authenticate, requirePermission('tenant:create')],
|
||||
handler: tenantController.createTenant,
|
||||
});
|
||||
|
||||
// 更新租户信息
|
||||
// PUT /api/admin/tenants/:id
|
||||
fastify.put('/:id', {
|
||||
preHandler: [authenticate, requirePermission('tenant:edit')],
|
||||
handler: tenantController.updateTenant,
|
||||
});
|
||||
|
||||
// 更新租户状态
|
||||
// PUT /api/admin/tenants/:id/status
|
||||
fastify.put('/:id/status', {
|
||||
preHandler: [authenticate, requirePermission('tenant:edit')],
|
||||
handler: tenantController.updateTenantStatus,
|
||||
});
|
||||
|
||||
// 删除租户
|
||||
// DELETE /api/admin/tenants/:id
|
||||
fastify.delete('/:id', {
|
||||
preHandler: [authenticate, requirePermission('tenant:delete')],
|
||||
handler: tenantController.deleteTenant,
|
||||
});
|
||||
|
||||
// 配置租户模块
|
||||
// PUT /api/admin/tenants/:id/modules
|
||||
fastify.put('/:id/modules', {
|
||||
preHandler: [authenticate, requirePermission('tenant:edit')],
|
||||
handler: tenantController.configureModules,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 模块管理路由
|
||||
*
|
||||
* API前缀: /api/admin/modules
|
||||
*/
|
||||
export async function moduleRoutes(fastify: FastifyInstance) {
|
||||
// 获取所有可用模块列表
|
||||
// GET /api/admin/modules
|
||||
fastify.get('/', {
|
||||
preHandler: [authenticate, requirePermission('tenant:view')],
|
||||
handler: tenantController.listModules,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user