添加valueLookup支持配置
This commit is contained in:
parent
2631943904
commit
01a671dff8
|
@ -13,6 +13,7 @@ type options struct {
|
||||||
router types.HttpRouter
|
router types.HttpRouter
|
||||||
writer types.HttpWriter
|
writer types.HttpWriter
|
||||||
permissionChecker types.PermissionChecker
|
permissionChecker types.PermissionChecker
|
||||||
|
valueLookup types.ValueLookupFunc
|
||||||
formatter *Formatter
|
formatter *Formatter
|
||||||
resourceDirectory string
|
resourceDirectory string
|
||||||
}
|
}
|
||||||
|
@ -30,6 +31,7 @@ func (o *options) Clone() *options {
|
||||||
permissionChecker: o.permissionChecker,
|
permissionChecker: o.permissionChecker,
|
||||||
formatter: o.formatter,
|
formatter: o.formatter,
|
||||||
resourceDirectory: o.resourceDirectory,
|
resourceDirectory: o.resourceDirectory,
|
||||||
|
valueLookup: o.valueLookup,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +49,12 @@ func WithUriPrefix(s string) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithValueLookup(f types.ValueLookupFunc) Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.valueLookup = f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithModuleName 模块名称
|
// WithModuleName 模块名称
|
||||||
func WithModuleName(s string) Option {
|
func WithModuleName(s string) Option {
|
||||||
return func(o *options) {
|
return func(o *options) {
|
||||||
|
|
3
rest.go
3
rest.go
|
@ -516,6 +516,9 @@ func AutoMigrate(ctx context.Context, model any, cbs ...Option) (modelValue *Mod
|
||||||
if scenarioModel, ok := model.(types.ScenarioModel); ok {
|
if scenarioModel, ok := model.(types.ScenarioModel); ok {
|
||||||
modelValue.scenarios = scenarioModel.Scenario()
|
modelValue.scenarios = scenarioModel.Scenario()
|
||||||
}
|
}
|
||||||
|
if opts.valueLookup != nil {
|
||||||
|
modelValue.valueLookup = opts.valueLookup
|
||||||
|
}
|
||||||
modelValue.hookMgr = hookMgr
|
modelValue.hookMgr = hookMgr
|
||||||
modelValue.schemaLookup = VisibleSchemas
|
modelValue.schemaLookup = VisibleSchemas
|
||||||
modelValue.permissionChecker = opts.permissionChecker
|
modelValue.permissionChecker = opts.permissionChecker
|
||||||
|
|
Loading…
Reference in New Issue