|
|
@ -62,7 +62,7 @@ func Paginate(r *Request) func(db *gorm.DB) *gorm.DB { |
|
|
|
func Search(r *Request, key, query string) func(db *gorm.DB) *gorm.DB { |
|
|
|
func Search(r *Request, key, query string) func(db *gorm.DB) *gorm.DB { |
|
|
|
return func(db *gorm.DB) *gorm.DB { |
|
|
|
return func(db *gorm.DB) *gorm.DB { |
|
|
|
if keyword, ok := r.Get(key); ok { |
|
|
|
if keyword, ok := r.Get(key); ok { |
|
|
|
return db.Where(query, keyword) |
|
|
|
return db.Where(query, "%"+keyword+"%") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return db |
|
|
|
return db |
|
|
|
} |
|
|
|
} |
|
|
|