Skip to content

Commit

Permalink
[feature] #18 #30 支持模糊匹配
Browse files Browse the repository at this point in the history
  • Loading branch information
runs committed Mar 7, 2023
1 parent f5587d1 commit 08eae4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/app/api/service/bilbil_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func queryCheck() map[string]func(item query_parser.QueryItem) (bool, string) {
return map[string]func(item query_parser.QueryItem) (bool, string){
"tag": _stringCheck,
"name": _stringCheck,
"title": _stringCheck,
"mid": _numericCheck,
"view": _numericCheck,
"pubdate": _numericCheck,
Expand Down
2 changes: 1 addition & 1 deletion internal/repository/bilbil_video_pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (impl *BilibiliVideoPostgresImpl) builderQueryItems(tx *gorm.DB, queryItems
switch item.Type {
case query_parser.TypeAND:
for _, value := range item.Values {
tx = tx.Where(fmt.Sprintf("%s = ?", item.Key), value)
tx = tx.Where(fmt.Sprintf("%s LIKE ?", item.Key), "%"+value+"%")
}
case query_parser.TypeOR:
tx = tx.Where(fmt.Sprintf("%s IN (?)", item.Key), item.Values)
Expand Down

0 comments on commit 08eae4f

Please sign in to comment.