GWM : country url
This commit is contained in:
parent
3f2f157323
commit
92c962ab95
17
main.go
17
main.go
@ -2014,11 +2014,10 @@ func main() {
|
|||||||
CountryName string `db:"country_name" json:"country_name"`
|
CountryName string `db:"country_name" json:"country_name"`
|
||||||
CountryCode string `db:"country_code" json:"country_code"`
|
CountryCode string `db:"country_code" json:"country_code"`
|
||||||
FlagUrl string `db:"flag_url" json:"flag_url"`
|
FlagUrl string `db:"flag_url" json:"flag_url"`
|
||||||
Logo string `db:"logo" json:"logo"`
|
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
countryNameColumn := "country_name_" + language
|
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().
|
err := app.DB().
|
||||||
NewQuery(query).
|
NewQuery(query).
|
||||||
All(&countries)
|
All(&countries)
|
||||||
@ -2035,22 +2034,12 @@ func main() {
|
|||||||
// Build response with full logo URLs
|
// Build response with full logo URLs
|
||||||
result := []map[string]interface{}{}
|
result := []map[string]interface{}{}
|
||||||
for _, country := range countries {
|
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{}{
|
result = append(result, map[string]interface{}{
|
||||||
"id": country.ID,
|
"id": country.ID,
|
||||||
"country_name": country.CountryName,
|
"country_name": country.CountryName,
|
||||||
"country_code": country.CountryCode,
|
"country_code": country.CountryCode,
|
||||||
"flag_url": flagURL,
|
"flag_url": country.FlagUrl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2079,7 +2068,7 @@ func main() {
|
|||||||
}{}
|
}{}
|
||||||
|
|
||||||
countryNameColumn := "country_name_" + language
|
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().
|
err := app.DB().
|
||||||
NewQuery(query).
|
NewQuery(query).
|
||||||
Bind(dbx.Params{
|
Bind(dbx.Params{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user