mysql 跑通

This commit is contained in:
eson 2023-06-01 12:15:36 +08:00
parent 340c7966e0
commit e1e0e5ef21
4 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,4 @@
Name: home-user-auth
Host: 0.0.0.0
Port: 8888
DataSource: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest

View File

@ -4,4 +4,5 @@ import "github.com/zeromicro/go-zero/rest"
type Config struct {
rest.RestConf
DataSource string
}

View File

@ -25,6 +25,15 @@ 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
f, err := l.svcCtx.FsFontModel.FindOne(context.TODO(), 10)
if err != nil {
// panic(err)
logx.Error(err)
return
}
logx.Info(f)
resp = &types.Response{
Data: f,
}
return
}

View File

@ -15,6 +15,6 @@ type ServiceContext struct {
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
FsFontModel: model.NewFsFontModel(sqlx.NewMysql("")),
FsFontModel: model.NewFsFontModel(sqlx.NewMysql(c.DataSource)),
}
}