增加账单、套餐相关配置

This commit is contained in:
GoEdgeLab
2021-11-11 08:31:32 +08:00
parent 79da524d88
commit 3d8d2438bc
7 changed files with 57 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package serverconfigs
type PlanConfig struct {
Id int64 `yaml:"id" json:"id"`
}
func (this *PlanConfig) Init() error {
return nil
}

View File

@@ -53,6 +53,8 @@ type ServerConfig struct {
Group *ServerGroupConfig `yaml:"group" json:"group"`
isOk bool
planId int64
}
// NewServerConfigFromJSON 从JSON中解析Server配置
@@ -230,6 +232,10 @@ func (this *ServerConfig) Init() error {
if err != nil {
return err
}
if this.UserPlan.Plan != nil {
this.planId = this.UserPlan.Plan.Id
}
}
this.isOk = true
@@ -368,3 +374,8 @@ func (this *ServerConfig) FindAndCheckReverseProxy(dataType string) (*ReversePro
func (this *ServerConfig) ShouldCheckTrafficLimit() bool {
return this.TrafficLimit != nil && !this.TrafficLimit.IsEmpty()
}
// PlanId 套餐ID
func (this *ServerConfig) PlanId() int64 {
return this.planId
}

View File

@@ -21,10 +21,18 @@ const DefaultPlanExpireNoticePageBody = `<!DOCTYPE html>
// UserPlanConfig 用户套餐配置
type UserPlanConfig struct {
DayTo string `yaml:"dayTo" json:"dayTo"` // 有效期
Plan *PlanConfig `yaml:"plan" json:"plan"`
}
// Init 初始化
func (this *UserPlanConfig) Init() error {
if this.Plan != nil {
err := this.Plan.Init()
if err != nil {
return err
}
}
return nil
}