commit code

This commit is contained in:
2025-05-31 21:44:34 +08:00
parent bfca5d7d0b
commit ca373ad91f
19 changed files with 496 additions and 126 deletions

View File

@ -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)),
}
}