Files
AIclinicalresearch/backend/src/modules/admin/routes/tenantRoutes.ts
HaHafeng 4ed67a8846 fix(admin): Fix Prompt management list not showing version info and add debug diagnostics
Summary:
- Fix Prompt list API response schema missing activeVersion and draftVersion fields
- Fastify was filtering out undefined schema fields, causing version columns to show empty
- Add detailed diagnostic logging for Prompt debug mode troubleshooting
- Verify debug mode works correctly (DRAFT version is used when debug enabled)

Changes:
- backend/src/common/prompt/prompt.routes.ts: Add activeVersion and draftVersion to response schema
- backend/src/common/prompt/prompt.service.ts: Add diagnostic logs for setDebugMode and get methods
- PKB module: Various authentication and document handling fixes from previous session

Tested: Debug mode verified working - v2 DRAFT version correctly loaded when debug enabled
2026-01-13 22:22:10 +08:00

81 lines
2.1 KiB
TypeScript

/**
* 租户管理路由
*
* 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,
});
}