83 lines
2.2 KiB
Protocol Buffer
83 lines
2.2 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
|
|
package app;
|
|
option go_package = "./app";
|
|
import "google/protobuf/struct.proto";
|
|
import "google/protobuf/timestamp.proto";
|
|
message UserInfo {
|
|
optional uint64 id = 1;
|
|
optional string username = 2;
|
|
optional string email = 3;
|
|
optional string mobile = 4;
|
|
optional string password_hash = 5;
|
|
optional string salt = 6;
|
|
optional string nickname = 7;
|
|
optional string avatar = 8;
|
|
optional string gender = 9;
|
|
optional string account_status = 10;
|
|
optional uint32 is_verified = 11;
|
|
optional int64 last_login_at = 12;
|
|
optional string last_login_ip = 13;
|
|
optional int64 login_attempts = 14;
|
|
optional int64 locked_until = 15;
|
|
optional string recovery_token = 16;
|
|
optional int64 recovery_token_expiry = 17;
|
|
optional google.protobuf.Struct metadata = 20;
|
|
optional string registration_source = 21;
|
|
}
|
|
|
|
|
|
message RegisterUserRequest {
|
|
optional string email = 1;
|
|
optional string password = 2;
|
|
optional string username = 3;
|
|
optional string name = 4;
|
|
optional string mobile = 5;
|
|
optional string verificationCode = 6;
|
|
optional uint32 verificationType = 7;
|
|
optional string verificationId = 8; // 邮箱或手机号
|
|
optional string nickName = 9;
|
|
optional string registrationSource = 10;
|
|
}
|
|
message RegisterUserResponse {
|
|
UserInfo user = 1;
|
|
AuthToken auth_token = 2;
|
|
bool email_verification_required = 3;
|
|
bool phone_verification_required = 4;
|
|
}
|
|
|
|
// 认证令牌
|
|
message AuthToken {
|
|
string access_token = 1;
|
|
string refresh_token = 2;
|
|
string token_type = 3;
|
|
int32 expires_in = 4; // 过期时间(秒)
|
|
google.protobuf.Timestamp issued_at = 5;
|
|
google.protobuf.Timestamp expires_at = 6;
|
|
repeated string scopes = 7;
|
|
}
|
|
|
|
message LoginResponse{
|
|
UserInfo user = 1;
|
|
AuthToken auth_token = 2;
|
|
}
|
|
message LoginRequest {
|
|
optional string username = 1;
|
|
optional string email = 2;
|
|
optional string mobile = 3;
|
|
optional string password = 4;
|
|
optional string clientIp = 5;
|
|
optional string platform = 6;
|
|
optional string login_type = 7;
|
|
optional string login_platform = 8;
|
|
}
|
|
// App 服务定义
|
|
service App {
|
|
// 用户注册
|
|
// group: user
|
|
rpc registerUser(RegisterUserRequest) returns (RegisterUserResponse);
|
|
// 用户登录
|
|
// group: user
|
|
rpc loginUser(LoginRequest) returns (LoginResponse);
|
|
} |