feat(session): 实现 Session CRUD 管理功能#44
Merged
ckeyer merged 3 commits intoinsmtx:mainfrom May 7, 2026
Merged
Conversation
- 添加 Session 和 SessionMessage 类型定义 - 实现 Session DAO 层(CRUD、生命周期管理、消息管理) - 实现 Session Service 层(业务逻辑、状态转换验证) - 定义 Session Contract 接口和类型结构 - 实现 Session Handler(13 个 API 端点) - 注册 Session 路由到 /v1 分组 - 添加数据库迁移支持(自动创建 session 和 session_message 表) 主要功能: - 会话 CRUD 操作(创建、查询、更新、删除) - 会话生命周期管理(激活、暂停、结束、恢复) - 会话消息管理(添加消息、查询消息、删除消息、清空消息) - 支持多条件过滤和分页查询 - 自动维护会话的消息计数和最后消息时间
- 添加 Session DAO 层单元测试 (23 个测试用例) - 添加 SessionMessage DAO 层单元测试 (11 个测试用例) - 添加 Session Service 层单元测试 (22 个测试用例) - 为所有 Session API 端点添加 Swagger 文档注释 - 更新 Swagger 文档 (docs/docs.go, swagger.json, swagger.yaml) - 修复 DeleteMessage 方法中的 bug 测试覆盖: - DAO 层:CRUD 操作、生命周期管理、消息管理、分页查询 - Service 层:业务逻辑、状态转换验证、消息计数维护 - 所有测试通过,编译成功
- 添加 MessageRoleTool 角色类型 - 添加 MessageStatus 状态常量(sending/streaming/complete/error) - SessionMessage 新增字段: - Status (消息状态) - Chunks (流式片段 JSON 数组) - Thinking (思维链) - ToolCalls (工具调用 JSON 数组) - Timestamp (Unix 毫秒时间戳) - MessageMetadata 新增字段: - Model (LLM 模型名称) - Tokens (Token 数量) - Latency (延迟毫秒) - 添加 ToolCall 结构体和 ToolCallStatus 状态 - 添加自定义类型 StringSlice 和 ToolCallSlice 支持 JSONB 存储 - 更新 SessionMessage 响应结构: - ID 从 uint 转换为 string - SessionID 字段映射为 conversation_id - 添加 Status, Chunks, Thinking, ToolCalls, Timestamp 字段 - 更新 AddMessageRequest 支持新字段 - 更新转换函数以匹配新的数据结构 - 更新 Swagger 文档 数据结构现在与 docs/frontend/ai-assistant/data-model.md 对齐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
主要功能: