From 4ac8e521274429b18e13144c669cbb870f00d19a Mon Sep 17 00:00:00 2001 From: zyj <18107291228@163.com> Date: Sat, 30 Aug 2025 18:05:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7rpc?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proto/user.proto | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/proto/user.proto b/proto/user.proto index 058fb9e..180ec69 100644 --- a/proto/user.proto +++ b/proto/user.proto @@ -3,45 +3,52 @@ syntax = "proto3"; package user; option go_package = "./proto;userpb"; +// 登录请求 message LoginRequest { string username = 1; string password = 2; } +// 登录响应 message LoginResponse { - string token = 1; - UserInfo user_info = 2; + string user_id = 1; + string username = 2; + string email = 3; + string access_token = 4; + int32 expires_in = 5; // token过期时间(秒) } +// 用户注册请求 message RegisterRequest { string username = 1; string password = 2; string email = 3; } +// 用户注册响应 message RegisterResponse { - bool success = 1; - string message = 2; - UserInfo user_info = 3; -} - -message UserInfo { - string id = 1; + string user_id = 1; string username = 2; string email = 3; } -message TokenRequest { - string token = 1; +// 令牌验证请求 +message ValidateTokenRequest { + string access_token = 1; } -message ValidateResponse { - bool valid = 1; - UserInfo user_info = 2; +// 令牌验证响应 +message ValidateTokenResponse { + string user_id = 1; + bool is_valid = 2; } +// 用户服务定义 service UserService { + // 用户登录 rpc Login(LoginRequest) returns (LoginResponse); + // 用户注册 rpc Register(RegisterRequest) returns (RegisterResponse); - rpc ValidateToken(TokenRequest) returns (ValidateResponse); + // 验证访问令牌 + rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse); } \ No newline at end of file