basic setup
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/orderService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
@@ -13,10 +14,15 @@ import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type OrdersHandler struct{}
|
||||
type OrdersHandler struct {
|
||||
ordersService *orderService.OrderService
|
||||
}
|
||||
|
||||
func NewOrdersHandler() *OrdersHandler {
|
||||
return &OrdersHandler{}
|
||||
ordersService := orderService.New()
|
||||
return &OrdersHandler{
|
||||
ordersService: ordersService,
|
||||
}
|
||||
}
|
||||
|
||||
func OrdersHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
@@ -83,7 +89,7 @@ func (h *OrdersHandler) PlaceNewOrder(c fiber.Ctx) error {
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.ordersService.PlaceNewOrder(userID, cart_id, country_id, address_info)
|
||||
err = h.ordersService.PlaceNewOrder(userID, uint(cart_id), uint(country_id), address_info)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
@@ -115,7 +121,7 @@ func (h *OrdersHandler) ChangeOrderAddress(c fiber.Ctx) error {
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.ordersService.ChangeOrderAddress(user, order_id, country_id, address_info)
|
||||
err = h.ordersService.ChangeOrderAddress(user, uint(order_id), uint(country_id), address_info)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
@@ -141,7 +147,7 @@ func (h *OrdersHandler) ChangeOrderStatus(c fiber.Ctx) error {
|
||||
|
||||
status := c.Query("status")
|
||||
|
||||
err = h.ordersService.ChangeOrderStatus(user, order_id, status)
|
||||
err = h.ordersService.ChangeOrderStatus(user, uint(order_id), status)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
|
||||
36
app/repos/ordersRepo/ordersRepo.go
Normal file
36
app/repos/ordersRepo/ordersRepo.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package ordersRepo
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/filters"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/find"
|
||||
)
|
||||
|
||||
type UIOrdersRepo interface {
|
||||
Find(user_id uint, p find.Paging, filt *filters.FiltersList) (find.Found[model.CustomerOrder], error)
|
||||
PlaceNewOrder(user_id uint, cart_id uint, country_id uint, address_info string) error
|
||||
ChangeOrderAddress(user_id uint, order_id uint, country_id uint, address_info string) error
|
||||
ChangeOrderStatus(user_id uint, order_id uint, status string) error
|
||||
}
|
||||
|
||||
type OrdersRepo struct{}
|
||||
|
||||
func New() UIOrdersRepo {
|
||||
return &OrdersRepo{}
|
||||
}
|
||||
|
||||
func (repo *OrdersRepo) Find(user_id uint, p find.Paging, filt *filters.FiltersList) (find.Found[model.CustomerOrder], error) {
|
||||
return find.Found[model.CustomerOrder]{}, nil
|
||||
}
|
||||
|
||||
func (repo *OrdersRepo) PlaceNewOrder(user_id uint, cart_id uint, country_id uint, address_info string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *OrdersRepo) ChangeOrderAddress(user_id uint, order_id uint, country_id uint, address_info string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *OrdersRepo) ChangeOrderStatus(user_id uint, order_id uint, status string) error {
|
||||
return nil
|
||||
}
|
||||
34
app/service/orderService/orderService.go
Normal file
34
app/service/orderService/orderService.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package orderService
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/repos/ordersRepo"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/filters"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/find"
|
||||
)
|
||||
|
||||
type OrderService struct {
|
||||
ordersRepo ordersRepo.UIOrdersRepo
|
||||
}
|
||||
|
||||
func New() *OrderService {
|
||||
return &OrderService{
|
||||
ordersRepo: ordersRepo.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *OrderService) Find(user *model.Customer, p find.Paging, filt *filters.FiltersList) (find.Found[model.CustomerOrder], error) {
|
||||
return s.ordersRepo.Find(user.ID, p, filt)
|
||||
}
|
||||
|
||||
func (s *OrderService) PlaceNewOrder(user_id uint, cart_id uint, country_id uint, address_info string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *OrderService) ChangeOrderAddress(user *model.Customer, order_id uint, country_id uint, address_info string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *OrderService) ChangeOrderStatus(user *model.Customer, order_id uint, status string) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user