youtu_grpc/ranking_management/ranking_management.proto
2025-02-05 18:45:49 +08:00

50 lines
1.2 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package ranking_management;
option go_package = "./ranking_management";
message Request {
string ping = 1;
}
message Response {
string pong = 1;
}
// 定义SetUserGameScoreRequest消息类型
message SetUserGameScoreRequest {
uint32 score = 1; // 对应json的"score"
uint32 type = 2; // 对应json的"type", 带默认值0
uint32 userId = 3;
}
// 定义RankingData消息类型
message RankingData {
string nickname = 1; // 昵称对应db:"nickname"
string avatar = 2; // 头像对应db:"avatar"
uint32 score = 3; // 得分对应db:"score"
uint64 user_id = 4; // 用户ID对应db:"app_user_id"
uint32 rank = 5; // 排名对应db:"rank"
bool self = 6; // 是否自我判断
}
// 定义分页请求参数(如果有的话)
message PageRequest {
int32 page = 1;
int32 limit = 2;
}
// 定义Base响应结构
message BaseResult {
int32 error_code = 1; // 错误码
string error_msg = 2; // 错误信息
}
service Ranking_management {
rpc Ping(Request) returns(Response);
rpc SetUserGameScore (SetUserGameScoreRequest) returns (BaseResult);
rpc GetRankingList (PageRequest) returns (stream RankingData);
}