All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
feat(cool): 修改关键词搜索逻辑以支持文本类型匹配 将 WhereOrLike 查询方式改为 WhereOrf,使用 PostgreSQL 的文本类型转换语法, 通过 field::text LIKE 来实现更准确的关键词匹配功能。 fix(config): 为店铺服务添加默认查询条件和字段选择 在 ShopService 中增加 ListQueryOp 配置,设置默认查询条件 is_enable=1 和指定的字段选择列表,优化查询性能并确保数据有效性。 ```
43 lines
785 B
Go
43 lines
785 B
Go
package service
|
|
|
|
import (
|
|
"blazing/cool"
|
|
"blazing/modules/config/model"
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
type ShopService struct {
|
|
*cool.Service
|
|
}
|
|
|
|
func NewShopService() *ShopService {
|
|
return &ShopService{
|
|
&cool.Service{
|
|
Model: model.NewShopConfig(),
|
|
ListQueryOp: &cool.QueryOp{
|
|
Where: func(ctx context.Context) []g.Array {
|
|
return [][]interface{}{
|
|
|
|
{"is_enable", 1, true},
|
|
}
|
|
},
|
|
Select: "product_id,product_name,seerdou_price,jindou_price,remark",
|
|
},
|
|
|
|
PageQueryOp: &cool.QueryOp{
|
|
KeyWordField: []string{"desc", "product_name"},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
func (s *ShopService) Get(product_id uint32) *model.ShopConfig {
|
|
m := dbm_enable(s.Model).Where("product_id", product_id)
|
|
var tt *model.ShopConfig
|
|
m.Scan(&tt)
|
|
|
|
return tt
|
|
|
|
}
|