GWM : country url

This commit is contained in:
Gowtham M 2026-03-13 09:54:14 +05:30
parent 3f2f157323
commit 92c962ab95

17
main.go
View File

@ -2014,11 +2014,10 @@ func main() {
CountryName string `db:"country_name" json:"country_name"`
CountryCode string `db:"country_code" json:"country_code"`
FlagUrl string `db:"flag_url" json:"flag_url"`
Logo string `db:"logo" json:"logo"`
}{}
countryNameColumn := "country_name_" + language
query := ` SELECT id,country_code,flag_url,logo,` + countryNameColumn + ` AS country_name FROM countries`
query := ` SELECT id,country_code,flag_url,` + countryNameColumn + ` AS country_name FROM countries`
err := app.DB().
NewQuery(query).
All(&countries)
@ -2035,22 +2034,12 @@ func main() {
// Build response with full logo URLs
result := []map[string]interface{}{}
for _, country := range countries {
var flagURL string
if country.Logo == "" {
flagURL = ""
} else {
flagURL = fmt.Sprintf("%s/api/files/countries/%s/%s",
baseUrl,
country.ID,
country.Logo,
)
}
result = append(result, map[string]interface{}{
"id": country.ID,
"country_name": country.CountryName,
"country_code": country.CountryCode,
"flag_url": flagURL,
"flag_url": country.FlagUrl,
})
}
@ -2079,7 +2068,7 @@ func main() {
}{}
countryNameColumn := "country_name_" + language
query := ` SELECT id,country_code,flag_url,logo,` + countryNameColumn + ` AS country_name FROM countries WHERE country_code = {:country_code}`
query := ` SELECT id,country_code,flag_url,` + countryNameColumn + ` AS country_name FROM countries WHERE country_code = {:country_code}`
err := app.DB().
NewQuery(query).
Bind(dbx.Params{