You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
621 B
Go

package svc
import (
3 years ago
"gorm.io/driver/mysql"
"gorm.io/gorm"
"live-service/app/user_center/model"
"live-service/app/user_center/rpc/internal/config"
3 years ago
"log"
)
type ServiceContext struct {
Config config.Config
UserModel model.UserModel
UserPlatformModel model.UserPlatformModel
}
func NewServiceContext(c config.Config) *ServiceContext {
3 years ago
gormDb, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{})
if err != nil {
log.Fatal(err)
}
return &ServiceContext{
Config: c,
3 years ago
UserModel: model.NewUserModel(gormDb),
UserPlatformModel: model.NewUserPlatformModel(gormDb),
}
}