mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-02-01 00:25:47 +08:00
增加账单、套餐相关配置
This commit is contained in:
11
pkg/serverconfigs/plan_config.go
Normal file
11
pkg/serverconfigs/plan_config.go
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user