mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
Fix search
This commit is contained in:
@@ -422,7 +422,11 @@ func GetResourcesIdWithTag(tagID uint) ([]uint, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return tagIds, nil
|
||||
ids := make([]uint, len(result))
|
||||
for i, r := range result {
|
||||
ids[i] = r.ID
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
func BatchGetResources(ids []uint) ([]model.Resource, error) {
|
||||
|
@@ -325,6 +325,21 @@ func SearchResource(query string, page int) ([]model.ResourceView, int, error) {
|
||||
}
|
||||
resources = append(resources, temp...)
|
||||
|
||||
// remove duplicates
|
||||
temp = make([]uint, 0)
|
||||
for _, id := range resources {
|
||||
found := false
|
||||
for _, id2 := range temp {
|
||||
if id == id2 {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
temp = append(temp, id)
|
||||
}
|
||||
}
|
||||
|
||||
if start >= len(resources) {
|
||||
return []model.ResourceView{}, 0, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user