update: 优化标签查询逻辑,新增查询条件构建和调试日志记录
This commit is contained in:
parent
e97b785a1e
commit
ce2bcdd387
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue