add carts
This commit is contained in:
@@ -20,40 +20,10 @@ func New() *ListProductsService {
|
||||
func (s *ListProductsService) GetListing(id_lang uint, p find.Paging, filters *filters.FiltersList) (find.Found[model.ProductInList], error) {
|
||||
var products find.Found[model.ProductInList]
|
||||
|
||||
// currencyIso := c.Cookies("currency_iso", "")
|
||||
// countryIso := c.Cookies("country_iso", "")
|
||||
|
||||
// if overrides["override_currency"] != "" {
|
||||
// currencyIso = overrides["override_currency"]
|
||||
// }
|
||||
// if overrides["override_country"] != "" {
|
||||
// countryIso = overrides["override_country"]
|
||||
// }
|
||||
|
||||
products, err := s.listProductsRepo.GetListing(id_lang, p, filters)
|
||||
if err != nil {
|
||||
return products, err
|
||||
}
|
||||
|
||||
// var loopErr error
|
||||
// parallel.ForEach(products.Items, func(t model.Product, i int) {
|
||||
// // products.Items[i].PriceTaxed *= currRate.Rate.InexactFloat64()
|
||||
// // products.Items[i].PriceTaxed = tiny_util.RoundUpMonetary(products.Items[i].PriceTaxed)
|
||||
|
||||
// if products.Items[i].Name.IsNull() {
|
||||
// translation, err := s.listProductsRepo.GetTranslation(ctx, products.Items[i].ID, defaults.DefaultLanguageID)
|
||||
// if err != nil {
|
||||
// loopErr = err
|
||||
// return
|
||||
// }
|
||||
// products.Items[i].Name = nullable.FromPrimitiveString(translation.Name)
|
||||
// products.Items[i].DescriptionShort = nullable.FromPrimitiveString(translation.DescriptionShort)
|
||||
// products.Items[i].LinkRewrite = nullable.FromPrimitiveString(translation.LinkRewrite)
|
||||
// }
|
||||
// })
|
||||
// if loopErr != nil {
|
||||
// return products, errs.Handled(span, loopErr, errs.InternalError, errs.ERR_TODO)
|
||||
// }
|
||||
|
||||
return products, nil
|
||||
}
|
||||
|
||||
@@ -5,23 +5,26 @@ import (
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/repos/categoriesRepo"
|
||||
routesRepo "git.ma-al.com/goc_daniel/b2b/app/repos/routesRepo"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
)
|
||||
|
||||
type MenuService struct {
|
||||
categoriesRepo categoriesRepo.UICategoriesRepo
|
||||
routesRepo routesRepo.UIRoutesRepo
|
||||
}
|
||||
|
||||
func New() *MenuService {
|
||||
return &MenuService{
|
||||
categoriesRepo: categoriesRepo.New(),
|
||||
routesRepo: routesRepo.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MenuService) GetMenu(id_lang uint) (model.Category, error) {
|
||||
func (s *MenuService) GetMenu(id_lang uint) (*model.Category, error) {
|
||||
all_categories, err := s.categoriesRepo.GetAllCategories(id_lang)
|
||||
if err != nil {
|
||||
return model.Category{}, err
|
||||
return &model.Category{}, err
|
||||
}
|
||||
|
||||
// find the root
|
||||
@@ -35,7 +38,7 @@ func (s *MenuService) GetMenu(id_lang uint) (model.Category, error) {
|
||||
}
|
||||
}
|
||||
if !root_found {
|
||||
return model.Category{}, responseErrors.ErrNoRootFound
|
||||
return &model.Category{}, responseErrors.ErrNoRootFound
|
||||
}
|
||||
|
||||
// now create the children and reorder them according to position
|
||||
@@ -57,7 +60,7 @@ func (s *MenuService) GetMenu(id_lang uint) (model.Category, error) {
|
||||
// finally, create the tree
|
||||
tree := s.createTree(root_index, &all_categories, &children_indices)
|
||||
|
||||
return tree, nil
|
||||
return &tree, nil
|
||||
}
|
||||
|
||||
func (s *MenuService) createTree(index int, all_categories *([]model.ScannedCategory), children_indices *(map[int][]ChildWithPosition)) model.Category {
|
||||
@@ -70,6 +73,10 @@ func (s *MenuService) createTree(index int, all_categories *([]model.ScannedCate
|
||||
return node
|
||||
}
|
||||
|
||||
func (s *MenuService) GetRoutes(id_lang uint) ([]model.Route, error) {
|
||||
return s.routesRepo.GetRoutes(id_lang)
|
||||
}
|
||||
|
||||
func (s *MenuService) scannedToNormalCategory(scanned model.ScannedCategory) model.Category {
|
||||
var normal model.Category
|
||||
// normal.Active = scanned.Active
|
||||
|
||||
Reference in New Issue
Block a user