topfans/backend/proto/common.proto
2026-06-15 16:28:35 +08:00

39 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 topfans.common;
option go_package = "github.com/topfans/backend/pkg/proto/common;common";
// 通用响应结构
// code 字段语义:google.rpc.Code 数字
// 0 = OK
// 3 = INVALID_ARGUMENT (旧 HTTP 400)
// 5 = NOT_FOUND (旧 HTTP 404)
// 7 = PERMISSION_DENIED (旧 HTTP 403,账号封禁/冻结)
// 8 = RESOURCE_EXHAUSTED (旧 HTTP 429,限流/冷静期)
// 13 = INTERNAL (旧 HTTP 500,内部错)
// 16 = UNAUTHENTICATED (旧 HTTP 401,鉴权失败)
message BaseResponse {
uint32 code = 1; // google.rpc.Code 数字(0=OK, 3=INVALID_ARGUMENT, 5=NOT_FOUND, 7=PERMISSION_DENIED, 8=RESOURCE_EXHAUSTED, 13=INTERNAL, 16=UNAUTHENTICATED)
string message = 2; // 错误信息(成功时为空)
int64 timestamp = 3; // 响应时间戳Unix时间戳毫秒
}
// 分页请求--如好友功能
message PageRequest {
int32 page = 1; // 页码从1开始
int32 page_size = 2; // 每页数量
}
// 分页响应
message PageResponse {
int32 page = 1;
int32 page_size = 2;
int64 total = 3; // 总记录数
int32 total_pages = 4; // 总页数
}
// 空消息用于无参数的RPC方法
message Empty {
}