355 lines
9.2 KiB
Protocol Buffer
355 lines
9.2 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
option go_package = "./pb";
|
|
|
|
package pb;
|
|
|
|
// ------------------------------------
|
|
// Messages
|
|
// ------------------------------------
|
|
|
|
//--------------------------------users--------------------------------
|
|
//--------------------------------users--------------------------------
|
|
message Users {
|
|
int64 id = 1; //id
|
|
string username = 2; //username
|
|
string passwordHash = 3; //passwordHash
|
|
string phone = 4; //phone
|
|
string email = 5; //email
|
|
string nickname = 6; //nickname
|
|
string avatar = 7; //avatar
|
|
string bio = 8; //bio
|
|
string currentRole = 9; //currentRole
|
|
repeated string verifiedRoles = 10; //verifiedRoles
|
|
string verificationStatus = 11; //verificationStatus
|
|
bool isAdmin = 12; //isAdmin
|
|
int64 createdAt = 13; //createdAt
|
|
int64 updatedAt = 14; //updatedAt
|
|
int64 deletedAt = 15; //deletedAt
|
|
}
|
|
|
|
message AddUsersReq {
|
|
string username = 1; //username
|
|
string passwordHash = 2; //passwordHash
|
|
string phone = 3; //phone
|
|
string email = 4; //email
|
|
string nickname = 5; //nickname
|
|
string avatar = 6; //avatar
|
|
string bio = 7; //bio
|
|
string currentRole = 8; //currentRole
|
|
repeated string verifiedRoles = 9; //verifiedRoles
|
|
string verificationStatus = 10; //verificationStatus
|
|
bool isAdmin = 11; //isAdmin
|
|
int64 createdAt = 12; //createdAt
|
|
int64 updatedAt = 13; //updatedAt
|
|
int64 deletedAt = 14; //deletedAt
|
|
}
|
|
|
|
message AddUsersResp {
|
|
}
|
|
|
|
message UpdateUsersReq {
|
|
int64 id = 1; //id
|
|
optional string username = 2; //username
|
|
optional string passwordHash = 3; //passwordHash
|
|
optional string phone = 4; //phone
|
|
optional string email = 5; //email
|
|
optional string nickname = 6; //nickname
|
|
optional string avatar = 7; //avatar
|
|
optional string bio = 8; //bio
|
|
optional string currentRole = 9; //currentRole
|
|
repeated string verifiedRoles = 10; //verifiedRoles
|
|
optional string verificationStatus = 11; //verificationStatus
|
|
optional bool isAdmin = 12; //isAdmin
|
|
optional int64 createdAt = 13; //createdAt
|
|
optional int64 updatedAt = 14; //updatedAt
|
|
optional int64 deletedAt = 15; //deletedAt
|
|
}
|
|
|
|
message UpdateUsersResp {
|
|
}
|
|
|
|
message DelUsersReq {
|
|
int64 id = 1; //id
|
|
}
|
|
|
|
message DelUsersResp {
|
|
}
|
|
|
|
message GetUsersByIdReq {
|
|
int64 id = 1; //id
|
|
}
|
|
|
|
message GetUsersByIdResp {
|
|
Users users = 1; //users
|
|
}
|
|
|
|
message SearchUsersReq {
|
|
optional int64 page = 1; //page
|
|
optional int64 limit = 2; //limit
|
|
optional int64 id = 3; //id
|
|
optional string username = 4; //username
|
|
optional string passwordHash = 5; //passwordHash
|
|
optional string phone = 6; //phone
|
|
optional string email = 7; //email
|
|
optional string nickname = 8; //nickname
|
|
optional string avatar = 9; //avatar
|
|
optional string bio = 10; //bio
|
|
optional string currentRole = 11; //currentRole
|
|
repeated string verifiedRoles = 12; //verifiedRoles
|
|
optional string verificationStatus = 13; //verificationStatus
|
|
optional bool isAdmin = 14; //isAdmin
|
|
optional int64 createdAt = 15; //createdAt
|
|
optional int64 updatedAt = 16; //updatedAt
|
|
optional int64 deletedAt = 17; //deletedAt
|
|
}
|
|
|
|
message SearchUsersResp {
|
|
repeated Users users = 1; //users
|
|
}
|
|
|
|
message GetUserByUsernameReq {
|
|
string username = 1; //username
|
|
}
|
|
|
|
message GetUserByUsernameResp {
|
|
Users users = 1; //users
|
|
}
|
|
|
|
message LoginReq {
|
|
string username = 1;
|
|
string passwd = 2;
|
|
}
|
|
|
|
message LoginResp {
|
|
string token = 1;
|
|
string username = 2;
|
|
string email = 3;
|
|
int64 id = 4;
|
|
}
|
|
|
|
message ValidateTokenReq {
|
|
string token = 1; // JWT token
|
|
int64 userId = 2; // 用户ID
|
|
}
|
|
|
|
message ValidateTokenResp {
|
|
bool valid = 1; // token 是否有效(不在黑名单中)
|
|
string message = 2; // 验证失败原因
|
|
int64 userId = 3; // 用户ID
|
|
string roleType = 4; // 用户角色
|
|
}
|
|
|
|
message CheckPermissionReq {
|
|
int64 userId = 1; // 用户ID
|
|
string resource = 2; // 资源 ID
|
|
string action = 3; // 操作类型: read/write/delete
|
|
}
|
|
|
|
message CheckPermissionResp {
|
|
bool allowed = 1; // 是否有权限
|
|
string message = 2; // 拒绝原因
|
|
}
|
|
|
|
message RegisterReq {
|
|
string username = 1;
|
|
string passwd = 2;
|
|
string phone = 3;
|
|
string vcode = 4;
|
|
string email = 5;
|
|
string requestId = 6;
|
|
}
|
|
|
|
message RegisterResp {
|
|
string res = 1;
|
|
}
|
|
|
|
message LogoutReq {
|
|
int64 userId = 1;
|
|
}
|
|
|
|
message LogoutResp {
|
|
|
|
}
|
|
|
|
message ResetPasswordReq {
|
|
string newPassword = 1;
|
|
string email = 2;
|
|
string requestId = 3;
|
|
string vcode = 4;
|
|
}
|
|
|
|
message ResetPasswordResp {
|
|
|
|
}
|
|
|
|
message SwitchRoleReq {
|
|
int64 userId = 1;
|
|
string newRole = 2;
|
|
}
|
|
|
|
message SwitchRoleResp {
|
|
bool success = 1;
|
|
}
|
|
|
|
//--------------------------------userFollows--------------------------------
|
|
message UserFollows {
|
|
int64 id = 1; //id
|
|
int64 followerId = 2; //followerId
|
|
int64 followeeId = 3; //followeeId
|
|
int64 createdAt = 4; //createdAt
|
|
}
|
|
|
|
message AddUserFollowsReq {
|
|
int64 followerId = 1; //followerId
|
|
int64 followeeId = 2; //followeeId
|
|
int64 createdAt = 3; //createdAt
|
|
}
|
|
|
|
message AddUserFollowsResp {
|
|
}
|
|
|
|
message UpdateUserFollowsReq {
|
|
int64 id = 1; //id
|
|
int64 followerId = 2; //followerId
|
|
int64 followeeId = 3; //followeeId
|
|
int64 createdAt = 4; //createdAt
|
|
}
|
|
|
|
message UpdateUserFollowsResp {
|
|
}
|
|
|
|
message DelUserFollowsReq {
|
|
int64 id = 1; //id
|
|
int64 userId = 2; // userId
|
|
}
|
|
|
|
message DelUserFollowsResp {
|
|
}
|
|
|
|
message GetUserFollowsByIdReq {
|
|
int64 id = 1; //id
|
|
}
|
|
|
|
message GetUserFollowsByIdResp {
|
|
UserFollows userFollows = 1; //userFollows
|
|
}
|
|
|
|
message SearchUserFollowsReq {
|
|
int64 page = 1; //page
|
|
int64 limit = 2; //limit
|
|
int64 id = 3; //id
|
|
int64 followerId = 4; //followerId
|
|
int64 followeeId = 5; //followeeId
|
|
int64 createdAt = 6; //createdAt
|
|
}
|
|
|
|
message SearchUserFollowsResp {
|
|
repeated UserFollows userFollows = 1; //userFollows
|
|
}
|
|
|
|
//--------------------------------userPreferences--------------------------------
|
|
message UserPreferences {
|
|
int64 userId = 1; //userId
|
|
bool notificationOrder = 2; //notificationOrder
|
|
bool notificationCommunity = 3; //notificationCommunity
|
|
bool notificationSystem = 4; //notificationSystem
|
|
string theme = 5; //theme
|
|
string language = 6; //language
|
|
int64 updatedAt = 7; //updatedAt
|
|
}
|
|
|
|
message AddUserPreferencesReq {
|
|
int64 userId = 1; //userId
|
|
bool notificationOrder = 2; //notificationOrder
|
|
bool notificationCommunity = 3; //notificationCommunity
|
|
bool notificationSystem = 4; //notificationSystem
|
|
string theme = 5; //theme
|
|
string language = 6; //language
|
|
int64 updatedAt = 7; //updatedAt
|
|
}
|
|
|
|
message AddUserPreferencesResp {
|
|
}
|
|
|
|
message UpdateUserPreferencesReq {
|
|
int64 userId = 1; //userId
|
|
bool notificationOrder = 2; //notificationOrder
|
|
bool notificationCommunity = 3; //notificationCommunity
|
|
bool notificationSystem = 4; //notificationSystem
|
|
string theme = 5; //theme
|
|
string language = 6; //language
|
|
int64 updatedAt = 7; //updatedAt
|
|
}
|
|
|
|
message UpdateUserPreferencesResp {
|
|
}
|
|
|
|
message DelUserPreferencesReq {
|
|
int64 id = 1; //id
|
|
}
|
|
|
|
message DelUserPreferencesResp {
|
|
}
|
|
|
|
message GetUserPreferencesByIdReq {
|
|
int64 id = 1; //id
|
|
}
|
|
|
|
message GetUserPreferencesByIdResp {
|
|
UserPreferences userPreferences = 1; //userPreferences
|
|
}
|
|
|
|
message SearchUserPreferencesReq {
|
|
int64 page = 1; //page
|
|
int64 limit = 2; //limit
|
|
int64 userId = 3; //userId
|
|
bool notificationOrder = 4; //notificationOrder
|
|
bool notificationCommunity = 5; //notificationCommunity
|
|
bool notificationSystem = 6; //notificationSystem
|
|
string theme = 7; //theme
|
|
string language = 8; //language
|
|
int64 updatedAt = 9; //updatedAt
|
|
}
|
|
|
|
message SearchUserPreferencesResp {
|
|
repeated UserPreferences userPreferences = 1; //userPreferences
|
|
}
|
|
|
|
// ------------------------------------
|
|
// Rpc Func
|
|
// ------------------------------------
|
|
|
|
service usercenter {
|
|
|
|
//-----------------------users-----------------------
|
|
rpc AddUsers(AddUsersReq) returns (AddUsersResp);
|
|
rpc UpdateUsers(UpdateUsersReq) returns (UpdateUsersResp);
|
|
rpc DelUsers(DelUsersReq) returns (DelUsersResp);
|
|
rpc GetUsersById(GetUsersByIdReq) returns (GetUsersByIdResp);
|
|
rpc SearchUsers(SearchUsersReq) returns (SearchUsersResp);
|
|
|
|
rpc GetUserByUsername(GetUserByUsernameReq) returns (GetUserByUsernameResp);
|
|
rpc Login(LoginReq) returns (LoginResp);
|
|
rpc Register(RegisterReq) returns (RegisterResp);
|
|
rpc ValidateToken(ValidateTokenReq) returns (ValidateTokenResp);
|
|
rpc CheckPermission(CheckPermissionReq) returns (CheckPermissionResp);
|
|
rpc Logout(LogoutReq) returns (LogoutResp);
|
|
rpc ResetPassword(ResetPasswordReq) returns (ResetPasswordResp);
|
|
rpc SwitchRole(SwitchRoleReq) returns (SwitchRoleResp);
|
|
|
|
|
|
//-----------------------userFollows-----------------------
|
|
rpc AddUserFollows(AddUserFollowsReq) returns (AddUserFollowsResp);
|
|
rpc UpdateUserFollows(UpdateUserFollowsReq) returns (UpdateUserFollowsResp);
|
|
rpc DelUserFollows(DelUserFollowsReq) returns (DelUserFollowsResp);
|
|
rpc GetUserFollowsById(GetUserFollowsByIdReq) returns (GetUserFollowsByIdResp);
|
|
rpc SearchUserFollows(SearchUserFollowsReq) returns (SearchUserFollowsResp);
|
|
//-----------------------userPreferences-----------------------
|
|
rpc AddUserPreferences(AddUserPreferencesReq) returns (AddUserPreferencesResp);
|
|
rpc UpdateUserPreferences(UpdateUserPreferencesReq) returns (UpdateUserPreferencesResp);
|
|
rpc DelUserPreferences(DelUserPreferencesReq) returns (DelUserPreferencesResp);
|
|
rpc GetUserPreferencesById(GetUserPreferencesByIdReq) returns (GetUserPreferencesByIdResp);
|
|
rpc SearchUserPreferences(SearchUserPreferencesReq) returns (SearchUserPreferencesResp);
|
|
}
|