From ff8cd07e9c3b3af3055e9ecc75b5eaac7359d593 Mon Sep 17 00:00:00 2001 From: Habib Fatkhul Rohman Date: Thu, 20 Nov 2025 14:38:54 +0700 Subject: [PATCH] feat: update InventoryMovementResponse to include client details and modify client ID retrieval in WarehouseController --- .../dto/inventory_movement_dto.go | 19 ++++++++++--------- .../controller/warehouse_controller.go | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/inventory_movement/dto/inventory_movement_dto.go b/modules/inventory_movement/dto/inventory_movement_dto.go index 3b6622e..46f938b 100644 --- a/modules/inventory_movement/dto/inventory_movement_dto.go +++ b/modules/inventory_movement/dto/inventory_movement_dto.go @@ -2,6 +2,7 @@ package dto import ( "github.com/Caknoooo/go-gin-clean-starter/database/entities" + pkgdto "github.com/Caknoooo/go-gin-clean-starter/pkg/dto" "github.com/Caknoooo/go-gin-clean-starter/pkg/utils" ) @@ -55,14 +56,14 @@ type InventoryMovementLineUpdateRequest struct { } type InventoryMovementResponse struct { - ID string `json:"id"` - MovementNumber string `json:"movement_number"` - MovementDate string `json:"movement_date"` - MovementType string `json:"movement_type"` - Status string `json:"status"` - ClientID string `json:"client_id"` - SourceLocationID string `json:"source_location_id"` - DestinationLocationID string `json:"destination_location_id"` + ID string `json:"id"` + MovementNumber string `json:"movement_number"` + MovementDate string `json:"movement_date"` + MovementType string `json:"movement_type"` + Status string `json:"status"` + Client pkgdto.IdNameResponse `json:"client"` + SourceLocationID string `json:"source_location_id"` + DestinationLocationID string `json:"destination_location_id"` } type InventoryMovementLineResponse struct { @@ -81,7 +82,7 @@ func ToInventoryMovementResponse(e entities.TInventoryMovementEntity) InventoryM MovementDate: utils.DateTimeToString(e.MovementDate), MovementType: e.MovementType, Status: e.Status, - ClientID: e.ClientID.String(), + Client: pkgdto.IdNameResponse{ID: e.Client.ID.String(), Name: e.Client.Name}, SourceLocationID: e.SourceLocationID.String(), DestinationLocationID: e.DestinationLocationID.String(), } diff --git a/modules/warehouse/controller/warehouse_controller.go b/modules/warehouse/controller/warehouse_controller.go index 30a99ed..b8c4ea5 100644 --- a/modules/warehouse/controller/warehouse_controller.go +++ b/modules/warehouse/controller/warehouse_controller.go @@ -87,7 +87,7 @@ func (w *warehouseController) GetById(ctx *gin.Context) { } func (w *warehouseController) GetAll(ctx *gin.Context) { - clientId := ctx.MustGet("client_id").(string) + clientId := ctx.Query("client_id") var filter query.WarehouseFilter filter.ClientID = clientId if err := ctx.ShouldBindQuery(&filter); err != nil {