update: 优化标签查询逻辑,新增查询条件构建和调试日志记录
This commit is contained in:
parent
2000f2a89e
commit
26c52879bc
|
|
@ -1,6 +1,8 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/beancount-gs/script"
|
"github.com/beancount-gs/script"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
@ -12,7 +14,15 @@ type Tags struct {
|
||||||
func QueryTags(c *gin.Context) {
|
func QueryTags(c *gin.Context) {
|
||||||
ledgerConfig := script.GetLedgerConfigFromContext(c)
|
ledgerConfig := script.GetLedgerConfigFromContext(c)
|
||||||
tags := make([]Tags, 0)
|
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 {
|
if err != nil {
|
||||||
InternalError(c, err.Error())
|
InternalError(c, err.Error())
|
||||||
return
|
return
|
||||||
|
|
@ -22,8 +32,13 @@ func QueryTags(c *gin.Context) {
|
||||||
for _, t := range tags {
|
for _, t := range tags {
|
||||||
if t.Value != "" {
|
if t.Value != "" {
|
||||||
result = append(result, 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)
|
OK(c, result)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue