commit code
This commit is contained in:
@ -1,21 +1,28 @@
|
||||
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
|
||||
Config config.Config
|
||||
FileRpc file.FileClient
|
||||
CategoryRpc category.CategoryClient
|
||||
ImagesModel model.ImagesModel
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := zrpc.MustNewClient(c.FileRpc).Conn()
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
FileRpc: file.NewFileClient(conn),
|
||||
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)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user