使用ddl生成结构, 支持mysql连接使用
This commit is contained in:
@@ -1,24 +1,20 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"home-user-auth/internal/config"
|
||||
"fusenapi/home-user-auth/internal/config"
|
||||
"fusenapi/model"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
DB *gorm.DB
|
||||
Config config.Config
|
||||
FsFontModel model.FsFontModel
|
||||
}
|
||||
|
||||
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,
|
||||
Config: c,
|
||||
FsFontModel: model.NewFsFontModel(sqlx.NewMysql("")),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user