36 lines
1.2 KiB
Go
Raw Normal View History

package svc
import (
"muyu-apiserver/model"
"muyu-apiserver/rpc/inventory/internal/config"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
type ServiceContext struct {
Config config.Config
ProductModel model.InvProductModel
PanModel model.InvProductPanModel
BoltModel model.InvProductBoltModel
ImportLogModel model.InvStockImportLogModel
StockCheckModel model.InvStockCheckModel
CheckDetailModel model.InvStockCheckDetailModel
StockAdjustModel model.InvStockAdjustModel
AdjustDetailModel model.InvStockAdjustDetailModel
}
func NewServiceContext(c config.Config) *ServiceContext {
conn := sqlx.NewMysql(c.DataSource)
return &ServiceContext{
Config: c,
ProductModel: model.NewInvProductModel(conn, c.Cache),
PanModel: model.NewInvProductPanModel(conn),
BoltModel: model.NewInvProductBoltModel(conn),
ImportLogModel: model.NewInvStockImportLogModel(conn, c.Cache),
StockCheckModel: model.NewInvStockCheckModel(conn, c.Cache),
CheckDetailModel: model.NewInvStockCheckDetailModel(conn, c.Cache),
StockAdjustModel: model.NewInvStockAdjustModel(conn, c.Cache),
AdjustDetailModel: model.NewInvStockAdjustDetailModel(conn, c.Cache),
}
}