diff --git a/build/rpc.json b/build/rpc.json index f799a66..03332d3 100644 --- a/build/rpc.json +++ b/build/rpc.json @@ -15440,7 +15440,7 @@ }, { "name": "CreatePlanRequest", - "code": "message CreatePlanRequest {\n\tstring name = 1;\n\tint64 clusterId = 2;\n\tbytes trafficLimitJSON = 3;\n\tbytes featuresJSON = 4;\n\tstring priceType = 5;\n\tbytes trafficPriceJSON = 6;\n\tbytes bandwidthPriceJSON = 10;\n\tfloat monthlyPrice = 7;\n\tfloat seasonallyPrice = 8;\n\tfloat yearlyPrice = 9;\n\tint32 totalServers = 11; // 可以添加的网站数\n\tint32 totalServerNamesPerServer = 12; // 每个网站可以添加的域名数\n\tint32 totalServerNames = 13; // 可以添加的域名总数\n}", + "code": "message CreatePlanRequest {\n\tstring name = 1;\n\tint64 clusterId = 2;\n\tbytes trafficLimitJSON = 3;\n\tbytes featuresJSON = 4;\n\tstring priceType = 5;\n\tbytes trafficPriceJSON = 6;\n\tbytes bandwidthPriceJSON = 10;\n\tfloat monthlyPrice = 7;\n\tfloat seasonallyPrice = 8;\n\tfloat yearlyPrice = 9;\n\tint32 totalServers = 11; // 可以添加的网站数\n\tint32 totalServerNamesPerServer = 12; // 每个网站可以添加的域名数\n\tint32 totalServerNames = 13; // 可以添加的域名总数\n\tint64 dailyRequests = 14; // 每日访问量额度\n\tint64 monthlyRequests = 15; // 每月访问量额度\n}", "doc": "创建套餐" }, { @@ -21075,7 +21075,7 @@ }, { "name": "Plan", - "code": "message Plan {\n\tint64 id = 1;\n\tbool isOn = 2;\n\tstring name = 3;\n\tint64 clusterId = 4;\n\tbytes trafficLimitJSON = 5;\n\tbytes featuresJSON = 6;\n\tstring priceType = 7;\n\tbytes trafficPriceJSON = 8;\n\tbytes bandwidthPriceJSON = 12;\n\tdouble monthlyPrice = 9;\n\tdouble seasonallyPrice = 10;\n\tdouble yearlyPrice = 11;\n\tint32 totalServers = 13; // 可以添加的网站数\n\tint32 totalServerNamesPerServer = 14; // 每个网站可以添加的域名数\n\tint32 totalServerNames = 15; // 可以添加的域名总数\n}", + "code": "message Plan {\n\tint64 id = 1;\n\tbool isOn = 2;\n\tstring name = 3;\n\tint64 clusterId = 4;\n\tbytes trafficLimitJSON = 5;\n\tbytes featuresJSON = 6;\n\tstring priceType = 7;\n\tbytes trafficPriceJSON = 8;\n\tbytes bandwidthPriceJSON = 12;\n\tdouble monthlyPrice = 9;\n\tdouble seasonallyPrice = 10;\n\tdouble yearlyPrice = 11;\n\tint32 totalServers = 13; // 可以添加的网站数\n\tint32 totalServerNamesPerServer = 14; // 每个网站可以添加的域名数\n\tint32 totalServerNames = 15; // 可以添加的域名总数\n\tint64 dailyRequests = 16; // 每日访问量额度\n\tint64 monthlyRequests = 17; // 每月访问量额度\n}", "doc": "" }, { @@ -22450,7 +22450,7 @@ }, { "name": "UpdatePlanRequest", - "code": "message UpdatePlanRequest {\n\tint64 planId = 1;\n\tstring name = 2;\n\tbool isOn = 3;\n\tint64 clusterId = 4;\n\tbytes trafficLimitJSON = 5;\n\tbytes featuresJSON = 6;\n\tstring priceType = 7;\n\tbytes trafficPriceJSON = 8;\n\tbytes bandwidthPriceJSON = 12;\n\tfloat monthlyPrice = 9;\n\tfloat seasonallyPrice = 10;\n\tfloat yearlyPrice = 11;\n\tint32 totalServers = 13; // 可以添加的网站数\n\tint32 totalServerNamesPerServer = 14; // 每个网站可以添加的域名数\n\tint32 totalServerNames = 15; // 可以添加的域名总数\n}", + "code": "message UpdatePlanRequest {\n\tint64 planId = 1;\n\tstring name = 2;\n\tbool isOn = 3;\n\tint64 clusterId = 4;\n\tbytes trafficLimitJSON = 5;\n\tbytes featuresJSON = 6;\n\tstring priceType = 7;\n\tbytes trafficPriceJSON = 8;\n\tbytes bandwidthPriceJSON = 12;\n\tfloat monthlyPrice = 9;\n\tfloat seasonallyPrice = 10;\n\tfloat yearlyPrice = 11;\n\tint32 totalServers = 13; // 可以添加的网站数\n\tint32 totalServerNamesPerServer = 14; // 每个网站可以添加的域名数\n\tint32 totalServerNames = 15; // 可以添加的域名总数\n\tint64 dailyRequests = 16; // 每日访问量额度\n\tint64 monthlyRequests = 17; // 每月访问量额度\n}", "doc": "修改套餐" }, { diff --git a/pkg/rpc/pb/model_plan.pb.go b/pkg/rpc/pb/model_plan.pb.go index ea0d31f..2acf3c7 100644 --- a/pkg/rpc/pb/model_plan.pb.go +++ b/pkg/rpc/pb/model_plan.pb.go @@ -40,6 +40,8 @@ type Plan struct { TotalServers int32 `protobuf:"varint,13,opt,name=totalServers,proto3" json:"totalServers,omitempty"` // 可以添加的网站数 TotalServerNamesPerServer int32 `protobuf:"varint,14,opt,name=totalServerNamesPerServer,proto3" json:"totalServerNamesPerServer,omitempty"` // 每个网站可以添加的域名数 TotalServerNames int32 `protobuf:"varint,15,opt,name=totalServerNames,proto3" json:"totalServerNames,omitempty"` // 可以添加的域名总数 + DailyRequests int64 `protobuf:"varint,16,opt,name=dailyRequests,proto3" json:"dailyRequests,omitempty"` // 每日访问量额度 + MonthlyRequests int64 `protobuf:"varint,17,opt,name=monthlyRequests,proto3" json:"monthlyRequests,omitempty"` // 每月访问量额度 } func (x *Plan) Reset() { @@ -179,11 +181,25 @@ func (x *Plan) GetTotalServerNames() int32 { return 0 } +func (x *Plan) GetDailyRequests() int64 { + if x != nil { + return x.DailyRequests + } + return 0 +} + +func (x *Plan) GetMonthlyRequests() int64 { + if x != nil { + return x.MonthlyRequests + } + return 0 +} + var File_models_model_plan_proto protoreflect.FileDescriptor var file_models_model_plan_proto_rawDesc = []byte{ 0x0a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x70, - 0x6c, 0x61, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xa4, 0x04, + 0x6c, 0x61, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xf4, 0x04, 0x0a, 0x04, 0x50, 0x6c, 0x61, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, @@ -218,7 +234,12 @@ var file_models_model_plan_proto_rawDesc = []byte{ 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, - 0x61, 0x6d, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x61, 0x6d, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x61, 0x69, + 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6d, 0x6f, + 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x11, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } diff --git a/pkg/rpc/pb/service_plan.pb.go b/pkg/rpc/pb/service_plan.pb.go index c060867..966bc3e 100644 --- a/pkg/rpc/pb/service_plan.pb.go +++ b/pkg/rpc/pb/service_plan.pb.go @@ -39,6 +39,8 @@ type CreatePlanRequest struct { TotalServers int32 `protobuf:"varint,11,opt,name=totalServers,proto3" json:"totalServers,omitempty"` // 可以添加的网站数 TotalServerNamesPerServer int32 `protobuf:"varint,12,opt,name=totalServerNamesPerServer,proto3" json:"totalServerNamesPerServer,omitempty"` // 每个网站可以添加的域名数 TotalServerNames int32 `protobuf:"varint,13,opt,name=totalServerNames,proto3" json:"totalServerNames,omitempty"` // 可以添加的域名总数 + DailyRequests int64 `protobuf:"varint,14,opt,name=dailyRequests,proto3" json:"dailyRequests,omitempty"` // 每日访问量额度 + MonthlyRequests int64 `protobuf:"varint,15,opt,name=monthlyRequests,proto3" json:"monthlyRequests,omitempty"` // 每月访问量额度 } func (x *CreatePlanRequest) Reset() { @@ -164,6 +166,20 @@ func (x *CreatePlanRequest) GetTotalServerNames() int32 { return 0 } +func (x *CreatePlanRequest) GetDailyRequests() int64 { + if x != nil { + return x.DailyRequests + } + return 0 +} + +func (x *CreatePlanRequest) GetMonthlyRequests() int64 { + if x != nil { + return x.MonthlyRequests + } + return 0 +} + type CreatePlanResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -232,6 +248,8 @@ type UpdatePlanRequest struct { TotalServers int32 `protobuf:"varint,13,opt,name=totalServers,proto3" json:"totalServers,omitempty"` // 可以添加的网站数 TotalServerNamesPerServer int32 `protobuf:"varint,14,opt,name=totalServerNamesPerServer,proto3" json:"totalServerNamesPerServer,omitempty"` // 每个网站可以添加的域名数 TotalServerNames int32 `protobuf:"varint,15,opt,name=totalServerNames,proto3" json:"totalServerNames,omitempty"` // 可以添加的域名总数 + DailyRequests int64 `protobuf:"varint,16,opt,name=dailyRequests,proto3" json:"dailyRequests,omitempty"` // 每日访问量额度 + MonthlyRequests int64 `protobuf:"varint,17,opt,name=monthlyRequests,proto3" json:"monthlyRequests,omitempty"` // 每月访问量额度 } func (x *UpdatePlanRequest) Reset() { @@ -371,6 +389,20 @@ func (x *UpdatePlanRequest) GetTotalServerNames() int32 { return 0 } +func (x *UpdatePlanRequest) GetDailyRequests() int64 { + if x != nil { + return x.DailyRequests + } + return 0 +} + +func (x *UpdatePlanRequest) GetMonthlyRequests() int64 { + if x != nil { + return x.MonthlyRequests + } + return 0 +} + // 删除套餐 type DeletePlanRequest struct { state protoimpl.MessageState @@ -711,7 +743,7 @@ var file_service_plan_proto_rawDesc = []byte{ 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x70, 0x6c, 0x61, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x04, 0x0a, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xdd, 0x04, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, @@ -744,10 +776,15 @@ var file_service_plan_proto_rawDesc = []byte{ 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x6f, 0x74, 0x61, - 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x2c, 0x0a, 0x12, + 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, + 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x0e, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6d, 0x6f, 0x6e, + 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x22, 0x2c, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x06, 0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x22, 0xb9, 0x04, 0x0a, 0x11, 0x55, + 0x28, 0x03, 0x52, 0x06, 0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x22, 0x89, 0x05, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, @@ -783,7 +820,12 @@ var file_service_plan_proto_rawDesc = []byte{ 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x2b, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, + 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, + 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, + 0x11, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x22, 0x2b, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x22, 0x30, 0x0a, 0x16, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, diff --git a/pkg/rpc/protos/models/model_plan.proto b/pkg/rpc/protos/models/model_plan.proto index 79e7ef9..f60fbc3 100644 --- a/pkg/rpc/protos/models/model_plan.proto +++ b/pkg/rpc/protos/models/model_plan.proto @@ -19,4 +19,6 @@ message Plan { int32 totalServers = 13; // 可以添加的网站数 int32 totalServerNamesPerServer = 14; // 每个网站可以添加的域名数 int32 totalServerNames = 15; // 可以添加的域名总数 + int64 dailyRequests = 16; // 每日访问量额度 + int64 monthlyRequests = 17; // 每月访问量额度 } \ No newline at end of file diff --git a/pkg/rpc/protos/service_plan.proto b/pkg/rpc/protos/service_plan.proto index 4242217..23d3bb8 100644 --- a/pkg/rpc/protos/service_plan.proto +++ b/pkg/rpc/protos/service_plan.proto @@ -45,6 +45,8 @@ message CreatePlanRequest { int32 totalServers = 11; // 可以添加的网站数 int32 totalServerNamesPerServer = 12; // 每个网站可以添加的域名数 int32 totalServerNames = 13; // 可以添加的域名总数 + int64 dailyRequests = 14; // 每日访问量额度 + int64 monthlyRequests = 15; // 每月访问量额度 } message CreatePlanResponse { @@ -68,6 +70,8 @@ message UpdatePlanRequest { int32 totalServers = 13; // 可以添加的网站数 int32 totalServerNamesPerServer = 14; // 每个网站可以添加的域名数 int32 totalServerNames = 15; // 可以添加的域名总数 + int64 dailyRequests = 16; // 每日访问量额度 + int64 monthlyRequests = 17; // 每月访问量额度 } // 删除套餐 diff --git a/pkg/serverconfigs/traffic_limit_status.go b/pkg/serverconfigs/traffic_limit_status.go index 99a1e4f..19eace9 100644 --- a/pkg/serverconfigs/traffic_limit_status.go +++ b/pkg/serverconfigs/traffic_limit_status.go @@ -4,11 +4,19 @@ package serverconfigs import timeutil "github.com/iwind/TeaGo/utils/time" +type TrafficLimitTarget = string + +const ( + TrafficLimitTargetTraffic TrafficLimitTarget = "traffic" + TrafficLimitTargetRequest TrafficLimitTarget = "request" +) + // TrafficLimitStatus 流量限制状态 type TrafficLimitStatus struct { - UntilDay string `yaml:"untilDay" json:"untilDay"` // 有效日期,格式YYYYMMDD - PlanId int64 `yaml:"planId" json:"planId"` // 套餐ID - DateType string `yaml:"dateType" json:"dateType"` // 日期类型 day|month + 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|... } func (this *TrafficLimitStatus) IsValid() bool {