Merge pull request 'feature/responses-v2' (#30) from feature/responses-v2 into dev
Reviewed-on: winter-access/backend_nam#30
This commit is contained in:
commit
2dc7d7d6f2
|
|
@ -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
|
||||
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)
|
||||
// Validate device types and convert to uppercase
|
||||
validTypes := map[string]bool{"CLOSURE": true, "OTB": true}
|
||||
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"}
|
||||
deviceTypes = []string{"CLOSURE", "OTB"}
|
||||
}
|
||||
|
||||
log.Printf("Fetching devices without connections for types: %v", deviceTypes)
|
||||
|
||||
devices, err := u.deviceDetailsRepo.GetDevicesWithoutConnections(deviceTypes)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue