package aeusadmin import ( "git.nobla.cn/golang/rest" "git.nobla.cn/golang/rest/types" "gorm.io/gorm" ) var ( defaultScenarios = []string{ types.ScenarioList, types.ScenarioCreate, types.ScenarioUpdate, types.ScenarioDelete, types.ScenarioView, types.ScenarioImport, types.ScenarioExport, } ) type ( options struct { db *gorm.DB moduleName string viewPath string translate Translate restOpts []rest.Option } Option func(*options) Translate interface { Menu(model *rest.Model, label string) string Permission(model *rest.Model, scene string, label string) string } ) func WithDB(db *gorm.DB) Option { return func(o *options) { o.db = db } } func WithModuleName(moduleName string) Option { return func(o *options) { o.moduleName = moduleName } } func WithViewPath(viewPath string) Option { return func(o *options) { o.viewPath = viewPath } } func WithTranslate(t Translate) Option { return func(o *options) { o.translate = t } } func WithRestOptions(opts ...rest.Option) Option { return func(o *options) { o.restOpts = opts } } func newOptions(opts ...Option) *options { o := &options{ viewPath: "views", } for _, opt := range opts { opt(o) } return o }