增加套餐相关代码

This commit is contained in:
GoEdgeLab
2021-10-29 14:02:49 +08:00
parent 3df2751dcd
commit 047b200ce2
9 changed files with 3093 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
message Plan {
int64 id = 1;
bool isOn = 2;
string name = 3;
int64 clusterId = 4;
bytes bandwidthLimitJSON = 5;
bytes featuresJSON = 6;
string priceType = 7;
bytes bandwidthPriceJSON = 8;
float monthlyPrice = 9;
float seasonallyPrice = 10;
float yearlyPrice = 11;
}

View File

@@ -0,0 +1,19 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
import "models/model_user.proto";
import "models/model_plan.proto";
message UserPlan {
int64 id = 1;
int64 userId = 2;
int64 planId = 3;
bool isOn = 4;
string dayTo = 5;
User user = 30;
Plan plan = 31;
}

View File

@@ -0,0 +1,97 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
import "models/model_plan.proto";
import "models/rpc_messages.proto";
// 套餐相关服务
service PlanService {
// 创建套餐
rpc createPlan(CreatePlanRequest) returns (CreatePlanResponse);
// 修改套餐
rpc updatePlan(UpdatePlanRequest) returns (RPCSuccess);
// 删除套餐
rpc deletePlan(DeletePlanRequest) returns (RPCSuccess);
// 查找单个套餐
rpc findEnabledPlan(FindEnabledPlanRequest) returns (FindEnabledPlanResponse);
// 计算套餐数量
rpc countAllEnabledPlans(CountAllEnabledPlansRequest) returns (RPCCountResponse);
// 列出单页套餐
rpc listEnabledPlans(ListEnabledPlansRequest) returns (ListEnabledPlansResponse);
// 对套餐进行排序
rpc sortPlans(SortPlansRequest) returns (RPCSuccess);
}
// 创建套餐
message CreatePlanRequest {
string name = 1;
int64 clusterId = 2;
bytes bandwidthLimitJSON = 3;
bytes featuresJSON = 4;
string priceType = 5;
bytes bandwidthPriceJSON = 6;
float monthlyPrice = 7;
float seasonallyPrice = 8;
float yearlyPrice = 9;
}
message CreatePlanResponse {
int64 planId = 1;
}
// 修改套餐
message UpdatePlanRequest {
int64 planId = 1;
string name = 2;
bool isOn = 3;
int64 clusterId = 4;
bytes bandwidthLimitJSON = 5;
bytes featuresJSON = 6;
string priceType = 7;
bytes bandwidthPriceJSON = 8;
float monthlyPrice = 9;
float seasonallyPrice = 10;
float yearlyPrice = 11;
}
// 删除套餐
message DeletePlanRequest {
int64 planId = 1;
}
// 查找单个套餐
message FindEnabledPlanRequest {
int64 planId = 1;
}
message FindEnabledPlanResponse {
Plan plan = 1;
}
// 计算套餐数量
message CountAllEnabledPlansRequest {
}
// 列出单页套餐
message ListEnabledPlansRequest {
int64 offset = 1;
int64 size = 2;
}
message ListEnabledPlansResponse {
repeated Plan plans = 1;
}
// 对套餐进行排序
message SortPlansRequest {
repeated int64 planIds = 1;
}

View File

@@ -0,0 +1,83 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
import "models/rpc_messages.proto";
import "models/model_user_plan.proto";
// 用户购买的套餐
service UserPlanService {
// 添加已购套餐
rpc createUserPlan(CreateUserPlanRequest) returns (CreateUserPlanResponse);
// 查找单个已购套餐信息
rpc findEnabledUserPlan(FindEnabledUserPlanRequest) returns (FindEnabledUserPlanResponse);
// 修改已购套餐
rpc updateUserPlan(UpdateUserPlanRequest) returns (RPCSuccess);
// 删除已购套餐
rpc deleteUserPlan(DeleteUserPlanRequest) returns (RPCSuccess);
// 计算已购套餐数
rpc countAllEnabledUserPlans(CountAllEnabledUserPlansRequest) returns (RPCCountResponse);
// 列出单页已购套餐
rpc listEnabledUserPlans(ListEnabledUserPlansRequest) returns (ListEnabledUserPlansResponse);
}
// 添加已购套餐
message CreateUserPlanRequest{
int64 userId = 1;
int64 planId = 2;
string dayTo = 3;
}
message CreateUserPlanResponse {
int64 userPlanId = 1;
}
// 查找单个已购套餐信息
message FindEnabledUserPlanRequest {
int64 userPlanId = 1;
}
message FindEnabledUserPlanResponse {
UserPlan userPlan = 1;
}
// 修改已购套餐
message UpdateUserPlanRequest {
int64 userPlanId = 1;
int64 planId = 2;
string dayTo = 3;
bool isOn = 4;
}
// 删除已购套餐
message DeleteUserPlanRequest {
int64 userPlanId = 1;
}
// 计算已购套餐数
message CountAllEnabledUserPlansRequest {
bool isAvailable = 1;
bool isExpired = 2;
int32 expiringDays = 3;
int64 userId = 4;
}
// 列出单页已购套餐
message ListEnabledUserPlansRequest {
bool isAvailable = 1;
bool isExpired = 2;
int32 expiringDays = 3;
int64 userId = 4;
int64 offset = 5;
int64 size = 6;
}
message ListEnabledUserPlansResponse {
repeated UserPlan userPlans = 1;
}