fixing uppercase on devicewithoutconnections
This commit is contained in:
parent
d8e51e2ff4
commit
0c926d722b
|
|
@ -3,6 +3,7 @@ package usecase
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -55,12 +56,15 @@ 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
|
||||
|
|
@ -68,6 +72,8 @@ func (u *deviceDetailsUseCase) GetDevicesWithoutConnections(deviceTypes []string
|
|||
deviceTypes = []string{"CLOSURE", "OTB"}
|
||||
}
|
||||
|
||||
log.Printf("Fetching devices without connections for types: %v", deviceTypes)
|
||||
|
||||
devices, err := u.deviceDetailsRepo.GetDevicesWithoutConnections(deviceTypes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue