Fix search

This commit is contained in:
2025-09-08 20:24:57 +08:00
parent faa802dd72
commit 5bf2544282
2 changed files with 20 additions and 1 deletions

View File

@@ -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) {

View File

@@ -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
}