From b670dad3e4c0bdffe048e1980d065a294d41bb39 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Mon, 16 Feb 2026 18:14:51 +0530 Subject: [PATCH] icon url added: GWM --- main.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index d10df64..7bc2d50 100755 --- a/main.go +++ b/main.go @@ -2227,14 +2227,16 @@ func main() { // Get all bilateral trade statistics allBilateralTradeData := []struct { - Topic string `db:"topic" json:"topic"` - Value string `db:"value" json:"value"` - Icon string `db:"icon" json:"icon"` + ID string `db:"id" json:"id"` + Topic string `db:"topic" json:"topic"` + Value string `db:"value" json:"value"` + Icon string `db:"icon" json:"icon"` + IconURL string `db:"-" json:"icon_url"` }{} topicColumn := "topic_" + language - query2 := `SELECT ` + topicColumn + ` AS topic,value,icon FROM bilateral_trade_data WHERE country = {:country} AND statistics = {:statistics}` + query2 := `SELECT ` + topicColumn + ` AS topic,id,value,icon FROM bilateral_trade_data WHERE country = {:country} AND statistics = {:statistics}` err = app.DB(). NewQuery(query2). @@ -2256,6 +2258,19 @@ func main() { }) } + for i := range allBilateralTradeData { + if allBilateralTradeData[i].Icon == "" { + allBilateralTradeData[i].IconURL = "" + continue + } + + allBilateralTradeData[i].IconURL = fmt.Sprintf("%s/api/files/country_statistics/%s/%s", + baseUrl, + allBilateralTradeData[i].ID, + allBilateralTradeData[i].Icon, + ) + } + return c.JSON(http.StatusOK, allBilateralTradeData) })