From c72db5bd18a3856c42a8733a9c5ec6bc0ff8d40e Mon Sep 17 00:00:00 2001 From: aguhh18 Date: Mon, 3 Nov 2025 09:29:00 +0700 Subject: [PATCH] FIX[BE]: delete redudant kandang response on projectflockkandang getone API --- .../dto/project_flock_kandang.dto.go | 14 -------------- .../services/project_flock_kandang.service.go | 4 +--- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/internal/modules/production/project-flock-kandangs/dto/project_flock_kandang.dto.go b/internal/modules/production/project-flock-kandangs/dto/project_flock_kandang.dto.go index 1656eaba..888964a7 100644 --- a/internal/modules/production/project-flock-kandangs/dto/project_flock_kandang.dto.go +++ b/internal/modules/production/project-flock-kandangs/dto/project_flock_kandang.dto.go @@ -28,7 +28,6 @@ type ProjectFlockCustomDTO struct { Category string `json:"category"` Fcr *fcrDTO.FcrBaseDTO `json:"fcr,omitempty"` Location *locationDTO.LocationBaseDTO `json:"location,omitempty"` - Kandangs []KandangCustomDTO `json:"kandangs,omitempty"` CreatedUser *userDTO.UserBaseDTO `json:"created_user,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` @@ -85,7 +84,6 @@ func toProjectFlockCustomDTO(pf *projectFlockDTO.ProjectFlockListDTO) *ProjectFl Category: pf.Category, Fcr: pf.Fcr, Location: pf.Location, - Kandangs: buildKandangCustomDTOs(pf.Kandangs), CreatedUser: pf.CreatedUser, CreatedAt: pf.CreatedAt, UpdatedAt: pf.UpdatedAt, @@ -238,18 +236,6 @@ func buildCreatedUser(pf entity.ProjectFlock) *userDTO.UserBaseDTO { return nil } -func buildKandangCustomDTOs(kandangs []projectFlockDTO.KandangWithProjectFlockIdDTO) []KandangCustomDTO { - if len(kandangs) == 0 { - return nil - } - - result := make([]KandangCustomDTO, len(kandangs)) - for i, k := range kandangs { - result[i] = toKandangCustomDTO(k) - } - return result -} - func buildKandangFromEntity(kandang entity.Kandang) *KandangCustomDTO { if kandang.Id == 0 { return nil diff --git a/internal/modules/production/project-flock-kandangs/services/project_flock_kandang.service.go b/internal/modules/production/project-flock-kandangs/services/project_flock_kandang.service.go index d3f1f0b7..6258e34a 100644 --- a/internal/modules/production/project-flock-kandangs/services/project_flock_kandang.service.go +++ b/internal/modules/production/project-flock-kandangs/services/project_flock_kandang.service.go @@ -115,20 +115,18 @@ func (s projectFlockKandangService) getAvailableQuantities(c *fiber.Ctx, project var result []map[string]interface{} for _, pw := range products { if pw.Quantity > 0 { - // Build product data + productData := map[string]interface{}{ "id": pw.Product.Id, "name": pw.Product.Name, } - // Build warehouse data warehouseData := map[string]interface{}{ "id": pw.Warehouse.Id, "name": pw.Warehouse.Name, "type": pw.Warehouse.Type, } - // Build product warehouse data with nested product and warehouse productWarehouseData := map[string]interface{}{ "id": pw.Id, "quantity": pw.Quantity,