fusenapi/home-user-auth/internal/svc/servicecontext.go

26 lines
630 B
Go
Raw Normal View History

2023-05-31 10:33:02 +00:00
package svc
import (
"fusenapi/home-user-auth/internal/config"
"fusenapi/model"
2023-05-31 10:33:02 +00:00
"github.com/zeromicro/go-zero/core/stores/sqlx"
2023-05-31 10:33:02 +00:00
)
type ServiceContext struct {
2023-06-01 08:19:24 +00:00
Config config.Config
FsFontModel model.FsFontModel
FsCanteenTypeModel model.FsCanteenTypeModel
2023-06-01 10:35:09 +00:00
FsUserModel model.FsUserModel
2023-05-31 10:33:02 +00:00
}
func NewServiceContext(c config.Config) *ServiceContext {
2023-06-01 08:19:24 +00:00
conn := sqlx.NewMysql(c.DataSource)
2023-05-31 10:33:02 +00:00
return &ServiceContext{
2023-06-01 08:19:24 +00:00
Config: c,
FsFontModel: model.NewFsFontModel(conn),
FsCanteenTypeModel: model.NewFsCanteenTypeModel(conn),
2023-06-01 10:35:09 +00:00
FsUserModel: model.NewFsUserModel(conn),
2023-05-31 10:33:02 +00:00
}
}