fixing uppercase on devicewithoutconnections
This commit is contained in:
parent
d8e51e2ff4
commit
0c926d722b
|
|
@ -3,6 +3,7 @@ package usecase
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -55,12 +56,15 @@ func NewDeviceDetailsUseCase(deviceDetailsRepo repository.DeviceDetailsRepo, geo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *deviceDetailsUseCase) GetDevicesWithoutConnections(deviceTypes []string) ([]res.DeviceDetailsResponse, error) {
|
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}
|
validTypes := map[string]bool{"CLOSURE": true, "OTB": true}
|
||||||
for _, deviceType := range deviceTypes {
|
for i, deviceType := range deviceTypes {
|
||||||
if !validTypes[deviceType] {
|
upperDeviceType := strings.ToUpper(deviceType)
|
||||||
return nil, fmt.Errorf("invalid device type: %s. Only closure and OTB are allowed", 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 no device types provided, default to closure and OTB
|
||||||
|
|
@ -68,6 +72,8 @@ func (u *deviceDetailsUseCase) GetDevicesWithoutConnections(deviceTypes []string
|
||||||
deviceTypes = []string{"CLOSURE", "OTB"}
|
deviceTypes = []string{"CLOSURE", "OTB"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("Fetching devices without connections for types: %v", deviceTypes)
|
||||||
|
|
||||||
devices, err := u.deviceDetailsRepo.GetDevicesWithoutConnections(deviceTypes)
|
devices, err := u.deviceDetailsRepo.GetDevicesWithoutConnections(deviceTypes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue