cleanup
This commit is contained in:
36
repository/langsAndCountriesRepo/langsAndCountriesRepo.go
Normal file
36
repository/langsAndCountriesRepo/langsAndCountriesRepo.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package langsAndCountriesRepo
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/db"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
)
|
||||
|
||||
type UILangsAndCountriesRepo interface {
|
||||
GetLanguages() ([]model.Language, error)
|
||||
GetCountriesAndCurrencies() ([]model.Country, error)
|
||||
}
|
||||
|
||||
type LangsAndCountriesRepo struct{}
|
||||
|
||||
func New() UILangsAndCountriesRepo {
|
||||
return &LangsAndCountriesRepo{}
|
||||
}
|
||||
|
||||
func (repo *LangsAndCountriesRepo) GetLanguages() ([]model.Language, error) {
|
||||
var languages []model.Language
|
||||
|
||||
err := db.DB.Table("b2b_language").Scan(&languages).Error
|
||||
|
||||
return languages, err
|
||||
}
|
||||
|
||||
func (repo *LangsAndCountriesRepo) 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
|
||||
}
|
||||
Reference in New Issue
Block a user