diff --git a/service/tags.go b/service/tags.go index 29f3380..a732f9e 100644 --- a/service/tags.go +++ b/service/tags.go @@ -1,6 +1,8 @@ package service import ( + "fmt" + "github.com/beancount-gs/script" "github.com/gin-gonic/gin" ) @@ -12,7 +14,15 @@ type Tags struct { func QueryTags(c *gin.Context) { ledgerConfig := script.GetLedgerConfigFromContext(c) tags := make([]Tags, 0) - err := script.BQLQueryList(ledgerConfig, nil, &tags) + + // 使用 script.QueryParams 构建查询条件 + queryParams := &script.QueryParams{ + Where: true, // 启用 WHERE 子句 + Tag: "tags", // tag in tags 条件 + TagNotNull: "true", // tag 非空条件(值可以是任意非空字符串) + } + + err := script.BQLQueryList(ledgerConfig, queryParams, &tags) if err != nil { InternalError(c, err.Error()) return @@ -22,8 +32,13 @@ func QueryTags(c *gin.Context) { for _, t := range tags { if t.Value != "" { result = append(result, t.Value) + // 记录每个标签值 + script.LogDebugDetailed(ledgerConfig.Mail, "TagValue", "标签值: %s", t.Value) } } + // 记录最终返回结果 + script.LogDebug(ledgerConfig.Mail, fmt.Sprintf("返回 %d 个标签", len(result))) + OK(c, result) }