syntax = "proto3";
option go_package = "./pb";

package pb;

import "models/rpc_messages.proto";
import "models/model_user_plan.proto";

// 用户购买的套餐
service UserPlanService {
	// 购买套餐
	rpc buyUserPlan(BuyUserPlanRequest) returns (BuyUserPlanResponse);

	// 续费套餐
	rpc renewUserPlan(RenewUserPlanRequest) returns (RPCSuccess);

	// 查找单个已购套餐信息
	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);

	// 查找所有服务可用的套餐
	rpc findAllEnabledUserPlansForServer(FindAllEnabledUserPlansForServerRequest) returns (FindAllEnabledUserPlansForServerResponse);
}

// 添加已购套餐
message BuyUserPlanRequest{
	int64 userId = 1;
	int64 planId = 2;
	string dayTo = 3;
	string period = 4;
	int32  countPeriod = 5;
}

message BuyUserPlanResponse {
	int64 userPlanId = 1;
}

// 续费套餐
message RenewUserPlanRequest {
	int64 userPlanId = 1;
	string dayTo = 3;
	string period = 4;
	int32  countPeriod = 5;
}

// 查找单个已购套餐信息
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;
}

// 查找所有服务可用的套餐
message FindAllEnabledUserPlansForServerRequest {
	int64 userId = 1;
	int64 serverId = 2;
}

message FindAllEnabledUserPlansForServerResponse {
	repeated UserPlan userPlans = 1;
}