Skip to content

Commit 43dec56

Browse files
committed
feat: 如果没有选项默认为空数组
1 parent c9668e2 commit 43dec56

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/middleware/collect_answer.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ func FillHash(t *entity.Tiku) {
2929
}
3030
sort.Strings(options) // 将选项排序
3131

32-
optionsStr, _ := json.Marshal(options)
32+
sortOptionsStr, err := json.Marshal(options)
33+
if err != nil {
34+
sortOptionsStr = []byte("[]")
35+
}
3336

34-
t.Hash = strutil.Md5(t.Question + string(optionsStr) + strconv.Itoa(int(t.Type)) + strconv.Itoa(int(t.Plat)))
37+
t.Hash = strutil.Md5(t.Question + string(sortOptionsStr) + strconv.Itoa(int(t.Type)) + strconv.Itoa(int(t.Plat)))
3538
}
3639

3740
// CollectAnswer 收集没有搜索到的答案

0 commit comments

Comments
 (0)