Add refund order

This commit is contained in:
aditya.siregar
2025-06-14 21:17:13 +07:00
parent 58d3b32c40
commit ebb33186b8
42 changed files with 1152 additions and 2094 deletions
+8 -4
View File
@@ -38,7 +38,7 @@ func (b *ProductRepository) UpdateProduct(ctx context.Context, product *entity.P
func (b *ProductRepository) GetProductByID(ctx context.Context, id int64) (*entity.ProductDB, error) {
product := new(entity.ProductDB)
if err := b.db.First(product, id).Error; err != nil {
if err := b.db.Preload("Category").First(product, id).Error; err != nil {
logger.ContextLogger(ctx).Error("error when get by id product", zap.Error(err))
return nil, err
}
@@ -84,8 +84,12 @@ func (b *ProductRepository) GetAllProducts(ctx context.Context, req entity.Produ
query = query.Where("type = ? ", req.Type)
}
if req.BranchID > 0 {
query = query.Where("branch_id = ? ", req.BranchID)
if req.CategoryID > 0 {
query = query.Where("category_id = ? ", req.CategoryID)
}
if req.PartnerID > 0 {
query = query.Where("partner_id = ? ", req.PartnerID)
}
if req.Limit > 0 {
@@ -96,7 +100,7 @@ func (b *ProductRepository) GetAllProducts(ctx context.Context, req entity.Produ
query = query.Offset(req.Offset)
}
if err := query.Find(&products).Error; err != nil {
if err := query.Preload("Category").Find(&products).Order("id ASC").Error; err != nil {
logger.ContextLogger(ctx).Error("error when get all products", zap.Error(err))
return nil, 0, err
}