From 705eb31007de06e8de8e87bf71c0a398eeea721b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Mon, 23 Mar 2026 15:01:13 +0800 Subject: [PATCH] 1 --- common/cool/service.go | 8 ++++++-- modules/player/service/pet.go | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/cool/service.go b/common/cool/service.go index 858b6cb2b..c8b306034 100644 --- a/common/cool/service.go +++ b/common/cool/service.go @@ -240,7 +240,9 @@ func (s *Service) ServiceList(ctx context.Context, req *ListReq) (data interface for _, field := range s.ListQueryOp.DataFieldEQ { if val := r.Get(field); val.String() != "" { // 关键:拼接 data->>'字段名' = ? - m.Where("data->>? = ?", field, val) + // 错误写法:m.Where("data->>::TEXT? = ?", field, val) + // 正确写法: + m.Where("(data->>?)::TEXT = ?", field, val) } } } @@ -356,7 +358,9 @@ func (s *Service) ServicePage(ctx context.Context, req *PageReq) (data interface for _, field := range s.PageQueryOp.DataFieldEQ { if val := r.Get(field); val.String() != "" { // 关键:拼接 data->>'字段名' = ? - m.Where("data->>? = ?", field, val) + // 错误写法:m.Where("data->>::TEXT? = ?", field, val) + // 正确写法: + m.Where("(data->>?)::TEXT = ?", field, val) } } } diff --git a/modules/player/service/pet.go b/modules/player/service/pet.go index 86c1642f3..4def17065 100644 --- a/modules/player/service/pet.go +++ b/modules/player/service/pet.go @@ -320,7 +320,8 @@ func NewPetService(userid uint32) *PetService { }, }, PageQueryOp: &cool.QueryOp{ - FieldEQ: []string{"player_id", "free"}, + FieldEQ: []string{"player_id", "free"}, + DataFieldEQ: []string{"ID"}, Where: func(ctx context.Context) [][]interface{} { // var ( // admin = cool.GetAdmin(ctx)