mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-12-08 08:00:26 +08:00
增加账单、套餐相关配置
This commit is contained in:
@@ -41,6 +41,7 @@ type ServerDailyStat struct {
|
|||||||
CountAttackRequests int64 `protobuf:"varint,8,opt,name=countAttackRequests,proto3" json:"countAttackRequests,omitempty"`
|
CountAttackRequests int64 `protobuf:"varint,8,opt,name=countAttackRequests,proto3" json:"countAttackRequests,omitempty"`
|
||||||
AttackBytes int64 `protobuf:"varint,9,opt,name=attackBytes,proto3" json:"attackBytes,omitempty"`
|
AttackBytes int64 `protobuf:"varint,9,opt,name=attackBytes,proto3" json:"attackBytes,omitempty"`
|
||||||
CheckTrafficLimiting bool `protobuf:"varint,10,opt,name=checkTrafficLimiting,proto3" json:"checkTrafficLimiting,omitempty"`
|
CheckTrafficLimiting bool `protobuf:"varint,10,opt,name=checkTrafficLimiting,proto3" json:"checkTrafficLimiting,omitempty"`
|
||||||
|
PlanId int64 `protobuf:"varint,11,opt,name=planId,proto3" json:"planId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ServerDailyStat) Reset() {
|
func (x *ServerDailyStat) Reset() {
|
||||||
@@ -145,12 +146,19 @@ func (x *ServerDailyStat) GetCheckTrafficLimiting() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *ServerDailyStat) GetPlanId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.PlanId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
var File_models_model_server_daily_stat_proto protoreflect.FileDescriptor
|
var File_models_model_server_daily_stat_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_models_model_server_daily_stat_proto_rawDesc = []byte{
|
var file_models_model_server_daily_stat_proto_rawDesc = []byte{
|
||||||
0x0a, 0x24, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73,
|
0x0a, 0x24, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73,
|
||||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x73, 0x74, 0x61, 0x74,
|
0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x73, 0x74, 0x61, 0x74,
|
||||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xff, 0x02, 0x0a, 0x0f, 0x53,
|
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x97, 0x03, 0x0a, 0x0f, 0x53,
|
||||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, 0x69, 0x6c, 0x79, 0x53, 0x74, 0x61, 0x74, 0x12, 0x1a,
|
0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, 0x69, 0x6c, 0x79, 0x53, 0x74, 0x61, 0x74, 0x12, 0x1a,
|
||||||
0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||||
0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65,
|
0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65,
|
||||||
@@ -174,8 +182,10 @@ var file_models_model_server_daily_stat_proto_rawDesc = []byte{
|
|||||||
0x61, 0x63, 0x6b, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x63, 0x68, 0x65, 0x63,
|
0x61, 0x63, 0x6b, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x63, 0x68, 0x65, 0x63,
|
||||||
0x6b, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x6e, 0x67,
|
0x6b, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x6e, 0x67,
|
||||||
0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x72, 0x61,
|
0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x72, 0x61,
|
||||||
0x66, 0x66, 0x69, 0x63, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x06, 0x5a, 0x04,
|
0x66, 0x66, 0x69, 0x63, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x16, 0x0a, 0x06,
|
||||||
0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x6c,
|
||||||
|
0x61, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||||
|
0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ type UserBill struct {
|
|||||||
Month string `protobuf:"bytes,7,opt,name=month,proto3" json:"month,omitempty"`
|
Month string `protobuf:"bytes,7,opt,name=month,proto3" json:"month,omitempty"`
|
||||||
IsPaid bool `protobuf:"varint,8,opt,name=isPaid,proto3" json:"isPaid,omitempty"`
|
IsPaid bool `protobuf:"varint,8,opt,name=isPaid,proto3" json:"isPaid,omitempty"`
|
||||||
PaidAt int64 `protobuf:"varint,9,opt,name=paidAt,proto3" json:"paidAt,omitempty"`
|
PaidAt int64 `protobuf:"varint,9,opt,name=paidAt,proto3" json:"paidAt,omitempty"`
|
||||||
|
Code string `protobuf:"bytes,10,opt,name=code,proto3" json:"code,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UserBill) Reset() {
|
func (x *UserBill) Reset() {
|
||||||
@@ -136,13 +137,20 @@ func (x *UserBill) GetPaidAt() int64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *UserBill) GetCode() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Code
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
var File_models_model_user_bill_proto protoreflect.FileDescriptor
|
var File_models_model_user_bill_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_models_model_user_bill_proto_rawDesc = []byte{
|
var file_models_model_user_bill_proto_rawDesc = []byte{
|
||||||
0x0a, 0x1c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x75,
|
0x0a, 0x1c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x75,
|
||||||
0x73, 0x65, 0x72, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02,
|
0x73, 0x65, 0x72, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02,
|
||||||
0x70, 0x62, 0x1a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c,
|
0x70, 0x62, 0x1a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c,
|
||||||
0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe8, 0x01, 0x0a, 0x08,
|
0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfc, 0x01, 0x0a, 0x08,
|
||||||
0x55, 0x73, 0x65, 0x72, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
|
0x55, 0x73, 0x65, 0x72, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
|
||||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72,
|
0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72,
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72,
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72,
|
||||||
@@ -157,8 +165,9 @@ var file_models_model_user_bill_proto_rawDesc = []byte{
|
|||||||
0x05, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x50, 0x61, 0x69, 0x64,
|
0x05, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x50, 0x61, 0x69, 0x64,
|
||||||
0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x50, 0x61, 0x69, 0x64, 0x12, 0x16,
|
0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x50, 0x61, 0x69, 0x64, 0x12, 0x16,
|
||||||
0x0a, 0x06, 0x70, 0x61, 0x69, 0x64, 0x41, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06,
|
0x0a, 0x06, 0x70, 0x61, 0x69, 0x64, 0x41, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06,
|
||||||
0x70, 0x61, 0x69, 0x64, 0x41, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06,
|
0x70, 0x61, 0x69, 0x64, 0x41, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x0a,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
|
||||||
|
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ message ServerDailyStat {
|
|||||||
int64 countAttackRequests = 8;
|
int64 countAttackRequests = 8;
|
||||||
int64 attackBytes = 9;
|
int64 attackBytes = 9;
|
||||||
bool checkTrafficLimiting = 10;
|
bool checkTrafficLimiting = 10;
|
||||||
|
int64 planId = 11;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ message UserBill {
|
|||||||
string month = 7;
|
string month = 7;
|
||||||
bool isPaid = 8;
|
bool isPaid = 8;
|
||||||
int64 paidAt = 9;
|
int64 paidAt = 9;
|
||||||
|
string code = 10;
|
||||||
}
|
}
|
||||||
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"`
|
Group *ServerGroupConfig `yaml:"group" json:"group"`
|
||||||
|
|
||||||
isOk bool
|
isOk bool
|
||||||
|
|
||||||
|
planId int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServerConfigFromJSON 从JSON中解析Server配置
|
// NewServerConfigFromJSON 从JSON中解析Server配置
|
||||||
@@ -230,6 +232,10 @@ func (this *ServerConfig) Init() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if this.UserPlan.Plan != nil {
|
||||||
|
this.planId = this.UserPlan.Plan.Id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isOk = true
|
this.isOk = true
|
||||||
@@ -368,3 +374,8 @@ func (this *ServerConfig) FindAndCheckReverseProxy(dataType string) (*ReversePro
|
|||||||
func (this *ServerConfig) ShouldCheckTrafficLimit() bool {
|
func (this *ServerConfig) ShouldCheckTrafficLimit() bool {
|
||||||
return this.TrafficLimit != nil && !this.TrafficLimit.IsEmpty()
|
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 用户套餐配置
|
// UserPlanConfig 用户套餐配置
|
||||||
type UserPlanConfig struct {
|
type UserPlanConfig struct {
|
||||||
DayTo string `yaml:"dayTo" json:"dayTo"` // 有效期
|
DayTo string `yaml:"dayTo" json:"dayTo"` // 有效期
|
||||||
|
|
||||||
|
Plan *PlanConfig `yaml:"plan" json:"plan"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init 初始化
|
// Init 初始化
|
||||||
func (this *UserPlanConfig) Init() error {
|
func (this *UserPlanConfig) Init() error {
|
||||||
|
if this.Plan != nil {
|
||||||
|
err := this.Plan.Init()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user