From d8e51e2ff45f990cca40f83e1b357201ed95f140 Mon Sep 17 00:00:00 2001 From: areeqakbr Date: Mon, 23 Jun 2025 13:32:15 +0700 Subject: [PATCH 1/2] fixing typo --- usecase/device_details.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usecase/device_details.go b/usecase/device_details.go index b34f4c5..2bcd2ff 100644 --- a/usecase/device_details.go +++ b/usecase/device_details.go @@ -56,7 +56,7 @@ func NewDeviceDetailsUseCase(deviceDetailsRepo repository.DeviceDetailsRepo, geo func (u *deviceDetailsUseCase) GetDevicesWithoutConnections(deviceTypes []string) ([]res.DeviceDetailsResponse, error) { // Validate device types - validTypes := map[string]bool{"closure": true, "OTB": true} + validTypes := map[string]bool{"CLOSURE": true, "OTB": true} for _, deviceType := range deviceTypes { if !validTypes[deviceType] { return nil, fmt.Errorf("invalid device type: %s. Only closure and OTB are allowed", deviceType) @@ -65,7 +65,7 @@ func (u *deviceDetailsUseCase) GetDevicesWithoutConnections(deviceTypes []string // If no device types provided, default to closure and OTB if len(deviceTypes) == 0 { - deviceTypes = []string{"closure", "OTB"} + deviceTypes = []string{"CLOSURE", "OTB"} } devices, err := u.deviceDetailsRepo.GetDevicesWithoutConnections(deviceTypes) From 0c926d722b407343a72583628b8562a3730285c9 Mon Sep 17 00:00:00 2001 From: areeqakbr Date: Mon, 23 Jun 2025 13:47:39 +0700 Subject: [PATCH 2/2] fixing uppercase on devicewithoutconnections --- usecase/device_details.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usecase/device_details.go b/usecase/device_details.go index 2bcd2ff..8ee41ae 100644 --- a/usecase/device_details.go +++ b/usecase/device_details.go @@ -3,6 +3,7 @@ package usecase import ( "errors" "fmt" + "log" "mime/multipart" "strings" "time" @@ -55,18 +56,23 @@ func NewDeviceDetailsUseCase(deviceDetailsRepo repository.DeviceDetailsRepo, geo } func (u *deviceDetailsUseCase) GetDevicesWithoutConnections(deviceTypes []string) ([]res.DeviceDetailsResponse, error) { - // Validate device types + // Validate device types and convert to uppercase validTypes := map[string]bool{"CLOSURE": true, "OTB": true} - for _, deviceType := range deviceTypes { - if !validTypes[deviceType] { - return nil, fmt.Errorf("invalid device type: %s. Only closure and OTB are allowed", deviceType) + for i, deviceType := range deviceTypes { + upperDeviceType := strings.ToUpper(deviceType) + if !validTypes[upperDeviceType] { + return nil, fmt.Errorf("invalid device type: %s. Only CLOSURE and OTB are allowed", deviceType) } + // Replace the original value in the slice with uppercase version for consistency + deviceTypes[i] = upperDeviceType } // If no device types provided, default to closure and OTB if len(deviceTypes) == 0 { deviceTypes = []string{"CLOSURE", "OTB"} } + + log.Printf("Fetching devices without connections for types: %v", deviceTypes) devices, err := u.deviceDetailsRepo.GetDevicesWithoutConnections(deviceTypes) if err != nil {