2020-04-11 20:27:56 +00:00
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"git.dragon-labs.de/alphyron/group_helper/config"
|
|
|
|
"git.dragon-labs.de/alphyron/group_helper/logic"
|
2020-04-11 21:35:40 +00:00
|
|
|
"git.dragon-labs.de/alphyron/group_helper/repository/sql"
|
2020-04-11 20:27:56 +00:00
|
|
|
)
|
|
|
|
|
2020-04-11 21:35:40 +00:00
|
|
|
func NewUserHelperRepository() (logic.GroupHelperRepository, error) {
|
2020-04-11 20:27:56 +00:00
|
|
|
databaseConfig := config.DatabaseConfig{}
|
|
|
|
_ = databaseConfig.LoadConfig()
|
|
|
|
|
|
|
|
switch databaseConfig.DatabaseType {
|
2020-04-11 21:35:40 +00:00
|
|
|
case "mysql":
|
|
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
|
|
|
case "postgres":
|
|
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
|
|
|
case "sqlite3":
|
|
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
|
|
|
case "mssql":
|
|
|
|
return sql.NewGroupHelperRepository(&databaseConfig)
|
2020-04-11 20:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil, errors.New("cannot support given database type (" + databaseConfig.DatabaseType + ")")
|
|
|
|
}
|