reCoreD-UI/controllers/init.go
Sense T 8a8ea59b71 1
2024-04-03 17:05:12 +08:00

28 lines
356 B
Go

package controllers
import (
"reCoreD-UI/database"
"gorm.io/gorm"
)
type Controller struct {
DB *gorm.DB
}
func NewController(DSN string) (*Controller, error) {
db, err := database.Connect(DSN)
return &Controller{
DB: db,
}, err
}
func (c *Controller) Close() error {
d, err := c.DB.DB()
if err != nil {
return err
}
return d.Close()
}