Skip to content

Commit

Permalink
refactor , bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abbasfisal committed Dec 22, 2024
1 parent e8cb6c1 commit d1410c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions internal/modules/admin/repositories/order/order_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 := ""

Expand All @@ -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
}

Expand Down
4 changes: 1 addition & 3 deletions internal/modules/admin/services/order/order_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down

0 comments on commit d1410c6

Please sign in to comment.