add carts

This commit is contained in:
Daniel Goc
2026-03-24 14:47:20 +01:00
49 changed files with 1926 additions and 3374 deletions

View File

@@ -30,22 +30,12 @@ func (repo *CategoriesRepo) GetAllCategories(id_lang uint) ([]model.ScannedCateg
ps_category.is_root_category AS is_root_category,
ps_category_lang.link_rewrite AS link_rewrite,
ps_lang.iso_code AS iso_code
`).
Joins(`
LEFT JOIN ps_category_lang
ON ps_category_lang.id_category = ps_category.id_category
AND ps_category_lang.id_shop = ?
AND ps_category_lang.id_lang = ?
`, constdata.SHOP_ID, id_lang).
Joins(`
LEFT JOIN ps_category_shop
ON ps_category_shop.id_category = ps_category.id_category
AND ps_category_shop.id_shop = ?
`, constdata.SHOP_ID).
Joins(`
JOIN ps_lang
ON ps_lang.id_lang = ps_category_lang.id_lang
`).
FROM ps_category
LEFT JOIN ps_category_lang ON ps_category_lang.id_category = ps_category.id_category AND ps_category_lang.id_shop = ? AND ps_category_lang.id_lang = ?
LEFT JOIN ps_category_shop ON ps_category_shop.id_category = ps_category.id_category AND ps_category_shop.id_shop = ?
JOIN ps_lang ON ps_lang.id_lang = ps_category_lang.id_lang
`,
constdata.SHOP_ID, id_lang, constdata.SHOP_ID).
Scan(&allCategories).Error
return allCategories, err

View File

@@ -1,6 +1,7 @@
package listProductsRepo
import (
"git.ma-al.com/goc_daniel/b2b/app/config"
"git.ma-al.com/goc_daniel/b2b/app/db"
"git.ma-al.com/goc_daniel/b2b/app/model"
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
@@ -22,20 +23,6 @@ func (repo *ListProductsRepo) GetListing(id_lang uint, p find.Paging, filt *filt
var listing []model.ProductInList
var total int64
// var resultIDs []uint
// q := db.DB.
// // SQL_CALC_FOUND_ROWS is a neat trick which works on MariaDB and
// // MySQL. It works when followed by `SELECT FOUND_ROWS();`. To learn
// // more see: https://mariarawmodel.com/kb/en/found_rows/
// // WARN: This might not work on different SQL databases
// Select("DISTINCT SQL_CALC_FOUND_ROWS id").
// // Debug().
// Scopes(view.FromDBViewForDisplay(langID, countryIso)).
// Scopes(scopesForFiltersOnDisplay(db.DB, langID, countryIso, filt)).
// Scopes(filt.OfCategory(filters.ORDER_FILTER)...).
// Limit(p.Limit()).
// Offset(p.Offset())
subQuery := db.DB.
Table("ps_image").
Select("id_product, MIN(id_image) AS id_image").
@@ -44,12 +31,12 @@ func (repo *ListProductsRepo) GetListing(id_lang uint, p find.Paging, filt *filt
err := db.DB.
Table("ps_product").
Select(`
ps_product.id_product AS id,
ps_product.id_product AS product_id,
ps_product_lang.name AS name,
ps_product.active AS active,
ps_product_lang.link_rewrite AS link_rewrite,
COALESCE(ps_image_shop.id_image, any_image.id_image) AS id_image
`).
COALESCE(CONCAT( ?, '/', ps_image_shop.id_image, '-small_default/', ps_product_lang.link_rewrite, '.webp'), CONCAT( ?, '/', any_image.id_image, '-small_default/', ps_product_lang.link_rewrite, '.webp')) AS id_image
`, config.Get().Image.ImagePrefix, config.Get().Image.ImagePrefix).
Joins(`
LEFT JOIN ps_product_lang
ON ps_product_lang.id_product = ps_product.id_product

View File

@@ -0,0 +1,25 @@
package routesrepo
import (
"git.ma-al.com/goc_daniel/b2b/app/db"
"git.ma-al.com/goc_daniel/b2b/app/model"
)
type UIRoutesRepo interface {
GetRoutes(langId uint) ([]model.Route, error)
}
type RoutesRepo struct{}
func New() UIRoutesRepo {
return &RoutesRepo{}
}
func (p *RoutesRepo) GetRoutes(langId uint) ([]model.Route, error) {
routes := []model.Route{}
err := db.DB.Find(&routes).Error
if err != nil {
return nil, err
}
return routes, nil
}