feat: update InventoryMovement entity and service to use pointer UUIDs for location, zone, and aisle fields
Deploy Application / deploy (push) Successful in 19s
Details
Deploy Application / deploy (push) Successful in 19s
Details
This commit is contained in:
parent
abd8780191
commit
92c5ca68d1
|
|
@ -16,13 +16,13 @@ type TInventoryMovementEntity struct {
|
|||
MovementType string `gorm:"type:varchar(50);" json:"movement_type"`
|
||||
Status string `gorm:"type:varchar(50);default:'draft'" json:"status"`
|
||||
|
||||
ClientID uuid.UUID `gorm:"type:uuid;index;" json:"client_id"`
|
||||
SourceLocationID uuid.UUID `gorm:"type:uuid;index;" json:"source_location_id"`
|
||||
DestinationLocationID uuid.UUID `gorm:"type:uuid;index;" json:"destination_location_id"`
|
||||
SourceZoneID uuid.UUID `gorm:"type:uuid;index;" json:"source_zone_id"`
|
||||
DestinationZoneID uuid.UUID `gorm:"type:uuid;index;" json:"destination_zone_id"`
|
||||
SourceAisleID uuid.UUID `gorm:"type:uuid;index;" json:"source_aisle_id"`
|
||||
DestinationAisleID uuid.UUID `gorm:"type:uuid;index;" json:"destination_aisle_id"`
|
||||
ClientID uuid.UUID `gorm:"type:uuid;index;" json:"client_id"`
|
||||
SourceLocationID *uuid.UUID `gorm:"type:uuid;index;" json:"source_location_id"`
|
||||
DestinationLocationID *uuid.UUID `gorm:"type:uuid;index;" json:"destination_location_id"`
|
||||
SourceZoneID *uuid.UUID `gorm:"type:uuid;index;" json:"source_zone_id"`
|
||||
DestinationZoneID *uuid.UUID `gorm:"type:uuid;index;" json:"destination_zone_id"`
|
||||
SourceAisleID *uuid.UUID `gorm:"type:uuid;index;" json:"source_aisle_id"`
|
||||
DestinationAisleID *uuid.UUID `gorm:"type:uuid;index;" json:"destination_aisle_id"`
|
||||
|
||||
MovementLines []TInventoryMovementLineEntity `gorm:"foreignKey:InvMovementID;references:ID"`
|
||||
SourceLocation MWarehouseEntity `gorm:"foreignKey:SourceLocationID;references:ID"`
|
||||
|
|
|
|||
|
|
@ -86,36 +86,29 @@ type InventoryMovementLineResponse struct {
|
|||
}
|
||||
|
||||
func ToInventoryMovementResponse(e entities.TInventoryMovementEntity) InventoryMovementResponse {
|
||||
// prepare pointer strings for fields that are *string in the response
|
||||
var srcLocationID *string
|
||||
var dstLocationID *string
|
||||
var srcZoneID *string
|
||||
var dstZoneID *string
|
||||
var srcAisleID *string
|
||||
var dstAisleID *string
|
||||
var srcLocationID, dstLocationID, srcZoneID, dstZoneID, srcAisleID, dstAisleID *string
|
||||
|
||||
// populate pointers from the entity's values
|
||||
{
|
||||
if e.SourceLocationID != nil {
|
||||
v := e.SourceLocationID.String()
|
||||
srcLocationID = &v
|
||||
}
|
||||
{
|
||||
if e.DestinationLocationID != nil {
|
||||
v := e.DestinationLocationID.String()
|
||||
dstLocationID = &v
|
||||
}
|
||||
{
|
||||
if e.SourceZoneID != nil {
|
||||
v := e.SourceZoneID.String()
|
||||
srcZoneID = &v
|
||||
}
|
||||
{
|
||||
if e.DestinationZoneID != nil {
|
||||
v := e.DestinationZoneID.String()
|
||||
dstZoneID = &v
|
||||
}
|
||||
{
|
||||
if e.SourceAisleID != nil {
|
||||
v := e.SourceAisleID.String()
|
||||
srcAisleID = &v
|
||||
}
|
||||
{
|
||||
if e.DestinationAisleID != nil {
|
||||
v := e.DestinationAisleID.String()
|
||||
dstAisleID = &v
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,25 +78,30 @@ func (s *inventoryMovementService) Create(ctx context.Context, req dtodomain.Inv
|
|||
tx.Rollback()
|
||||
return dtodomain.InventoryMovementResponse{}, err
|
||||
}
|
||||
|
||||
var sourceLocationID, destinationLocationID, sourceZoneID, destinationZoneID, sourceAisleID, destinationAisleID uuid.UUID
|
||||
var sourceLocationID, destinationLocationID, sourceZoneID, destinationZoneID, sourceAisleID, destinationAisleID *uuid.UUID
|
||||
if req.SourceLocationID != nil {
|
||||
sourceLocationID = uuid.MustParse(*req.SourceLocationID)
|
||||
tmp := uuid.MustParse(*req.SourceLocationID)
|
||||
sourceLocationID = &tmp
|
||||
}
|
||||
if req.DestinationLocationID != nil {
|
||||
destinationLocationID = uuid.MustParse(*req.DestinationLocationID)
|
||||
tmp := uuid.MustParse(*req.DestinationLocationID)
|
||||
destinationLocationID = &tmp
|
||||
}
|
||||
if req.SourceZoneID != nil {
|
||||
sourceZoneID = uuid.MustParse(*req.SourceZoneID)
|
||||
tmp := uuid.MustParse(*req.SourceZoneID)
|
||||
sourceZoneID = &tmp
|
||||
}
|
||||
if req.DestinationZoneID != nil {
|
||||
destinationZoneID = uuid.MustParse(*req.DestinationZoneID)
|
||||
tmp := uuid.MustParse(*req.DestinationZoneID)
|
||||
destinationZoneID = &tmp
|
||||
}
|
||||
if req.SourceAisleID != nil {
|
||||
sourceAisleID = uuid.MustParse(*req.SourceAisleID)
|
||||
tmp := uuid.MustParse(*req.SourceAisleID)
|
||||
sourceAisleID = &tmp
|
||||
}
|
||||
if req.DestinationAisleID != nil {
|
||||
destinationAisleID = uuid.MustParse(*req.DestinationAisleID)
|
||||
tmp := uuid.MustParse(*req.DestinationAisleID)
|
||||
destinationAisleID = &tmp
|
||||
}
|
||||
|
||||
movement := entities.TInventoryMovementEntity{
|
||||
|
|
|
|||
Loading…
Reference in New Issue