签到检查功能增强:返回签到时间和内容

问题:
- 用户询问'我什么时候签到的'时,AI 说'系统只记录是否签到,没有时间戳'
- 实际上数据库 signs 表有完整的 sign_time 和 sign_text 字段

解决方案:
- 修改 executeCheck 方法,改用 ListSigns 查询今天的签到记录
- 返回完整的签到详情:签到时间(HH:MM:SS格式)+ 签到内容
- 未签到时仍返回简单提示

改动内容:
- executeCheck 使用 ListSigns 替代 HasSignedOnDay
- 构建 ListOptions 查询今天的签到记录(过滤 NodeID + 时间范围)
- 返回格式:'XXX 今天已经签到过了。\n签到时间:10:30:45\n签到内容:上海-Kevin-GAT562签到'
- 更新测试验证返回内容包含时间和签到文本
- 更新 mockSignStore.ListSigns 支持 NodeID 和 Limit 过滤

使用效果:
- 用户:'我今天签到了吗?' → 返回是否签到 + 时间 + 内容
- 用户:'我什么时候签到的?' → 返回签到时间:10:30:45

测试:
-  未签到场景测试通过
-  已签到场景测试通过(验证时间和内容)
-  所有签到工具测试通过
-  项目编译成功

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 21:47:16 +08:00
co-authored by Claude Fable 5
parent cbb54c28ca
commit 6620192322
3 changed files with 58 additions and 13 deletions
+20 -1
View File
@@ -85,6 +85,11 @@ func (m *mockSignStore) CountSignsByDay(opts storepkg.ListOptions) ([]storepkg.S
func (m *mockSignStore) ListSigns(opts storepkg.ListOptions) ([]storepkg.SignRecord, error) {
var result []storepkg.SignRecord
for _, sign := range m.signs {
// 过滤 NodeID
if opts.NodeID != "" && sign.NodeID != opts.NodeID {
continue
}
// 过滤时间范围
if opts.Since != nil && sign.SignTime.Before(*opts.Since) {
continue
}
@@ -93,6 +98,10 @@ func (m *mockSignStore) ListSigns(opts storepkg.ListOptions) ([]storepkg.SignRec
}
result = append(result, sign)
}
// 应用 Limit
if opts.Limit > 0 && len(result) > opts.Limit {
result = result[:opts.Limit]
}
return result, nil
}
@@ -261,12 +270,13 @@ func TestSignTool_CheckAction(t *testing.T) {
// 测试场景2:今天已签到
t.Run("今天已签到", func(t *testing.T) {
signTime := time.Date(2024, 6, 23, 10, 30, 45, 0, time.UTC)
store := &mockSignStore{
signs: []storepkg.SignRecord{
{
NodeID: "test_node_123",
SignText: "上海-TestUser-TestDevice签到",
SignTime: now,
SignTime: signTime,
},
},
nodeInfoMap: make(map[string]*storepkg.NodeInfoRecord),
@@ -300,6 +310,15 @@ func TestSignTool_CheckAction(t *testing.T) {
if !contains(result, "已经签到") {
t.Errorf("Expected result to indicate already signed")
}
if !contains(result, "签到时间") {
t.Errorf("Expected result to contain sign time")
}
if !contains(result, "10:30:45") {
t.Errorf("Expected result to contain the exact sign time")
}
if !contains(result, "签到内容") {
t.Errorf("Expected result to contain sign text")
}
})
}