fix products listing

This commit is contained in:
2026-03-27 23:17:21 +01:00
parent ec05101037
commit 9ec329b1d6
429 changed files with 9816 additions and 3774 deletions

View File

@@ -0,0 +1,44 @@
package categoryrepo
import (
"git.ma-al.com/goc_daniel/b2b/app/db"
"git.ma-al.com/goc_daniel/b2b/app/model/dbmodel"
)
type UICategoryRepo interface {
GetCategoryTranslations(ids []uint, idLang uint) (map[uint]string, error)
}
type CategoryRepo struct{}
func New() UICategoryRepo {
return &CategoryRepo{}
}
func (r *CategoryRepo) GetCategoryTranslations(ids []uint, idLang uint) (map[uint]string, error) {
if len(ids) == 0 {
return map[uint]string{}, nil
}
type result struct {
IDCategory int32
Name string
}
var results []result
if err := db.Get().
Model(dbmodel.PsCategoryLang{}).
Select("ps_category_lang.id_category, COALESCE(ps_category_lang.name, '') as name").
Where("ps_category_lang.id_category IN ?", ids).
Where("ps_category_lang.id_lang = ?", idLang).
Scan(&results).Error; err != nil {
return nil, err
}
translations := make(map[uint]string, len(results))
for _, res := range results {
translations[uint(res.IDCategory)] = res.Name
}
return translations, nil
}