add image_urls to nearest device

This commit is contained in:
areeqakbr 2025-06-20 09:28:31 +07:00
parent 8edbdfaa56
commit 433512e3da
2 changed files with 12 additions and 2 deletions

View File

@ -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"`

View File

@ -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,
@ -95,6 +96,13 @@ func ConvertToNearestDeviceDetailResponse(device entity.Device, distance float64
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,
DeviceCode: device.DeviceCode,
@ -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,