使用ddl生成结构, 支持mysql连接使用
This commit is contained in:
@@ -4,7 +4,7 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"home-user-auth/internal/svc"
|
||||
"fusenapi/home-user-auth/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
@@ -3,10 +3,10 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"fusenapi/home-user-auth/internal/logic"
|
||||
"fusenapi/home-user-auth/internal/svc"
|
||||
"fusenapi/home-user-auth/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"home-user-auth/internal/logic"
|
||||
"home-user-auth/internal/svc"
|
||||
"home-user-auth/internal/types"
|
||||
)
|
||||
|
||||
func UserFontsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
@@ -3,8 +3,8 @@ package logic
|
||||
import (
|
||||
"context"
|
||||
|
||||
"home-user-auth/internal/svc"
|
||||
"home-user-auth/internal/types"
|
||||
"fusenapi/home-user-auth/internal/svc"
|
||||
"fusenapi/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -25,5 +25,6 @@ func NewUserFontsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserFon
|
||||
|
||||
func (l *UserFontsLogic) UserFonts(req *types.Request) (resp *types.Response, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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