feat(dc/tool-c): Day 2 - Session管理与数据处理完成

核心功能:
- 数据库: 创建dc_tool_c_sessions表 (12字段, 3索引)
- 服务层: SessionService (383行), DataProcessService (303行)
- 控制器: SessionController (300行, 6个API端点)
- 路由: 新增6个Session管理路由
- 测试: 7个API测试全部通过 (100%)

技术亮点:
- 零落盘架构: Excel内存解析, OSS存储
- Session管理: 10分钟过期, 心跳延长机制
- 云原生规范: storage/logger/prisma全平台复用
- 完整测试: 上传/预览/完整数据/删除/心跳

文件清单:
- backend/prisma/schema.prisma (新增DcToolCSession模型)
- backend/prisma/migrations/create_tool_c_session.sql
- backend/scripts/create-tool-c-table.mjs
- backend/src/modules/dc/tool-c/services/ (SessionService, DataProcessService)
- backend/src/modules/dc/tool-c/controllers/SessionController.ts
- backend/src/modules/dc/tool-c/routes/index.ts
- backend/test-tool-c-day2.mjs
- docs/03-业务模块/DC-数据清洗整理/00-工具C当前状态与开发指南.md
- docs/03-业务模块/DC-数据清洗整理/06-开发记录/2025-12-06_工具C_Day2开发完成总结.md

代码统计: ~1900行
测试结果: 7/7 通过 (100%)
云原生规范: 完全符合
This commit is contained in:
2025-12-06 22:12:47 +08:00
parent 8be741cd52
commit 2348234013
13 changed files with 3466 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
/**
* 工具C路由定义
*
* @module routes
*/
import { FastifyInstance } from 'fastify';
import { testController } from '../controllers/TestController.js';
import { sessionController } from '../controllers/SessionController.js';
export async function toolCRoutes(fastify: FastifyInstance) {
// ==================== 测试路由Day 1 ====================
// 测试Python服务健康检查
fastify.get('/test/health', {
handler: testController.testHealth.bind(testController),
});
// 测试代码验证
fastify.post('/test/validate', {
handler: testController.testValidate.bind(testController),
});
// 测试代码执行
fastify.post('/test/execute', {
handler: testController.testExecute.bind(testController),
});
// ==================== Session管理路由Day 2 ====================
// 上传Excel文件创建Session
fastify.post('/sessions/upload', {
handler: sessionController.upload.bind(sessionController),
});
// 获取Session信息元数据
fastify.get('/sessions/:id', {
handler: sessionController.getSession.bind(sessionController),
});
// 获取预览数据前100行
fastify.get('/sessions/:id/preview', {
handler: sessionController.getPreviewData.bind(sessionController),
});
// 获取完整数据
fastify.get('/sessions/:id/full', {
handler: sessionController.getFullData.bind(sessionController),
});
// 删除Session
fastify.delete('/sessions/:id', {
handler: sessionController.deleteSession.bind(sessionController),
});
// 更新心跳延长10分钟
fastify.post('/sessions/:id/heartbeat', {
handler: sessionController.updateHeartbeat.bind(sessionController),
});
}