mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 15:55:44 +00:00
fix(BE): add missing product json in transfer get all & support flag param filter in product warehouses
This commit is contained in:
+11
-1
@@ -34,7 +34,11 @@ func NewProductWarehouseService(repo repository.ProductWarehouseRepository, vali
|
||||
}
|
||||
|
||||
func (s productWarehouseService) withRelations(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("Product.Flags").Preload("Product").Preload("Warehouse").Preload("CreatedUser")
|
||||
return db.
|
||||
Preload("Product.Flags").
|
||||
Preload("Product").
|
||||
Preload("Warehouse").
|
||||
Preload("CreatedUser")
|
||||
}
|
||||
|
||||
func (s productWarehouseService) GetAll(c *fiber.Ctx, params *validation.Query) ([]entity.ProductWarehouse, int64, error) {
|
||||
@@ -55,6 +59,12 @@ func (s productWarehouseService) GetAll(c *fiber.Ctx, params *validation.Query)
|
||||
db = db.Where("warehouse_id = ?", params.WarehouseId)
|
||||
}
|
||||
|
||||
if params.Flag != "" {
|
||||
db = db.Joins("JOIN products ON products.id = product_warehouses.product_id")
|
||||
db = db.Joins("JOIN flags ON flags.flagable_id = products.id AND flags.flagable_type = ?", "products")
|
||||
db = db.Where("flags.name = ?", params.Flag)
|
||||
}
|
||||
|
||||
return db.Order("created_at DESC").Order("updated_at DESC")
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user