From 433512e3da07d45891327976d3da86f75d02d6b6 Mon Sep 17 00:00:00 2001 From: areeqakbr Date: Fri, 20 Jun 2025 09:28:31 +0700 Subject: [PATCH] add image_urls to nearest device --- model/dto/res/nearest_devices.go | 4 +++- utils/helper/nearest_device_helper.go | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/model/dto/res/nearest_devices.go b/model/dto/res/nearest_devices.go index 7302b5c..0ef8b4f 100644 --- a/model/dto/res/nearest_devices.go +++ b/model/dto/res/nearest_devices.go @@ -20,6 +20,7 @@ type NearestDeviceResponse struct { Province *string `json:"province,omitempty"` City *string `json:"city,omitempty"` District *string `json:"district,omitempty"` + ImageURL *string `json:"image_url"` // Connection counts BackboneCount int `json:"backbone_count"` @@ -44,7 +45,8 @@ type NearestDeviceDetailResponse struct { Province *string `json:"province,omitempty"` City *string `json:"city,omitempty"` District *string `json:"district,omitempty"` - ImageURL *string `json:"image_url,omitempty"` + ImageURL *string `json:"image_url"` + ImageURLs []string `json:"image_urls"` // Detailed connection information Backbones []BackboneConnectionInfo `json:"backbones"` diff --git a/utils/helper/nearest_device_helper.go b/utils/helper/nearest_device_helper.go index e3b209b..4e57947 100644 --- a/utils/helper/nearest_device_helper.go +++ b/utils/helper/nearest_device_helper.go @@ -49,6 +49,7 @@ func ConvertToNearestDeviceResponses(devices []entity.DeviceWithDistance, repo r Province: device.Province, City: device.City, District: device.District, + ImageURL: device.ImageURL, BackboneCount: backboneCount, FishboneCount: fishboneCount, TowerCount: towerCount, @@ -94,6 +95,13 @@ func ConvertToNearestDeviceDetailResponse(device entity.Device, distance float64 backboneInfos := convertToBackboneConnectionInfos(backbones, device.ID) fishboneInfos := convertToFishboneConnectionInfos(fishbones, device.ID) towerInfos := convertToTowerConnectionInfos(towers, device.Latitude, device.Longitude) + + allImageURLs := device.GetAllImageURLs() + if len(allImageURLs) == 0 { + allImageURLs = []string{} + } + + log.Printf("Device %s has %d images", device.DeviceCode, len(allImageURLs)) response := res.NearestDeviceDetailResponse{ ID: device.ID, @@ -108,7 +116,7 @@ func ConvertToNearestDeviceDetailResponse(device entity.Device, distance float64 Province: device.Province, City: device.City, District: device.District, - ImageURL: device.ImageURL, + ImageURLs: device.GetAllImageURLs(), Backbones: backboneInfos, Fishbones: fishboneInfos, Towers: towerInfos,