diff --git a/internal/modules/admin/repositories/order/order_repository.go b/internal/modules/admin/repositories/order/order_repository.go index cac5614..8f53186 100644 --- a/internal/modules/admin/repositories/order/order_repository.go +++ b/internal/modules/admin/repositories/order/order_repository.go @@ -6,6 +6,7 @@ import ( "gorm.io/gorm" "shop/internal/entities" "shop/internal/modules/admin/requests" + "shop/internal/modules/admin/responses" "shop/internal/pkg/pagination" "strconv" "strings" @@ -43,7 +44,7 @@ func (oRepo *OrderRepository) GetOrders(c *gin.Context) (pagination.Pagination, Page: page, } - var orders []entities.Order + var orders []*entities.Order //condition := fmt.Sprintf("customer_id=%d", customer.ID) condition := "" @@ -58,7 +59,7 @@ func (oRepo *OrderRepository) GetOrders(c *gin.Context) (pagination.Pagination, return pg, pErr } - pg.Rows = orders + pg.Rows = responses.ToOrders(orders) return pg, nil } diff --git a/internal/modules/admin/services/order/order_service.go b/internal/modules/admin/services/order/order_service.go index a434435..5915681 100644 --- a/internal/modules/admin/services/order/order_service.go +++ b/internal/modules/admin/services/order/order_service.go @@ -2,7 +2,6 @@ package order import ( "github.com/gin-gonic/gin" - "shop/internal/entities" "shop/internal/modules/admin/repositories/order" "shop/internal/modules/admin/requests" "shop/internal/modules/admin/responses" @@ -20,11 +19,10 @@ func NewOrderService(repo order.OrderRepositoryInterface) OrderServiceInterface func (o OrderService) GetOrderPaginate(c *gin.Context) (pagination.Pagination, error) { orderList, err := o.repo.GetOrders(c) - if err != nil { + if err != nil || orderList.Rows == nil { return pagination.Pagination{}, err } - orderList.Rows = responses.ToOrders(orderList.Rows.([]*entities.Order)) return orderList, nil }