package svc import ( "godemo/category/category" "godemo/file/file" "godemo/gallery/internal/config" "godemo/gallery/internal/model" _ "github.com/lib/pq" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/zrpc" ) type ServiceContext struct { Config config.Config FileRpc file.FileClient CategoryRpc category.CategoryClient ImagesModel model.ImagesModel } func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, FileRpc: file.NewFileClient(zrpc.MustNewClient(c.FileRpc).Conn()), CategoryRpc: category.NewCategoryClient(zrpc.MustNewClient(c.CategoryRpc).Conn()), ImagesModel: model.NewImagesModel(sqlx.NewSqlConn("postgres", c.DB.DataSource)), } }