app-cloudep-trade-service/internal/svc/service_context.go

31 lines
642 B
Go

package svc
import (
"app-cloudep-trade-service/internal/config"
model "app-cloudep-trade-service/internal/model/mongo"
ers "code.30cm.net/digimon/library-go/errs"
"code.30cm.net/digimon/library-go/errs/code"
vi "code.30cm.net/digimon/library-go/validator"
)
type ServiceContext struct {
Config config.Config
Validate vi.Validate
OrderModel model.OrderModel
}
func NewServiceContext(c config.Config) *ServiceContext {
// TODO 改成 Trade
ers.Scope = code.CloudEPOrder
return &ServiceContext{
Config: c,
Validate: vi.MustValidator(
WithDecimalGt(),
WithDecimalGte(),
),
OrderModel: MustOrderModel(c),
}
}