Archived
支持套餐相关操作
This commit is contained in:
@@ -46,6 +46,9 @@ type ServerConfig struct {
|
||||
BandwidthLimit *BandwidthLimitConfig `yaml:"bandwidthLimit" json:"bandwidthLimit"`
|
||||
BandwidthLimitStatus *BandwidthLimitStatus `yaml:"bandwidthLimitStatus" json:"bandwidthLimitStatus"`
|
||||
|
||||
// 套餐
|
||||
UserPlan *UserPlanConfig `yaml:"userPlan" json:"userPlan"`
|
||||
|
||||
// 分组
|
||||
Group *ServerGroupConfig `yaml:"group" json:"group"`
|
||||
|
||||
@@ -221,6 +224,14 @@ func (this *ServerConfig) Init() error {
|
||||
}
|
||||
}
|
||||
|
||||
// 套餐
|
||||
if this.UserPlan != nil {
|
||||
err := this.UserPlan.Init()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
this.isOk = true
|
||||
|
||||
return nil
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package serverconfigs
|
||||
|
||||
import timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
|
||||
// DefaultPlanExpireNoticePageBody 套餐过期时提示
|
||||
const DefaultPlanExpireNoticePageBody = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>套餐已过期</title>
|
||||
<body>
|
||||
|
||||
<p>套餐已过期,请及时续费。</p>
|
||||
<p>Your server plan has been expired, please renew the plan.</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
// UserPlanConfig 用户套餐配置
|
||||
type UserPlanConfig struct {
|
||||
DayTo string `yaml:"dayTo" json:"dayTo"` // 有效期
|
||||
}
|
||||
|
||||
// Init 初始化
|
||||
func (this *UserPlanConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsAvailable 是否有效
|
||||
func (this *UserPlanConfig) IsAvailable() bool {
|
||||
return this.DayTo >= timeutil.Format("Y-m-d")
|
||||
}
|
||||
Reference in New Issue
Block a user