fix 修复查询时的`bug
This commit is contained in:
parent
e82ee959ed
commit
1290c1e1fd
@ -68,19 +68,19 @@ func (f *FindArticleQuery) SetAvailable(available bool) *FindArticleQuery {
|
|||||||
|
|
||||||
func (l *FindArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
func (l *FindArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
||||||
if l.ID != 0 {
|
if l.ID != 0 {
|
||||||
db = db.Where("`id`=?", l.ID)
|
db = db.Where("id=?", l.ID)
|
||||||
}
|
}
|
||||||
if l.Keyword != "" {
|
if l.Keyword != "" {
|
||||||
db = db.Where("(`name` ilike ? OR `english_name ilike ? OR `remark` ilike ? )", "%"+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)
|
||||||
}
|
}
|
||||||
if l.Pid != "" {
|
if l.Pid != "" {
|
||||||
db = db.Where("`pid`=?", l.Pid)
|
db = db.Where("pid=?", l.Pid)
|
||||||
}
|
}
|
||||||
if l.Available != nil {
|
if l.Available != nil {
|
||||||
db = db.Where("`available`=?", *l.Available)
|
db = db.Where("available=?", *l.Available)
|
||||||
}
|
}
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
@ -133,13 +133,13 @@ func NewGetArticleQuery() *GetArticleQuery {
|
|||||||
func (g *GetArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
func (g *GetArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
||||||
db = db.Preload("Providers").Preload("Sellers")
|
db = db.Preload("Providers").Preload("Sellers")
|
||||||
if g.ID != 0 {
|
if g.ID != 0 {
|
||||||
db = db.Where("`id`=?", g.ID)
|
db = db.Where("id=?", g.ID)
|
||||||
}
|
}
|
||||||
if g.Brand != "" {
|
if g.Brand != "" {
|
||||||
db = db.Where("`brand`=?", g.Brand)
|
db = db.Where("brand=?", g.Brand)
|
||||||
}
|
}
|
||||||
if g.Pid != "" {
|
if g.Pid != "" {
|
||||||
db = db.Where("`pid`=?", g.Pid)
|
db = db.Where("pid=?", g.Pid)
|
||||||
}
|
}
|
||||||
if g.History {
|
if g.History {
|
||||||
db = db.Preload("Providers.HistoryPrice").Preload("Sellers.HistoryPrice")
|
db = db.Preload("Providers.HistoryPrice").Preload("Sellers.HistoryPrice")
|
||||||
|
Loading…
Reference in New Issue
Block a user