Compare commits
6 Commits
70e0e23ace
...
customer-m
| Author | SHA1 | Date | |
|---|---|---|---|
| 25a04551e1 | |||
| 612e97e76e | |||
| 931840c243 | |||
|
|
d73dad8975 | ||
|
|
7995177fe1 | ||
|
|
f435a8839b |
@@ -3,6 +3,8 @@ package restricted
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"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/localeExtractor"
|
||||
@@ -30,6 +32,7 @@ func MenuHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
r.Get("/get-category-tree", handler.GetCategoryTree)
|
||||
r.Get("/get-breadcrumb", handler.GetBreadcrumb)
|
||||
r.Get("/get-top-menu", handler.GetTopMenu)
|
||||
r.Get("/get-customer-management-menu", middleware.Require(perms.UserReadAny), handler.GetCustomerManagementMenu)
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -119,3 +122,18 @@ func (h *MenuHandler) GetTopMenu(c fiber.Ctx) error {
|
||||
|
||||
return c.JSON(response.Make(&menu, len(menu), i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *MenuHandler) GetCustomerManagementMenu(c fiber.Ctx) error {
|
||||
langId, ok := localeExtractor.GetLangID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
menu, err := h.menuService.GetCustomerManagementMenu(langId)
|
||||
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, len(menu), i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
@@ -73,6 +73,11 @@ var columnMappingListOrders map[string]string = map[string]string{
|
||||
"name": "b2b_customer_orders.name",
|
||||
"country_id": "b2b_customer_orders.country_id",
|
||||
"status": "b2b_customer_orders.status",
|
||||
"base_price": "b2b_customer_orders.base_price",
|
||||
"tax_incl": "b2b_customer_orders.tax_incl",
|
||||
"tax_excl": "b2b_customer_orders.tax_excl",
|
||||
"created_at": "b2b_customer_orders.created_at",
|
||||
"updated_at": "b2b_customer_orders.updated_at",
|
||||
}
|
||||
|
||||
func (h *OrdersHandler) PlaceNewOrder(c fiber.Ctx) error {
|
||||
|
||||
@@ -2,7 +2,7 @@ package model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type B2BTopMenu struct {
|
||||
type B2BMenu struct {
|
||||
MenuID int `gorm:"column:menu_id;primaryKey;autoIncrement" json:"menu_id"`
|
||||
Label json.RawMessage `gorm:"column:label;type:longtext;not null;default:'{}'" json:"label"`
|
||||
ParentID *int `gorm:"column:parent_id;index:FK_b2b_top_menu_parent_id" json:"parent_id,omitempty"`
|
||||
@@ -10,10 +10,22 @@ type B2BTopMenu struct {
|
||||
Active int8 `gorm:"column:active;type:tinyint;not null;default:1" json:"active"`
|
||||
Position int `gorm:"column:position;not null;default:1" json:"position"`
|
||||
|
||||
Parent *B2BTopMenu `gorm:"foreignKey:ParentID;references:MenuID;constraint:OnDelete:RESTRICT,OnUpdate:RESTRICT" json:"parent,omitempty"`
|
||||
Children []*B2BTopMenu `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
Parent *B2BMenu `gorm:"foreignKey:ParentID;references:MenuID;constraint:OnDelete:RESTRICT,OnUpdate:RESTRICT" json:"parent,omitempty"`
|
||||
Children []*B2BMenu `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
}
|
||||
|
||||
type B2BTopMenu struct {
|
||||
B2BMenu
|
||||
}
|
||||
|
||||
func (B2BTopMenu) TableName() string {
|
||||
return "b2b_top_menu"
|
||||
}
|
||||
|
||||
type B2BCustomerManagementMenu struct {
|
||||
B2BMenu
|
||||
}
|
||||
|
||||
func (B2BCustomerManagementMenu) TableName() string {
|
||||
return "b2b_customer_management_menu"
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type CustomerOrder struct {
|
||||
OrderID uint `gorm:"column:order_id;primaryKey;autoIncrement" json:"order_id"`
|
||||
UserID uint `gorm:"column:user_id;not null;index" json:"user_id"`
|
||||
@@ -8,6 +10,11 @@ type CustomerOrder struct {
|
||||
AddressString string `gorm:"column:address_string;not null" json:"address_string"`
|
||||
AddressUnparsed *AddressUnparsed `gorm:"-" json:"address_unparsed"`
|
||||
Status string `gorm:"column:status;size:50;not null" json:"status"`
|
||||
BasePrice float64 `gorm:"column:base_price;type:decimal(10,2);not null" json:"base_price"`
|
||||
TaxIncl float64 `gorm:"column:tax_incl;type:decimal(10,2);not null" json:"tax_incl"`
|
||||
TaxExcl float64 `gorm:"column:tax_excl;type:decimal(10,2);not null" json:"tax_excl"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
|
||||
Products []OrderProduct `gorm:"foreignKey:OrderID;references:OrderID" json:"products"`
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ordersRepo
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"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"
|
||||
@@ -11,7 +13,7 @@ import (
|
||||
type UIOrdersRepo interface {
|
||||
UserHasOrder(user_id uint, order_id uint) (bool, error)
|
||||
Find(user_id uint, p find.Paging, filt *filters.FiltersList) (*find.Found[model.CustomerOrder], error)
|
||||
PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string) error
|
||||
PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, base_price float64, tax_incl float64, tax_excl float64) error
|
||||
ChangeOrderAddress(order_id uint, country_id uint, address_info string) error
|
||||
ChangeOrderStatus(order_id uint, status string) error
|
||||
}
|
||||
@@ -69,7 +71,7 @@ func (repo *OrdersRepo) Find(user_id uint, p find.Paging, filt *filters.FiltersL
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string) error {
|
||||
func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, base_price float64, tax_incl float64, tax_excl float64) error {
|
||||
order := model.CustomerOrder{
|
||||
UserID: cart.UserID,
|
||||
Name: name,
|
||||
@@ -87,6 +89,12 @@ func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, cou
|
||||
})
|
||||
}
|
||||
|
||||
order.CreatedAt = time.Now()
|
||||
order.UpdatedAt = time.Now()
|
||||
order.BasePrice = base_price
|
||||
order.TaxIncl = tax_incl
|
||||
order.TaxExcl = tax_excl
|
||||
|
||||
return db.DB.Create(&order).Error
|
||||
}
|
||||
|
||||
@@ -97,6 +105,7 @@ func (repo *OrdersRepo) ChangeOrderAddress(order_id uint, country_id uint, addre
|
||||
Updates(map[string]interface{}{
|
||||
"country_id": country_id,
|
||||
"address_string": address_info,
|
||||
"updated_at": time.Now(),
|
||||
}).
|
||||
Error
|
||||
}
|
||||
@@ -105,6 +114,9 @@ func (repo *OrdersRepo) ChangeOrderStatus(order_id uint, status string) error {
|
||||
return db.DB.
|
||||
Table("b2b_customer_orders").
|
||||
Where("order_id = ?", order_id).
|
||||
Update("status", status).
|
||||
Updates(map[string]interface{}{
|
||||
"status": status,
|
||||
"updated_at": time.Now(),
|
||||
}).
|
||||
Error
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
type UIRoutesRepo interface {
|
||||
GetRoutes(langId uint, roleId uint) ([]model.Route, error)
|
||||
GetTopMenu(id uint, roleId uint) ([]model.B2BTopMenu, error)
|
||||
GetCustomerManagementMenu(langId uint) ([]model.B2BCustomerManagementMenu, error)
|
||||
}
|
||||
|
||||
type RoutesRepo struct{}
|
||||
@@ -38,10 +39,23 @@ func (p *RoutesRepo) GetTopMenu(langId uint, roleId uint) ([]model.B2BTopMenu, e
|
||||
Get().
|
||||
Model(model.B2BTopMenu{}).
|
||||
Joins("JOIN b2b_top_menu_roles tmr ON tmr.top_menu_id = b2b_top_menu.menu_id").
|
||||
Where(model.B2BTopMenu{Active: 1}).
|
||||
Where(model.B2BTopMenu{B2BMenu: model.B2BMenu{Active: 1}}).
|
||||
Where("tmr.role_id = ?", roleId).
|
||||
Order("b2b_top_menu.parent_id ASC, b2b_top_menu.position ASC").
|
||||
Find(&menus).Error
|
||||
|
||||
return menus, err
|
||||
}
|
||||
|
||||
func (p *RoutesRepo) GetCustomerManagementMenu(langId uint) ([]model.B2BCustomerManagementMenu, error) {
|
||||
var menus []model.B2BCustomerManagementMenu
|
||||
|
||||
err := db.
|
||||
Get().
|
||||
Model(model.B2BCustomerManagementMenu{}).
|
||||
Where(model.B2BCustomerManagementMenu{B2BMenu: model.B2BMenu{Active: 1}}).
|
||||
Order("b2b_customer_management_menu.parent_id ASC, b2b_customer_management_menu.position ASC").
|
||||
Find(&menus).Error
|
||||
|
||||
return menus, err
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ func (s *AuthService) Login(req *model.LoginRequest) (*model.AuthResponse, strin
|
||||
user.LangID = *req.LangID
|
||||
}
|
||||
|
||||
user.Country = nil
|
||||
s.db.Save(&user)
|
||||
|
||||
// Generate access token (JWT)
|
||||
@@ -259,6 +260,7 @@ func (s *AuthService) CompleteRegistration(req *model.CompleteRegistrationReques
|
||||
user.EmailVerificationToken = ""
|
||||
user.EmailVerificationExpires = nil
|
||||
|
||||
user.Country = nil
|
||||
if err := s.db.Save(&user).Error; err != nil {
|
||||
return nil, "", fmt.Errorf("failed to update user: %w", err)
|
||||
}
|
||||
@@ -327,6 +329,7 @@ func (s *AuthService) RequestPasswordReset(emailAddr string) error {
|
||||
user.PasswordResetToken = token
|
||||
user.PasswordResetExpires = &expiresAt
|
||||
user.LastPasswordResetRequest = &now
|
||||
user.Country = nil
|
||||
if err := s.db.Save(&user).Error; err != nil {
|
||||
return fmt.Errorf("failed to save reset token: %w", err)
|
||||
}
|
||||
@@ -381,6 +384,7 @@ func (s *AuthService) ResetPassword(token, newPassword string) error {
|
||||
user.PasswordResetToken = ""
|
||||
user.PasswordResetExpires = nil
|
||||
|
||||
user.Country = nil
|
||||
if err := s.db.Save(&user).Error; err != nil {
|
||||
logger.Error("password reset failed - database error",
|
||||
"service", "AuthService.ResetPassword",
|
||||
@@ -596,6 +600,7 @@ func (s *AuthService) UpdateJWTToken(user *model.Customer) (string, error) {
|
||||
}
|
||||
|
||||
// Save the updated user
|
||||
user.Country = nil
|
||||
if err := s.db.Save(user).Error; err != nil {
|
||||
return "", fmt.Errorf("database error: %w", err)
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ func (s *AuthService) HandleGoogleCallback(code string) (*model.AuthResponse, st
|
||||
// Update last login
|
||||
now := time.Now()
|
||||
user.LastLoginAt = &now
|
||||
user.Country = nil
|
||||
s.db.Save(user)
|
||||
|
||||
// Generate access token (JWT)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
routesRepo "git.ma-al.com/goc_daniel/b2b/app/repos/routesRepo"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/logger"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
)
|
||||
|
||||
@@ -193,18 +194,52 @@ func (s *MenuService) GetBreadcrumb(root_category_id uint, start_category_id uin
|
||||
return breadcrumb, nil
|
||||
}
|
||||
|
||||
func (s *MenuService) GetTopMenu(languageId uint, roleId uint) ([]*model.B2BTopMenu, error) {
|
||||
func (s *MenuService) GetTopMenu(languageId uint, roleId uint) ([]*model.B2BMenu, error) {
|
||||
items, err := s.routesRepo.GetTopMenu(languageId, roleId)
|
||||
if err != nil {
|
||||
logger.Error("failed to get top menu",
|
||||
"handler", "ManuService.GetTopMenu",
|
||||
"language_id", languageId,
|
||||
"role_id", roleId,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
menuMap := make(map[int]*model.B2BTopMenu, len(items))
|
||||
roots := make([]*model.B2BTopMenu, 0)
|
||||
menus := make([]model.B2BMenu, len(items))
|
||||
for i := range items {
|
||||
menus[i] = items[i].B2BMenu
|
||||
}
|
||||
|
||||
return buildMenu(menus), nil
|
||||
}
|
||||
|
||||
func (s *MenuService) GetCustomerManagementMenu(languageId uint) ([]*model.B2BMenu, error) {
|
||||
items, err := s.routesRepo.GetCustomerManagementMenu(languageId)
|
||||
if err != nil {
|
||||
logger.Error("failed to get customer management menu",
|
||||
"handler", "ManuService.GetCustomerManagementMenu",
|
||||
"language_id", languageId,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
menus := make([]model.B2BMenu, len(items))
|
||||
for i := range items {
|
||||
menus[i] = items[i].B2BMenu
|
||||
}
|
||||
|
||||
return buildMenu(menus), nil
|
||||
}
|
||||
|
||||
func buildMenu(items []model.B2BMenu) []*model.B2BMenu {
|
||||
menuMap := make(map[int]*model.B2BMenu, len(items))
|
||||
roots := make([]*model.B2BMenu, 0)
|
||||
|
||||
for i := range items {
|
||||
menu := &items[i]
|
||||
menu.Children = make([]*model.B2BTopMenu, 0)
|
||||
menu.Children = make([]*model.B2BMenu, 0)
|
||||
menuMap[menu.MenuID] = menu
|
||||
}
|
||||
|
||||
@@ -226,7 +261,7 @@ func (s *MenuService) GetTopMenu(languageId uint, roleId uint) ([]*model.B2BTopM
|
||||
parent.Children = append(parent.Children, menu)
|
||||
}
|
||||
|
||||
return roots, nil
|
||||
return roots
|
||||
}
|
||||
|
||||
func (s *MenuService) appendAdditional(all_categories *[]model.ScannedCategory, id_lang uint, iso_code string) {
|
||||
|
||||
@@ -7,8 +7,10 @@ import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/repos/cartsRepo"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/repos/ordersRepo"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/repos/productsRepo"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/addressesService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/emailService"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/logger"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/filters"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/find"
|
||||
@@ -18,6 +20,7 @@ import (
|
||||
type OrderService struct {
|
||||
ordersRepo ordersRepo.UIOrdersRepo
|
||||
cartsRepo cartsRepo.UICartsRepo
|
||||
productsRepo productsRepo.UIProductsRepo
|
||||
addressesService *addressesService.AddressesService
|
||||
emailService *emailService.EmailService
|
||||
}
|
||||
@@ -26,6 +29,7 @@ func New() *OrderService {
|
||||
return &OrderService{
|
||||
ordersRepo: ordersRepo.New(),
|
||||
cartsRepo: cartsRepo.New(),
|
||||
productsRepo: productsRepo.New(),
|
||||
addressesService: addressesService.New(),
|
||||
emailService: emailService.NewEmailService(),
|
||||
}
|
||||
@@ -85,8 +89,10 @@ func (s *OrderService) PlaceNewOrder(user_id uint, cart_id uint, name string, co
|
||||
name = *cart.Name
|
||||
}
|
||||
|
||||
base_price, tax_incl, tax_excl, err := s.getOrderTotalPrice(user_id, cart_id, country_id)
|
||||
|
||||
// all checks passed
|
||||
err = s.ordersRepo.PlaceNewOrder(cart, name, country_id, address_info)
|
||||
err = s.ordersRepo.PlaceNewOrder(cart, name, country_id, address_info, base_price, tax_incl, tax_excl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -153,3 +159,27 @@ func (s *OrderService) ChangeOrderStatus(user *model.Customer, order_id uint, st
|
||||
|
||||
return s.ordersRepo.ChangeOrderStatus(order_id, status)
|
||||
}
|
||||
|
||||
func (s *OrderService) getOrderTotalPrice(user_id uint, cart_id uint, country_id uint) (float64, float64, float64, error) {
|
||||
cart, err := s.cartsRepo.RetrieveCart(user_id, cart_id)
|
||||
if err != nil {
|
||||
return 0.0, 0.0, 0.0, err
|
||||
}
|
||||
|
||||
base_price := 0.0
|
||||
tax_incl := 0.0
|
||||
tax_excl := 0.0
|
||||
|
||||
for _, product := range cart.Products {
|
||||
prices, err := s.productsRepo.GetPrice(product.ProductID, product.ProductAttributeID, constdata.SHOP_ID, user_id, country_id, product.Amount)
|
||||
if err != nil {
|
||||
return 0.0, 0.0, 0.0, err
|
||||
}
|
||||
|
||||
base_price += prices.Base
|
||||
tax_incl += prices.FinalTaxIncl
|
||||
tax_excl += prices.FinalTaxExcl
|
||||
}
|
||||
|
||||
return base_price, tax_incl, tax_excl, nil
|
||||
}
|
||||
|
||||
22
bruno/api_v1/menu/Breadcrumb.yml
Normal file
22
bruno/api_v1/menu/Breadcrumb.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
info:
|
||||
name: Breadcrumb
|
||||
type: http
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/api/v1/restricted/menu/get-breadcrumb?root_category_id=2&category_id=13
|
||||
params:
|
||||
- name: root_category_id
|
||||
value: "2"
|
||||
type: query
|
||||
- name: category_id
|
||||
value: "13"
|
||||
type: query
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
19
bruno/api_v1/menu/Category tree.yml
Normal file
19
bruno/api_v1/menu/Category tree.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
info:
|
||||
name: Category tree
|
||||
type: http
|
||||
seq: 2
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/api/v1/restricted/menu/get-category-tree?root_category_id=2
|
||||
params:
|
||||
- name: root_category_id
|
||||
value: "2"
|
||||
type: query
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
15
bruno/api_v1/menu/Top Customer Management Menu.yml
Normal file
15
bruno/api_v1/menu/Top Customer Management Menu.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
info:
|
||||
name: Top Customer Management Menu
|
||||
type: http
|
||||
seq: 4
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: "{{bas_url}}/restricted/menu/get-customer-management-menu"
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
15
bruno/api_v1/menu/Top Menu.yml
Normal file
15
bruno/api_v1/menu/Top Menu.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
info:
|
||||
name: Top Menu
|
||||
type: http
|
||||
seq: 3
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: "{{bas_url}}/restricted/menu/get-top-menu"
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
7
bruno/api_v1/menu/folder.yml
Normal file
7
bruno/api_v1/menu/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
info:
|
||||
name: menu
|
||||
type: folder
|
||||
seq: 12
|
||||
|
||||
request:
|
||||
auth: inherit
|
||||
@@ -5,15 +5,14 @@ info:
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: http://localhost:3000/api/v1/public/auth/update-choice?lang_id=0&country_id=1
|
||||
url: http://localhost:3000/api/v1/public/auth/update-choice?lang_id=1&country_id=1
|
||||
params:
|
||||
- name: lang_id
|
||||
value: "0"
|
||||
value: "1"
|
||||
type: query
|
||||
- name: country_id
|
||||
value: "1"
|
||||
type: query
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
|
||||
@@ -5,7 +5,7 @@ info:
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/api/v1/restricted/carts/add-product-to-cart?cart_id=1&product_id=51&product_attribute_id=1115&amount=1&set_amount=true
|
||||
url: http://localhost:3000/api/v1/restricted/carts/add-product-to-cart?cart_id=1&product_id=51&product_attribute_id=1115&amount=2&set_amount=true
|
||||
params:
|
||||
- name: cart_id
|
||||
value: "1"
|
||||
@@ -17,7 +17,7 @@ http:
|
||||
value: "1115"
|
||||
type: query
|
||||
- name: amount
|
||||
value: "1"
|
||||
value: "2"
|
||||
type: query
|
||||
- name: set_amount
|
||||
value: "true"
|
||||
|
||||
@@ -42,9 +42,32 @@ INSERT IGNORE INTO `b2b_top_menu` (`menu_id`, `label`, `parent_id`, `params`, `a
|
||||
(3, JSON_COMPACT('{"name":"admin-products","trans":{"pl":{"label":"admin-products"},"en":{"label":"admin-products"},"de":{"label":"admin-products"}}}'),1,JSON_COMPACT('{}'),1,1),
|
||||
(9, JSON_COMPACT('{"name":"carts","trans":{"pl":{"label":"Koszyki"},"en":{"label":"Carts"},"de":{"label":"Warenkörbe"}}}'),3,JSON_COMPACT('{"route": {"name": "home", "params":{"locale": ""}}}'),1,1);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS b2b_customer_management_menu (
|
||||
menu_id INT AUTO_INCREMENT NOT NULL,
|
||||
label LONGTEXT NOT NULL DEFAULT '{}',
|
||||
parent_id INT NULL DEFAULT NULL,
|
||||
params LONGTEXT NOT NULL DEFAULT '{}',
|
||||
active TINYINT NOT NULL DEFAULT 1,
|
||||
position INT NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (menu_id),
|
||||
CONSTRAINT FK_b2b_customer_management_menu_parent_id FOREIGN KEY (parent_id)
|
||||
REFERENCES b2b_customer_management_menu (menu_id)
|
||||
ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
INDEX FK_b2b_customer_management_menu_parent_id_idx (parent_id ASC)
|
||||
) ENGINE = InnoDB;
|
||||
|
||||
INSERT IGNORE INTO `b2b_customer_management_menu` (`menu_id`, `label`, `parent_id`, `params`, `active`, `position`) VALUES
|
||||
(1, JSON_COMPACT('{"name":"root","trans":{"pl":{"label":"Menu główne"},"en":{"label":"Main Menu"},"de":{"label":"Hauptmenü"}}}'),NULL,JSON_COMPACT('{}'),1,1),
|
||||
(3, JSON_COMPACT('{"name":"admin-products","trans":{"pl":{"label":"admin-products"},"en":{"label":"admin-products"},"de":{"label":"admin-products"}}}'),1,JSON_COMPACT('{}'),1,1),
|
||||
(9, JSON_COMPACT('{"name":"carts","trans":{"pl":{"label":"Koszyki"},"en":{"label":"Carts"},"de":{"label":"Warenkörbe"}}}'),3,JSON_COMPACT('{"route": {"name": "home", "params":{"locale": ""}}}'),1,1);
|
||||
|
||||
INSERT INTO `b2b_customer_management_menu` (`menu_id`, `label`, `parent_id`, `params`, `active`, `position`) VALUES (1, '{"name":"root","trans":{"pl":{"label":"Menu główne"},"en":{"label":"Main Menu"},"de":{"label":"Hauptmenü"}}}', NULL, '{}', 1, 1);
|
||||
INSERT INTO `b2b_customer_management_menu` (`menu_id`, `label`, `parent_id`, `params`, `active`, `position`) VALUES (3, '{"name":"admin-products","trans":{"pl":{"label":"admin-products"},"en":{"label":"admin-products"},"de":{"label":"admin-products"}}}', 1, '{}', 1, 1);
|
||||
INSERT INTO `b2b_customer_management_menu` (`menu_id`, `label`, `parent_id`, `params`, `active`, `position`) VALUES (9, '{"name":"carts","trans":{"pl":{"label":"Koszyki"},"en":{"label":"Carts"},"de":{"label":"Warenkörbe"}}}', 3, '{"route":{"name":"home","params":{"locale":""}}}', 1, 1);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
DROP TABLE IF EXISTS b2b_routes;
|
||||
DROP TABLE IF EXISTS b2b_top_menu;
|
||||
DROP TABLE IF EXISTS b2b_customer_management_menu;
|
||||
DROP FUNCTION IF EXISTS `slugify_eu`;
|
||||
|
||||
@@ -251,6 +251,11 @@ CREATE TABLE IF NOT EXISTS b2b_customer_orders (
|
||||
country_id BIGINT UNSIGNED NOT NULL,
|
||||
address_string TEXT NOT NULL,
|
||||
status VARCHAR(50) NOT NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
updated_at DATETIME NOT NULL,
|
||||
base_price DECIMAL(10, 2) NOT NULL,
|
||||
tax_incl DECIMAL(10, 2) NOT NULL,
|
||||
tax_excl DECIMAL(10, 2) NOT NULL,
|
||||
CONSTRAINT fk_customer_orders_customers FOREIGN KEY (user_id) REFERENCES b2b_customers(id) ON DELETE NO ACTION ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_customer_orders_countries FOREIGN KEY (country_id) REFERENCES b2b_countries(id) ON DELETE NO ACTION ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
|
||||
|
||||
@@ -12,6 +12,19 @@ INSERT INTO `b2b_roles` (`name`, `id`) VALUES ('admin','2');
|
||||
INSERT INTO `b2b_roles` (`name`, `id`) VALUES ('super_admin','3');
|
||||
INSERT INTO `b2b_roles` (`name`, `id`) VALUES ('unlogged','4');
|
||||
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (1, '1');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (3, '1');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (9, '1');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (1, '2');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (3, '2');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (9, '2');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (1, '3');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (3, '3');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (9, '3');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (1, '4');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (3, '4');
|
||||
INSERT INTO `b2b_top_menu_roles` (`top_menu_id`, `role_id`) VALUES (9, '4');
|
||||
|
||||
|
||||
-- insert sample admin user admin@ma-al.com/Maal12345678
|
||||
INSERT IGNORE INTO b2b_customers (id, email, password, first_name, last_name, role_id, provider, provider_id, avatar_url, is_active, email_verified, email_verification_token, email_verification_expires, password_reset_token, password_reset_expires, last_password_reset_request, last_login_at, lang_id, country_id, created_at, updated_at, deleted_at)
|
||||
|
||||
@@ -415,7 +415,7 @@ BEGIN
|
||||
LEFT JOIN ps_manufacturer m
|
||||
ON m.id_manufacturer = p.id_manufacturer
|
||||
LEFT JOIN ps_configuration
|
||||
ON ps_configuration.name = PS_NB_DAYS_NEW_PRODUCT
|
||||
ON ps_configuration.name = 'PS_NB_DAYS_NEW_PRODUCT'
|
||||
|
||||
WHERE p.id_product = p_id_product
|
||||
LIMIT 1;
|
||||
|
||||
Reference in New Issue
Block a user