实现用户系统手机号码绑定和登录(商业版)

This commit is contained in:
GoEdgeLab
2023-11-17 11:51:02 +08:00
parent 1a616e3e80
commit 8ce4b69a76
18 changed files with 1990 additions and 273 deletions

View File

@@ -11,10 +11,11 @@ message User {
int64 id = 1; // 用户ID
string username = 2; // 用户名
string fullname = 3; // 全称
string mobile = 4;
string tel = 5;
string email = 6;
string verifiedEmail = 20;
string mobile = 4; // 手机号码
string tel = 5; // 联系电话
string email = 6; // 联系邮箱
string verifiedEmail = 20; // 已验证邮箱
string verifiedMobile = 23; // 已验证手机号码
string remark = 7;
bool isOn = 8;
int64 createdAt = 9;
@@ -23,8 +24,8 @@ message User {
bool isRejected = 14;
string rejectReason = 15;
bool isDeleted = 16;
bool isIndividualIdentified = 17;
bool isEnterpriseIdentified = 18;
bool isIndividualIdentified = 17; // 是否已通过个人验证
bool isEnterpriseIdentified = 18; // 是否已通过企业验证
string bandwidthAlgo = 21; // 带宽算法
string lang = 22; // 语言代号

View File

@@ -0,0 +1,16 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
// 手机号码认证
message UserMobileVerification {
int64 id = 1; // ID
string mobile = 2; // 手机号码
int64 userId = 3; // 用户ID
string code = 4; // 代号
int64 createdAt = 5; // 创建时间
bool isSent = 6; // 已发送
bool isVerified = 7; // 已激活
int64 expiresAt = 8; // 过期时间,动态计算而来
}

View File

@@ -0,0 +1,23 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
// 短信发送服务
service SMSSenderService {
// 发送短信
rpc sendSMS(SendSMSRequest) returns (SendSMSResponse);
}
// 发送短信
message SendSMSRequest {
string mobile = 1; // 手机号
string body = 2; // 内容
string type = 3; // 渠道类型webHook ...
bytes paramsJSON = 4; // 参数
}
message SendSMSResponse {
bool isOk = 1; // 是否成功
string result = 2; // 发送返回内容,只有失败时才会有数据
}

View File

@@ -88,6 +88,9 @@ service UserService {
// 检查邮箱是否已被使用
rpc checkUserEmail(CheckUserEmailRequest) returns (CheckUserEmailResponse);
// 检查手机号码是否已被使用
rpc checkUserMobile(CheckUserMobileRequest) returns (CheckUserMobileResponse);
// 根据用户名查询用户绑定的邮箱
rpc findUserVerifiedEmailWithUsername(FindUserVerifiedEmailWithUsernameRequest) returns (FindUserVerifiedEmailWithUsernameResponse);
}
@@ -378,6 +381,15 @@ message CheckUserEmailResponse {
bool exists = 1; // 是否已被使用
}
// 检查手机号码是否已被验证
message CheckUserMobileRequest {
string mobile = 1; // 手机号码
}
message CheckUserMobileResponse {
bool exists = 1; // 是否已被使用
}
// 根据用户名查询用户绑定的邮箱
message FindUserVerifiedEmailWithUsernameRequest {
string username = 1; // 用户名

View File

@@ -0,0 +1,50 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
import "models/model_user_mobile_verification.proto";
// 用户手机号码认证服务
service UserMobileVerificationService {
// 认证手机号码
rpc verifyUserMobile(VerifyUserMobileRequest) returns (VerifyUserMobileResponse);
// 发送手机号码认证
rpc sendUserMobileVerification(SendUserMobileVerificationRequest) returns (SendUserMobileVerificationResponse);
// 查找用户正在等待激活的认证
rpc findLatestUserMobileVerification(FindLatestUserMobileVerificationRequest) returns (FindLatestUserMobileVerificationResponse);
}
// 认证手机号码
message VerifyUserMobileRequest {
string mobile = 1; // 手机号
string code = 2; // 激活码
}
message VerifyUserMobileResponse {
int64 userId = 1; // 手机号码对应的用户ID
string mobile = 2; // 手机号码
string errorCode = 3; // 错误代号,如果为空,说明没有错误
string errorMessage = 4; // 错误信息
}
// 发送手机号码认证
message SendUserMobileVerificationRequest {
string mobile = 1; // 待验证手机号码
}
message SendUserMobileVerificationResponse {
bool isOk = 1; // 是否发送成功
string errorCode = 2; // 错误代号
}
// 查找用户正在等待激活的认证
message FindLatestUserMobileVerificationRequest {
}
message FindLatestUserMobileVerificationResponse {
UserMobileVerification userMobileVerification = 1;
}