mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 20:27:23 +00:00
Fix search
This commit is contained in:
@@ -422,7 +422,11 @@ func GetResourcesIdWithTag(tagID uint) ([]uint, error) {
|
|||||||
return nil, err
|
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) {
|
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...)
|
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) {
|
if start >= len(resources) {
|
||||||
return []model.ResourceView{}, 0, nil
|
return []model.ResourceView{}, 0, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user