This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +321,7 @@ func NewPetService(userid uint32) *PetService {
|
||||
},
|
||||
PageQueryOp: &cool.QueryOp{
|
||||
FieldEQ: []string{"player_id", "free"},
|
||||
DataFieldEQ: []string{"ID"},
|
||||
Where: func(ctx context.Context) [][]interface{} {
|
||||
// var (
|
||||
// admin = cool.GetAdmin(ctx)
|
||||
|
||||
Reference in New Issue
Block a user