Restructure project
This commit is contained in:
parent
e44e7caa11
commit
16b2f17301
46 changed files with 1744 additions and 1265 deletions
34
internal/controller/controller.go
Normal file
34
internal/controller/controller.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"github.com/r3labs/sse/v2"
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/database"
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/env"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
orm *gorm.DB
|
||||
env *env.Config
|
||||
SSE *sse.Server
|
||||
}
|
||||
|
||||
func NewController(env *env.Config) *Controller {
|
||||
db := database.NewDatabaseConnection(&database.Database{
|
||||
Host: env.DB_Host,
|
||||
User: env.DB_User,
|
||||
Password: env.DB_Password,
|
||||
Database: env.DB_Database,
|
||||
})
|
||||
|
||||
db.AutoMigrate(&Table{})
|
||||
db.AutoMigrate(&Order{})
|
||||
db.AutoMigrate(&OrderItem{})
|
||||
db.AutoMigrate(&Bill{})
|
||||
db.AutoMigrate(&BillItem{})
|
||||
db.AutoMigrate(&User{})
|
||||
|
||||
ctrl := Controller{orm: db, env: env, SSE: sse.New()}
|
||||
ctrl.setupEventChannel()
|
||||
return &ctrl
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue