endpoints returning languages, countries and currencies

This commit is contained in:
Daniel Goc
2026-03-18 14:12:33 +01:00
parent 6cebcacb5d
commit 01c8f4333f
7 changed files with 160 additions and 5 deletions

View File

@@ -0,0 +1,36 @@
package jwtFieldsRepo
import (
"git.ma-al.com/goc_daniel/b2b/app/db"
"git.ma-al.com/goc_daniel/b2b/app/model"
)
type UIJWTFieldsRepo interface {
GetLanguages() ([]model.Language, error)
GetCountriesAndCurrencies() ([]model.Country, error)
}
type JWTFieldsRepo struct{}
func New() UIJWTFieldsRepo {
return &JWTFieldsRepo{}
}
func (repo *JWTFieldsRepo) GetLanguages() ([]model.Language, error) {
var languages []model.Language
err := db.DB.Table("b2b_language").Scan(&languages).Error
return languages, err
}
func (repo *JWTFieldsRepo) GetCountriesAndCurrencies() ([]model.Country, error) {
var countries []model.Country
err := db.DB.Table("b2b_countries").
Select("b2b_countries.id, b2b_countries.name, b2b_countries.flag, ps_currency.id as id_currency, ps_currency.name as currency_name, ps_currency.iso_code as currency_iso_code").
Joins("JOIN ps_currency ON ps_currency.id = b2b_countries.currency").
Scan(&countries).Error
return countries, err
}