使用ddl生成结构, 支持mysql连接使用

This commit is contained in:
eson
2023-06-01 11:27:34 +08:00
parent f7d547de59
commit 340c7966e0
18 changed files with 840 additions and 592 deletions

View File

@@ -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("")),
}
}