(eid int64, libraryIDs []int64)
| 3265 | } |
| 3266 | |
| 3267 | func (s *SearchService) batchGetLibrariesByIDs(eid int64, libraryIDs []int64) (map[int64]*model.Library, error) { |
| 3268 | if len(libraryIDs) == 0 { |
| 3269 | return make(map[int64]*model.Library), nil |
| 3270 | } |
| 3271 | |
| 3272 | uniqueLibraryIDs := uniqueInt64IDsInOrder(libraryIDs) |
| 3273 | if len(uniqueLibraryIDs) == 0 { |
| 3274 | return make(map[int64]*model.Library), nil |
| 3275 | } |
| 3276 | |
| 3277 | libraries, err := model.GetLibrariesByEidCached(eid) |
| 3278 | if err != nil { |
| 3279 | return nil, err |
| 3280 | } |
| 3281 | |
| 3282 | requested := make(map[int64]struct{}, len(uniqueLibraryIDs)) |
| 3283 | for _, libraryID := range uniqueLibraryIDs { |
| 3284 | requested[libraryID] = struct{}{} |
| 3285 | } |
| 3286 | |
| 3287 | result := make(map[int64]*model.Library, len(uniqueLibraryIDs)) |
| 3288 | for i := range libraries { |
| 3289 | if _, ok := requested[libraries[i].ID]; !ok { |
| 3290 | continue |
| 3291 | } |
| 3292 | library := libraries[i] |
| 3293 | result[library.ID] = &library |
| 3294 | } |
| 3295 | return result, nil |
| 3296 | } |
| 3297 | |
| 3298 | // saveQueryRecord 保存查询记录 |
| 3299 | func (s *SearchService) saveQueryRecord(eid int64, userID *int64, req *SearchRequest, totalResults int, searchTimeMs int64) (int64, error) { |
no test coverage detected