This commit is contained in:
@@ -113,7 +113,11 @@ func (s *storageFile) GetProduct(_ context.Context, id int64) (*crm.Product, err
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *storageFile) GetBreadcrumbs(_ context.Context, id int64) ([]*crm.Category, error) {
|
||||
func (s *storageFile) GetBreadcrumbs(ctx context.Context, id int64) ([]*crm.Category, error) {
|
||||
product, err := s.GetProduct(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data, err := os.ReadFile("resources/catalog.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -122,7 +126,11 @@ func (s *storageFile) GetBreadcrumbs(_ context.Context, id int64) ([]*crm.Catego
|
||||
if err := json.Unmarshal(data, &categories); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return getBreadcrumbs(categories, id), nil
|
||||
breadcrumbs := getBreadcrumbs(categories, product.Id)
|
||||
breadcrumbs = append(breadcrumbs, &crm.Category{
|
||||
Name: product.Name,
|
||||
})
|
||||
return breadcrumbs, nil
|
||||
}
|
||||
|
||||
func getBreadcrumbs(categories []*crm.Category, id int64) []*crm.Category {
|
||||
|
||||
Reference in New Issue
Block a user