f
This commit is contained in:
@@ -449,8 +449,8 @@ func (s *ProductManagementService) GetAllProductsForDictionary(ctx context.Conte
|
||||
|
||||
options := interfaces.ListOptions{
|
||||
Page: 1,
|
||||
PageSize: 1000, // 获取所有产品
|
||||
Sort: "sort", // 使用 products 表的 sort 字段,排序后再按分类分组
|
||||
PageSize: 1000, // 获取所有产品
|
||||
Sort: "category.sort", // 按分类的排序字段排序
|
||||
Order: "asc",
|
||||
}
|
||||
|
||||
@@ -461,20 +461,5 @@ func (s *ProductManagementService) GetAllProductsForDictionary(ctx context.Conte
|
||||
return nil, fmt.Errorf("获取产品字典数据失败: %w", err)
|
||||
}
|
||||
|
||||
// 预加载分类信息
|
||||
for _, product := range products {
|
||||
if product.CategoryID != "" {
|
||||
category, _ := s.categoryRepo.GetByID(ctx, product.CategoryID)
|
||||
product.Category = &category
|
||||
}
|
||||
|
||||
if product.SubCategoryID != nil && *product.SubCategoryID != "" {
|
||||
subCategory, err := s.subCategoryRepo.GetByID(ctx, *product.SubCategoryID)
|
||||
if err == nil && subCategory != nil {
|
||||
product.SubCategory = subCategory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return products, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user