feat: update duration

This commit is contained in:
2025-12-16 16:12:55 +08:00
parent 0531a72ae6
commit 0e303e8a5c
6 changed files with 79 additions and 9 deletions

View File

@@ -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
}