🗃️ Finish database selection connection
This commit is contained in:
parent
18878de12c
commit
a08defa167
13
main.go
13
main.go
@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"git.dragon-labs.de/alphyron/group_helper/config"
|
||||
"git.dragon-labs.de/alphyron/group_helper/logic"
|
||||
"git.dragon-labs.de/alphyron/group_helper/repository"
|
||||
"log"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
@ -32,4 +34,15 @@ func main() {
|
||||
|
||||
bot.Debug = tgConfig.TelegramDebug
|
||||
log.Printf("Authorized on account %s", bot.Self.UserName)
|
||||
|
||||
groupHelperRepo, err := repository.NewUserHelperRepository()
|
||||
|
||||
if err != nil {
|
||||
log.Println("Problem while connection to the Database")
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
/* groupHelperService := */
|
||||
logic.NewGroupHelperService(groupHelperRepo)
|
||||
|
||||
}
|
||||
|
@ -4,14 +4,22 @@ import (
|
||||
"errors"
|
||||
"git.dragon-labs.de/alphyron/group_helper/config"
|
||||
"git.dragon-labs.de/alphyron/group_helper/logic"
|
||||
"git.dragon-labs.de/alphyron/group_helper/repository/sql"
|
||||
)
|
||||
|
||||
func NewUserHelperRepository() (*logic.GroupHelperRepository, error) {
|
||||
func NewUserHelperRepository() (logic.GroupHelperRepository, error) {
|
||||
databaseConfig := config.DatabaseConfig{}
|
||||
_ = databaseConfig.LoadConfig()
|
||||
|
||||
switch databaseConfig.DatabaseType {
|
||||
|
||||
case "mysql":
|
||||
return sql.NewGroupHelperRepository(&databaseConfig)
|
||||
case "postgres":
|
||||
return sql.NewGroupHelperRepository(&databaseConfig)
|
||||
case "sqlite3":
|
||||
return sql.NewGroupHelperRepository(&databaseConfig)
|
||||
case "mssql":
|
||||
return sql.NewGroupHelperRepository(&databaseConfig)
|
||||
}
|
||||
|
||||
return nil, errors.New("cannot support given database type (" + databaseConfig.DatabaseType + ")")
|
||||
|
Loading…
Reference in New Issue
Block a user