initial commit
This commit is contained in:
22
category/internal/svc/servicecontext.go
Normal file
22
category/internal/svc/servicecontext.go
Normal file
@ -0,0 +1,22 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"godemo/category/internal/config"
|
||||
"godemo/category/internal/model"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
CategoryModel model.CategoriesModel
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := sqlx.NewSqlConn("postgres", c.DB.DataSource)
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
CategoryModel: model.NewCategoriesModel(conn),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user