topfans/backend/proto/common.proto
2026-04-07 22:29:48 +08:00

44 lines
985 B
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";
// 通用响应状态码
enum StatusCode {
STATUS_UNSPECIFIED = 0;
STATUS_OK = 200;
STATUS_BAD_REQUEST = 400;
STATUS_UNAUTHORIZED = 401;
STATUS_FORBIDDEN = 403;
STATUS_NOT_FOUND = 404;
STATUS_TOO_MANY_REQUESTS = 429;
STATUS_INTERNAL_ERROR = 500;
}
// 通用响应结构
message BaseResponse {
StatusCode code = 1; // 状态码
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 {
}