icon url added: GWM
This commit is contained in:
parent
f841fd8952
commit
b670dad3e4
23
main.go
23
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)
|
||||
})
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user