feat(warehouse): Enhance Warehouse entity and DTO to include Zonas and Aisles details in responses
Deploy Application / deploy (push) Successful in 25s
Details
Deploy Application / deploy (push) Successful in 25s
Details
This commit is contained in:
parent
3d638530eb
commit
46706e655a
|
|
@ -15,6 +15,7 @@ type MWarehouseEntity struct {
|
||||||
|
|
||||||
Client M_Client `gorm:"foreignKey:ClientID;references:ID"`
|
Client M_Client `gorm:"foreignKey:ClientID;references:ID"`
|
||||||
PIC M_User `gorm:"foreignKey:PICID;references:ID"`
|
PIC M_User `gorm:"foreignKey:PICID;references:ID"`
|
||||||
|
Zonas []MZonaEntity `gorm:"foreignKey:WarehouseID;references:ID"`
|
||||||
|
|
||||||
FullAuditTrail
|
FullAuditTrail
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ type MZonaEntity struct {
|
||||||
|
|
||||||
Warehouse MWarehouseEntity `gorm:"foreignKey:WarehouseID;references:ID"`
|
Warehouse MWarehouseEntity `gorm:"foreignKey:WarehouseID;references:ID"`
|
||||||
Client M_Client `gorm:"foreignKey:ClientID;references:ID"`
|
Client M_Client `gorm:"foreignKey:ClientID;references:ID"`
|
||||||
|
Aisles []MAisleEntity `gorm:"foreignKey:ZoneID;references:ID"`
|
||||||
|
|
||||||
FullAuditTrail
|
FullAuditTrail
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,4 +54,37 @@ type WarehouseResponse struct {
|
||||||
DissallowNegativeInventory bool `json:"dissallow_negative_inventory"`
|
DissallowNegativeInventory bool `json:"dissallow_negative_inventory"`
|
||||||
Client pkgdto.IdNameResponse `json:"client"`
|
Client pkgdto.IdNameResponse `json:"client"`
|
||||||
PIC *pkgdto.IdNameResponse `json:"pic"`
|
PIC *pkgdto.IdNameResponse `json:"pic"`
|
||||||
|
Zonas []WarehouseZonaResponse `json:"zones"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WarehouseZonaResponse struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Temperature string `json:"temperature"`
|
||||||
|
Hazardous bool `json:"hazardous"`
|
||||||
|
QRCodeZone string `json:"qr_code_zone"`
|
||||||
|
IsActive bool `json:"is_active"`
|
||||||
|
Client pkgdto.IdNameResponse `json:"client"`
|
||||||
|
Aisles []ZonaAisleResponse `json:"aisles"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZonaAisleResponse struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
IsleX string `json:"isle_x"`
|
||||||
|
BinY string `json:"bin_y"`
|
||||||
|
LevelZ string `json:"level_z"`
|
||||||
|
DimLength string `json:"dim_length"`
|
||||||
|
DimWidth string `json:"dim_width"`
|
||||||
|
DimHeight string `json:"dim_height"`
|
||||||
|
Weight string `json:"weight"`
|
||||||
|
QrCodeAisle string `json:"qr_code_aisle"`
|
||||||
|
IsActive bool `json:"is_active"`
|
||||||
|
Zone pkgdto.IdNameResponse `json:"zone"`
|
||||||
|
DimUom pkgdto.IdNameResponse `json:"dim_uom_id"`
|
||||||
|
WeightUom pkgdto.IdNameResponse `json:"weight_uom_id"`
|
||||||
|
Client pkgdto.IdNameResponse `json:"client_id"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,13 @@ func (r *warehouseRepository) GetById(ctx context.Context, tx *gorm.DB, warehous
|
||||||
if err := tx.WithContext(ctx).
|
if err := tx.WithContext(ctx).
|
||||||
Preload("Client").
|
Preload("Client").
|
||||||
Preload("PIC").
|
Preload("PIC").
|
||||||
|
Preload("Zonas").
|
||||||
|
Preload("Zonas.Client").
|
||||||
|
Preload("Zonas.Aisles").
|
||||||
|
Preload("Zonas.Aisles.Client").
|
||||||
|
Preload("Zonas.Aisles.Zona").
|
||||||
|
Preload("Zonas.Aisles.DimUom").
|
||||||
|
Preload("Zonas.Aisles.WeightUom").
|
||||||
First(&warehouse, "id = ?", warehouseId).Error; err != nil {
|
First(&warehouse, "id = ?", warehouseId).Error; err != nil {
|
||||||
return warehouse, err
|
return warehouse, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,57 @@ func toWarehouseResponse(e entities.MWarehouseEntity) dtodomain.WarehouseRespons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zonas := make([]dtodomain.WarehouseZonaResponse, 0)
|
||||||
|
for _, zona := range e.Zonas {
|
||||||
|
zonas = append(zonas, dtodomain.WarehouseZonaResponse{
|
||||||
|
ID: zona.ID.String(),
|
||||||
|
Code: zona.Code,
|
||||||
|
Name: zona.Name,
|
||||||
|
Type: zona.Type,
|
||||||
|
Temperature: zona.Temperature,
|
||||||
|
Hazardous: zona.Hazardous,
|
||||||
|
QRCodeZone: zona.QRCodeZone,
|
||||||
|
IsActive: zona.IsActive,
|
||||||
|
Client: pkgdto.IdNameResponse{
|
||||||
|
ID: zona.Client.ID.String(),
|
||||||
|
Name: zona.Client.Name,
|
||||||
|
},
|
||||||
|
Aisles: make([]dtodomain.ZonaAisleResponse, 0),
|
||||||
|
})
|
||||||
|
for _, aisle := range zona.Aisles {
|
||||||
|
zonas[len(zonas)-1].Aisles = append(zonas[len(zonas)-1].Aisles, dtodomain.ZonaAisleResponse{
|
||||||
|
ID: aisle.ID.String(),
|
||||||
|
Code: aisle.Code,
|
||||||
|
Name: aisle.Name,
|
||||||
|
IsleX: aisle.IsleX,
|
||||||
|
BinY: aisle.BinY,
|
||||||
|
LevelZ: aisle.LevelZ,
|
||||||
|
DimLength: aisle.DimLength,
|
||||||
|
DimWidth: aisle.DimWidth,
|
||||||
|
DimHeight: aisle.DimHeight,
|
||||||
|
Weight: aisle.Weight,
|
||||||
|
QrCodeAisle: aisle.QrCodeAisle,
|
||||||
|
IsActive: aisle.IsActive,
|
||||||
|
Zone: pkgdto.IdNameResponse{
|
||||||
|
ID: aisle.Zona.ID.String(),
|
||||||
|
Name: aisle.Zona.Name,
|
||||||
|
},
|
||||||
|
DimUom: pkgdto.IdNameResponse{
|
||||||
|
ID: aisle.DimUom.ID.String(),
|
||||||
|
Name: aisle.DimUom.Name,
|
||||||
|
},
|
||||||
|
WeightUom: pkgdto.IdNameResponse{
|
||||||
|
ID: aisle.WeightUom.ID.String(),
|
||||||
|
Name: aisle.WeightUom.Name,
|
||||||
|
},
|
||||||
|
Client: pkgdto.IdNameResponse{
|
||||||
|
ID: aisle.Client.ID.String(),
|
||||||
|
Name: aisle.Client.Name,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return dtodomain.WarehouseResponse{
|
return dtodomain.WarehouseResponse{
|
||||||
ID: e.ID.String(),
|
ID: e.ID.String(),
|
||||||
Code: e.Code,
|
Code: e.Code,
|
||||||
|
|
@ -52,6 +103,7 @@ func toWarehouseResponse(e entities.MWarehouseEntity) dtodomain.WarehouseRespons
|
||||||
DissallowNegativeInventory: e.DissallowNegativeInventory,
|
DissallowNegativeInventory: e.DissallowNegativeInventory,
|
||||||
Client: client,
|
Client: client,
|
||||||
PIC: &pic,
|
PIC: &pic,
|
||||||
|
Zonas: zonas,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue