muyu-apiserver/rpc/purchase/internal/svc/servicecontext.go
Chever John a25acdc5e4 chore: sync codebase with upstream
Pull latest changes from upstream/main (GitHub) including:
- Purchase RPC service (proto, server, logic, models)
- Gateway route updates for purchase endpoints
- SQL migration and config updates

Excludes deploy/bin/ pre-compiled arm64 binaries (builds use
multi-stage Dockerfiles targeting amd64).
2026-06-15 09:20:56 +08:00

34 lines
1.1 KiB
Go

package svc
import (
"muyu-apiserver/model"
"muyu-apiserver/rpc/purchase/internal/config"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
type ServiceContext struct {
Config config.Config
SupplierModel model.PurSupplierModel
OrderModel model.PurPurchaseOrderModel
OrderDetailModel model.PurPurchaseOrderDetailModel
ReceiptModel model.PurPurchaseReceiptModel
ReceiptDetailModel model.PurPurchaseReceiptDetailModel
PaymentModel model.PurPurchasePaymentModel
InventoryLogModel model.InvInventoryLogModel
}
func NewServiceContext(c config.Config) *ServiceContext {
conn := sqlx.NewMysql(c.DataSource)
return &ServiceContext{
Config: c,
SupplierModel: model.NewPurSupplierModel(conn, c.Cache),
OrderModel: model.NewPurPurchaseOrderModel(conn, c.Cache),
OrderDetailModel: model.NewPurPurchaseOrderDetailModel(conn),
ReceiptModel: model.NewPurPurchaseReceiptModel(conn),
ReceiptDetailModel: model.NewPurPurchaseReceiptDetailModel(conn),
PaymentModel: model.NewPurPurchasePaymentModel(conn),
InventoryLogModel: model.NewInvInventoryLogModel(conn),
}
}