fix 修复数据库查询bug

This commit is contained in:
timerzz 2024-09-01 16:49:35 +08:00
parent 402be86404
commit 14abeb24b5
5 changed files with 30 additions and 29 deletions

View File

@ -1,9 +1,10 @@
package productv1 package productv1
import ( import (
"testing"
"gitea.timerzz.com/kedaya_haitao/common/pkg/database" "gitea.timerzz.com/kedaya_haitao/common/pkg/database"
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
"testing"
) )
func TestUpsert(t *testing.T) { func TestUpsert(t *testing.T) {

View File

@ -70,7 +70,7 @@ func (l *FindArticleQuery) Scope(db *gorm.DB) *gorm.DB {
db = db.Where("`id`=?", l.ID) db = db.Where("`id`=?", l.ID)
} }
if l.Keyword != "" { if l.Keyword != "" {
db = db.Where("(`name` LIKE ? OR `english_name LIKE ? OR `remark` LIKE ? )", "%"+l.Keyword+"%", "%"+l.Keyword+"%", "%"+l.Keyword+"%") db = db.Where("(`name` ilike ? OR `english_name ilike ? OR `remark` ilike ? )", "%"+l.Keyword+"%", "%"+l.Keyword+"%", "%"+l.Keyword+"%")
} }
if l.Brand != "" { if l.Brand != "" {
db = db.Where("`brand`=?", l.Brand) db = db.Where("`brand`=?", l.Brand)

View File

@ -43,7 +43,7 @@ func (g *ListProviderQuery) Scope(db *gorm.DB) *gorm.DB {
db = db.Where("provider_id=?", g.ProviderId) db = db.Where("provider_id=?", g.ProviderId)
} }
if g.Keyword != "" { if g.Keyword != "" {
db = db.Where("name LIKE ?", "%"+g.Keyword+"%") db = db.Where("name ilike ?", "%"+g.Keyword+"%")
} }
return db return db
} }

View File

@ -43,7 +43,7 @@ func (g *ListSellerQuery) Scope(db *gorm.DB) *gorm.DB {
db = db.Where("seller_id=?", g.SellerId) db = db.Where("seller_id=?", g.SellerId)
} }
if g.Keyword != "" { if g.Keyword != "" {
db = db.Where("name LIKE ?", "%"+g.Keyword+"%") db = db.Where("name ilike ?", "%"+g.Keyword+"%")
} }
return db return db
} }