123 lines
2.8 KiB
Protocol Buffer
123 lines
2.8 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package app;
|
|
option go_package = "./app";
|
|
|
|
import "google/protobuf/struct.proto";
|
|
|
|
import "google/protobuf/timestamp.proto";
|
|
|
|
// 账户类型枚举(手机/邮箱)
|
|
enum AccountType {
|
|
UNKNOWN = 0;
|
|
MOBILE = 1;
|
|
EMAIL = 2;
|
|
}
|
|
|
|
// 验证码类型枚举
|
|
enum VerifyCodeType {
|
|
REGISTER = 0;
|
|
LOGIN = 1;
|
|
RESET_PASSWORD = 2;
|
|
BIND_PHONE = 3;
|
|
BIND_EMAIL = 4;
|
|
UPDATE_PHONE = 5;
|
|
UPDATE_EMAIL = 6;
|
|
WITHDRAW = 7;
|
|
CHANGE_PAY_PASSWORD = 8;
|
|
}
|
|
|
|
// 认证令牌
|
|
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 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;
|
|
}
|
|
|
|
message LoginResponse {
|
|
UserInfo user = 1;
|
|
AuthToken auth_token = 2;
|
|
}
|
|
|
|
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 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 VerifyCodeReq {
|
|
VerifyCodeType type = 1;
|
|
AccountType account_type = 2;
|
|
string value = 3;
|
|
}
|
|
|
|
message VerifyCodeResp {
|
|
optional string code = 1;
|
|
optional uint32 expire = 2;
|
|
}
|
|
|
|
// App 服务定义
|
|
service App {
|
|
// 获取验证码
|
|
// group: code
|
|
rpc GetVerifyCode(VerifyCodeReq) returns (VerifyCodeResp);
|
|
// 用户注册
|
|
// group: user
|
|
rpc registerUser(RegisterUserRequest) returns (RegisterUserResponse);
|
|
// 用户登录
|
|
// group: user
|
|
rpc loginUser(LoginRequest) returns (LoginResponse);
|
|
}
|
|
|