Chever John 71a2d912e2 feat: initial commit for muyu-apiserver
Go service with gateway, RPC, model layers and k8s deploy configs.

Made-with: Cursor
2026-02-28 15:29:16 +08:00

32 lines
1.0 KiB
Go

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