23 lines
476 B
Go
23 lines
476 B
Go
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),
|
|
}
|
|
}
|