mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat(BE): add product flags to product warehouse response
This commit is contained in:
@@ -34,6 +34,7 @@ type ProductBaseDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Sku string `json:"sku"`
|
||||
Flags []string `json:"flags"`
|
||||
}
|
||||
|
||||
type WarehouseBaseDTO struct {
|
||||
@@ -68,6 +69,12 @@ func ToProductWarehouseListDTO(e entity.ProductWarehouse) ProductWarehouseListDT
|
||||
if e.Product.Sku != nil {
|
||||
product.Sku = *e.Product.Sku
|
||||
}
|
||||
// Map flags from Product relation
|
||||
if len(e.Product.Flags) > 0 {
|
||||
for _, f := range e.Product.Flags {
|
||||
product.Flags = append(product.Flags, f.Name)
|
||||
}
|
||||
}
|
||||
dto.Product = &product
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func NewProductWarehouseService(repo repository.ProductWarehouseRepository, vali
|
||||
}
|
||||
|
||||
func (s productWarehouseService) withRelations(db *gorm.DB) *gorm.DB {
|
||||
return db.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) {
|
||||
|
||||
Reference in New Issue
Block a user