feat: add tenant commands
This commit is contained in:
35
backend/modules/commands/tenant/expire.go
Normal file
35
backend/modules/commands/tenant/expire.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package tenant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"backend/modules/users"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Expire struct {
|
||||
userSvc *users.Service
|
||||
log *log.Entry `inject:"false"`
|
||||
}
|
||||
|
||||
// Prepare
|
||||
func (d *Expire) Prepare() error {
|
||||
d.log = log.WithField("module", "tenants.create")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Expire) RunE(slug string, expire time.Time) error {
|
||||
d.log.Infof("renew tenant %s expire at s %s", slug, expire)
|
||||
|
||||
err := d.userSvc.SetTenantExpireAtBySlug(context.Background(), slug, expire)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "renew tenant: %s expire at %s", slug, expire)
|
||||
}
|
||||
|
||||
d.log.Infof("renew tenant success: %s expire at %s", slug, expire)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user