mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
refactor: improve search user collections logic to handle optional keyword
This commit is contained in:
@@ -181,7 +181,11 @@ func SearchUserCollections(uid uint, keyword string, excludedRID uint) ([]*model
|
||||
var collections []*model.Collection
|
||||
|
||||
query := db.Model(&model.Collection{}).
|
||||
Where("user_id = ? AND title LIKE ?", uid, "%"+keyword+"%")
|
||||
Where("user_id = ?", uid)
|
||||
|
||||
if keyword != "" {
|
||||
query = query.Where("title LIKE ?", "%"+keyword+"%")
|
||||
}
|
||||
|
||||
if excludedRID > 0 {
|
||||
// Use LEFT JOIN with IS NULL for better performance
|
||||
|
Reference in New Issue
Block a user