feat: update duration
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
)
|
||||
@@ -18,3 +21,16 @@ type TenantItem struct {
|
||||
UserCount int64
|
||||
UserBalance int64
|
||||
}
|
||||
|
||||
type TenantExpireUpdateForm struct {
|
||||
Duration int `json:"duration" validate:"required,oneof=7 30 90 180 365"`
|
||||
}
|
||||
|
||||
// Duration
|
||||
func (form *TenantExpireUpdateForm) ParseDuration() (time.Duration, error) {
|
||||
duration := time.Duration(form.Duration) * 24 * time.Hour
|
||||
if duration == 0 {
|
||||
return 0, errors.New("invalid parsed duration")
|
||||
}
|
||||
return duration, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user