2021-10-21 17:09:59 +08:00
|
|
|
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
package serverconfigs
|
|
|
|
|
|
|
|
|
|
|
|
import timeutil "github.com/iwind/TeaGo/utils/time"
|
|
|
|
|
|
|
2023-09-07 11:46:20 +08:00
|
|
|
|
type TrafficLimitTarget = string
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
TrafficLimitTargetTraffic TrafficLimitTarget = "traffic"
|
|
|
|
|
|
TrafficLimitTargetRequest TrafficLimitTarget = "request"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2021-11-09 17:36:34 +08:00
|
|
|
|
// TrafficLimitStatus 流量限制状态
|
|
|
|
|
|
type TrafficLimitStatus struct {
|
2023-09-07 11:46:20 +08:00
|
|
|
|
UntilDay string `yaml:"untilDay" json:"untilDay"` // 有效日期,格式YYYYMMDD
|
|
|
|
|
|
PlanId int64 `yaml:"planId" json:"planId"` // 套餐ID
|
|
|
|
|
|
DateType string `yaml:"dateType" json:"dateType"` // 日期类型 day|month
|
|
|
|
|
|
TargetType string `yaml:"targetType" json:"targetType"` // 限制类型:traffic|request|...
|
2021-10-21 17:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 17:36:34 +08:00
|
|
|
|
func (this *TrafficLimitStatus) IsValid() bool {
|
2021-10-21 17:09:59 +08:00
|
|
|
|
if len(this.UntilDay) == 0 {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
return this.UntilDay >= timeutil.Format("Ymd")
|
|
|
|
|
|
}
|