新设计

This commit is contained in:
eson
2023-05-31 18:33:02 +08:00
parent 12986049ef
commit f7d547de59
14 changed files with 764 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
package svc
import (
"home-user-auth/internal/config"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type ServiceContext struct {
Config config.Config
DB *gorm.DB
}
func NewServiceContext(c config.Config) *ServiceContext {
db, err := gorm.Open(mysql.Open(c.DataSourceName), &gorm.Config{})
if err != nil {
panic(err)
}
return &ServiceContext{
Config: c,
DB: db,
}
}