diff --git a/app/delivery/web/api/restricted/menu.go b/app/delivery/web/api/restricted/menu.go
index d20cd45..74fa700 100644
--- a/app/delivery/web/api/restricted/menu.go
+++ b/app/delivery/web/api/restricted/menu.go
@@ -1,8 +1,6 @@
package restricted
import (
- "strconv"
-
"git.ma-al.com/goc_daniel/b2b/app/service/menuService"
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
@@ -26,18 +24,33 @@ func MenuHandlerRoutes(r fiber.Router) fiber.Router {
handler := NewMenuHandler()
r.Get("/get-menu", handler.GetMenu)
+ r.Get("/get-routes", handler.GetRouting)
return r
}
func (h *MenuHandler) GetMenu(c fiber.Ctx) error {
- id_lang, err := strconv.Atoi(c.Cookies("lang_id", "2"))
- if err != nil {
+ lang_id, ok := c.Locals("langID").(uint)
+ if !ok {
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
-
- menu, err := h.menuService.GetMenu(uint(id_lang))
+ menu, err := h.menuService.GetMenu(lang_id)
+ if err != nil {
+ return c.Status(responseErrors.GetErrorStatus(err)).
+ JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
+ }
+
+ return c.JSON(response.Make(&menu, 0, i18n.T_(c, response.Message_OK)))
+}
+
+func (h *MenuHandler) GetRouting(c fiber.Ctx) error {
+ lang_id, ok := c.Locals("langID").(uint)
+ if !ok {
+ return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
+ JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
+ }
+ menu, err := h.menuService.GetRoutes(lang_id)
if err != nil {
return c.Status(responseErrors.GetErrorStatus(err)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
diff --git a/app/delivery/web/init.go b/app/delivery/web/init.go
index bc61539..c18aaf0 100644
--- a/app/delivery/web/init.go
+++ b/app/delivery/web/init.go
@@ -110,6 +110,10 @@ func (s *Server) Setup() error {
meiliSearch := s.restricted.Group("/meili-search")
restricted.MeiliSearchHandlerRoutes(meiliSearch)
+ s.api.All("*", func(c fiber.Ctx) error {
+ return c.SendStatus(fiber.StatusNotFound)
+ })
+
// // Restricted routes example
// restricted := s.api.Group("/restricted")
// restricted.Use(middleware.AuthMiddleware())
diff --git a/app/model/product.go b/app/model/product.go
index eb63f68..3c8faae 100644
--- a/app/model/product.go
+++ b/app/model/product.go
@@ -82,18 +82,27 @@ type ProductFilters struct {
}
type ScannedCategory struct {
- CategoryID uint `gorm:"column:ID;primaryKey"`
- Name string `gorm:"column:name"`
- Active uint `gorm:"column:active"`
- Position uint `gorm:"column:position"`
- ParentID uint `gorm:"column:id_parent"`
- IsRoot uint `gorm:"column:is_root_category"`
+ CategoryID uint `gorm:"column:ID;primaryKey"`
+ Name string `gorm:"column:name"`
+ Active uint `gorm:"column:active"`
+ Position uint `gorm:"column:position"`
+ ParentID uint `gorm:"column:id_parent"`
+ IsRoot uint `gorm:"column:is_root_category"`
+ LinkRewrite string `gorm:"column:link_rewrite"`
+ IsoCode string `gorm:"column:iso_code"`
}
type Category struct {
- CategoryID uint `json:"category_id" form:"category_id"`
- Name string `json:"name" form:"name"`
- Active uint `json:"active" form:"active"`
- Subcategories []Category `json:"subcategories" form:"subcategories"`
+ CategoryID uint `json:"category_id" form:"category_id"`
+ Label string `json:"label" form:"label"`
+ // Active bool `json:"active" form:"active"`
+ Params CategpryParams `json:"params" form:"params"`
+ Children []Category `json:"children" form:"children"`
+}
+
+type CategpryParams struct {
+ CategoryID uint `json:"category_id" form:"category_id"`
+ LinkRewrite string `json:"link_rewrite" form:"link_rewrite"`
+ Locale string `json:"locale" form:"locale"`
}
type FeatVal = map[uint][]uint
diff --git a/app/model/routing.go b/app/model/routing.go
new file mode 100644
index 0000000..135f427
--- /dev/null
+++ b/app/model/routing.go
@@ -0,0 +1,21 @@
+package model
+
+type Route struct {
+ ID uint `gorm:"primaryKey;autoIncrement"`
+ Name string `gorm:"type:varchar(255);not null;unique"`
+ Path *string `gorm:"type:varchar(255);default:null"`
+ Component string `gorm:"type:varchar(255);not null;comment:path to component file"`
+ Layout *string `gorm:"type:varchar(50);default:'default';comment:'default | empty'"`
+ Meta *string `gorm:"type:longtext;default:'{}'"`
+ IsActive *bool `gorm:"type:tinyint;default:1"`
+ SortOrder *int `gorm:"type:int;default:0"`
+
+ ParentID *uint `gorm:"index"`
+ Parent *Route `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:SET NULL;foreignKey:ParentID"`
+
+ Children []Route `gorm:"foreignKey:ParentID"`
+}
+
+func (Route) TableName() string {
+ return "b2b_routes"
+}
diff --git a/app/repos/categoriesRepo/categoriesRepo.go b/app/repos/categoriesRepo/categoriesRepo.go
index 1713441..1556f59 100644
--- a/app/repos/categoriesRepo/categoriesRepo.go
+++ b/app/repos/categoriesRepo/categoriesRepo.go
@@ -26,15 +26,14 @@ func (repo *CategoriesRepo) GetAllCategories(id_lang uint) ([]model.ScannedCateg
ps_category.active AS active,
ps_category_shop.position AS position,
ps_category.id_parent AS id_parent,
- ps_category.is_root_category AS is_root_category
+ ps_category.is_root_category AS is_root_category,
+ ps_category_lang.link_rewrite AS link_rewrite,
+ ps_lang.iso_code AS iso_code
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 = ?`,
+ 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
diff --git a/app/repos/routesRepo/routesRepo.go b/app/repos/routesRepo/routesRepo.go
new file mode 100644
index 0000000..c70ba86
--- /dev/null
+++ b/app/repos/routesRepo/routesRepo.go
@@ -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
+}
diff --git a/app/service/menuService/menuService.go b/app/service/menuService/menuService.go
index 13a6a89..f4b9994 100644
--- a/app/service/menuService/menuService.go
+++ b/app/service/menuService/menuService.go
@@ -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,25 +60,31 @@ 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 {
node := s.scannedToNormalCategory((*all_categories)[index])
for i := 0; i < len((*children_indices)[index]); i++ {
- node.Subcategories = append(node.Subcategories, s.createTree((*children_indices)[index][i].Index, all_categories, children_indices))
+ node.Children = append(node.Children, s.createTree((*children_indices)[index][i].Index, all_categories, children_indices))
}
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
+ // normal.Active = scanned.Active
normal.CategoryID = scanned.CategoryID
- normal.Name = scanned.Name
- normal.Subcategories = []model.Category{}
+ normal.Label = scanned.Name
+ // normal.Active = scanned.Active == 1
+ normal.Params = model.CategpryParams{CategoryID: normal.CategoryID, LinkRewrite: scanned.LinkRewrite, Locale: scanned.IsoCode}
+ normal.Children = []model.Category{}
return normal
}
diff --git a/bo/components.d.ts b/bo/components.d.ts
index 622aa17..3425316 100644
--- a/bo/components.d.ts
+++ b/bo/components.d.ts
@@ -41,6 +41,7 @@ declare module 'vue' {
UInput: typeof import('./node_modules/@nuxt/ui/dist/runtime/components/Input.vue')['default']
UInputNumber: typeof import('./node_modules/@nuxt/ui/dist/runtime/components/InputNumber.vue')['default']
UModal: typeof import('./node_modules/@nuxt/ui/dist/runtime/components/Modal.vue')['default']
+ UNavigationMenu: typeof import('./node_modules/@nuxt/ui/dist/runtime/components/NavigationMenu.vue')['default']
UPagination: typeof import('./node_modules/@nuxt/ui/dist/runtime/components/Pagination.vue')['default']
USelect: typeof import('./node_modules/@nuxt/ui/dist/runtime/components/Select.vue')['default']
USelectMenu: typeof import('./node_modules/@nuxt/ui/dist/runtime/components/SelectMenu.vue')['default']
diff --git a/bo/src/layouts/default.vue b/bo/src/layouts/default.vue
index 1e86a0a..0705f3e 100644
--- a/bo/src/layouts/default.vue
+++ b/bo/src/layouts/default.vue
@@ -1,14 +1,51 @@
Page not found
+- {{ $t('general.password_reset_link_sent_notice') }} -
-+ {{ $t('general.password_reset_link_sent_notice') }} +
+- {{ $t('general.enter_email_for_password_reset') }} -
-+ {{ $t('general.enter_email_for_password_reset') }} +
+- {{ $t('general.dont_have_an_account') }} -
- {{ $t('general.password_updated_description') }} -
-+ {{ $t('general.password_updated_description') }} +
++ {{ $t('verify_email.success_message') }} +
++ {{ $t('verify_email.error_message') }} +
+{{ $t('verify_email.redirect_message') }}
+{{ $t('verify_email.please_wait') }}
+
+ {{ $t('verify_email.already_registered') }}
+
- {{ $t('verify_email.success_message') }} -
-- {{ $t('verify_email.error_message') }} -
-{{ $t('verify_email.redirect_message') }}
-{{ $t('verify_email.please_wait') }}
-
- {{ $t('verify_email.already_registered') }}
-