24 lines
564 B
Go
Executable File
24 lines
564 B
Go
Executable File
package activity
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// GetCategoryNames 批量查询活动分类名称
|
|
// 参数: ids 分类ID数组
|
|
// 返回: id->名称映射与错误
|
|
func (s *service) GetCategoryNames(ctx context.Context, ids []int64) (map[int64]string, error) {
|
|
result := make(map[int64]string)
|
|
if len(ids) == 0 {
|
|
return result, nil
|
|
}
|
|
items, err := s.readDB.ActivityCategories.WithContext(ctx).Where(s.readDB.ActivityCategories.ID.In(ids...)).Find()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for _, v := range items {
|
|
result[v.ID] = v.Name
|
|
}
|
|
return result, nil
|
|
}
|