feat: support bind user to tenants
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"git.ipao.vip/rogeecn/atom"
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -72,5 +73,31 @@ func Command() atom.Option {
|
||||
})
|
||||
}),
|
||||
),
|
||||
|
||||
atom.Command(
|
||||
atom.Name("bind"),
|
||||
atom.Short("设置租户的管理员ID"),
|
||||
atom.Example("bind slug user_id"),
|
||||
atom.Providers(defaultProviders().With(
|
||||
medias.Provide,
|
||||
users.Provide,
|
||||
tenant.Provide,
|
||||
)),
|
||||
atom.Arguments(func(cmd *cobra.Command) {
|
||||
}),
|
||||
atom.RunE(func(cmd *cobra.Command, args []string) error {
|
||||
return container.Container.Invoke(func(t *tenant.Bind) error {
|
||||
slug := args[0]
|
||||
userID, err := cast.ToInt64E(args[1]) // format 2024-01-01
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parse user_id failed: %s", args[1])
|
||||
}
|
||||
|
||||
// parse expire string as time.Time
|
||||
|
||||
return t.RunE(slug, userID)
|
||||
})
|
||||
}),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user