diff --git a/main.go b/main.go index 8c39388..b9b860a 100644 --- a/main.go +++ b/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) + } diff --git a/repository/grouphelperrepository.go b/repository/grouphelperrepository.go index c3a7eb8..865afe5 100644 --- a/repository/grouphelperrepository.go +++ b/repository/grouphelperrepository.go @@ -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 + ")")