465 lines
13 KiB
Protocol Buffer
465 lines
13 KiB
Protocol Buffer
syntax = "proto3";
|
||
|
||
package topfans.user;
|
||
|
||
option go_package = "github.com/topfans/backend/pkg/proto/user;user";
|
||
|
||
import "proto/common.proto";
|
||
import "google/api/annotations.proto";
|
||
|
||
// ==================== 用户域 ====================
|
||
|
||
// 用户基本信息
|
||
message User {
|
||
int64 id = 1;
|
||
string mobile = 2;
|
||
string avatar_url = 3;
|
||
string global_wallet_address = 4;
|
||
bool is_active = 5;
|
||
int64 created_at = 6;
|
||
}
|
||
|
||
// 粉丝档案(星球内身份)
|
||
message FanProfile {
|
||
int64 id = 1;
|
||
int64 user_id = 2;
|
||
int64 star_id = 3; // 核心隔离键
|
||
string nickname = 4; // 星球专属昵称
|
||
int32 level = 5; // 等级
|
||
int32 times = 6; // 剩余铸造次数
|
||
int32 social = 7; // 好友个数
|
||
int64 experience = 8; // 经验值
|
||
int64 coin_balance = 9; // 游戏币余额
|
||
int64 crystal_balance = 10; // 顶粉水晶余额
|
||
repeated string tags = 11; // 标签数组
|
||
string avatar_url = 17; // 头像URL(星球专属)
|
||
int64 created_at = 12;
|
||
int32 starbook_limit = 13; // 星书限制
|
||
int32 slot_limit = 14; // 槽位限制
|
||
int32 assets_count = 15; // 资产数量
|
||
string chain_address = 16; // 链地址
|
||
}
|
||
|
||
// 明星信息
|
||
message Star {
|
||
int64 star_id = 1;
|
||
string name = 2;
|
||
string name_en = 3;
|
||
string pic_url = 4;
|
||
string description = 5;
|
||
string identity_id = 6;
|
||
bool is_active = 7;
|
||
int64 created_at = 8;
|
||
string tag = 9; // 昵称标签(如"小飞侠")
|
||
}
|
||
|
||
// ==================== 认证相关消息 ====================
|
||
|
||
// 注册请求
|
||
message RegisterRequest {
|
||
string mobile = 1; // 手机号
|
||
string password = 2; // 密码
|
||
int64 star_id = 3; // 选择第一个粉丝身份的明星ID
|
||
string nickname = 4; // 第一个粉丝身份的昵称
|
||
}
|
||
|
||
// 注册响应
|
||
message RegisterResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
string access_token = 2; // JWT Token(已包含star_id)
|
||
int64 expires_in = 3; // Token过期时间(秒)
|
||
User user = 4; // 用户信息
|
||
FanProfile fan_profile = 5; // 创建的粉丝档案
|
||
}
|
||
|
||
// 登录请求
|
||
message LoginRequest {
|
||
string mobile = 1; // 手机号
|
||
string password = 2; // 密码
|
||
int64 star_id = 3; // 可选:指定登录的明星ID,不指定则使用最早创建的粉丝档案
|
||
}
|
||
|
||
// 登录响应
|
||
message LoginResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
string access_token = 2; // JWT Token(已包含star_id)
|
||
int64 expires_in = 3; // Token过期时间(秒)
|
||
User user = 4; // 用户信息
|
||
FanProfile fan_profile = 5; // 当前粉丝档案(根据Token中的star_id)
|
||
repeated FanProfile fan_profiles = 6; // 用户的所有粉丝身份列表
|
||
}
|
||
|
||
// 刷新Token请求
|
||
message RefreshTokenRequest {
|
||
// 空请求,网关从 Token 中提取 user_id 和 star_id,通过 attachments 传递
|
||
}
|
||
|
||
// 刷新Token响应
|
||
message RefreshTokenResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
string access_token = 2; // 新的 Access Token
|
||
int64 expires_in = 3; // Access Token 过期时间(秒)
|
||
}
|
||
|
||
// 验证Token请求(可选,用于服务端验证Token有效性)
|
||
message ValidateTokenRequest {
|
||
string access_token = 1;
|
||
}
|
||
|
||
// 验证Token响应
|
||
message ValidateTokenResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int64 user_id = 2; // Token关联的用户ID
|
||
int64 star_id = 3; // Token关联的明星ID
|
||
bool is_valid = 4; // Token是否有效
|
||
int64 expires_at = 5; // Token过期时间戳(毫秒)
|
||
}
|
||
|
||
// 登出请求
|
||
message LogoutRequest {
|
||
// 空请求,网关从 Token 中提取 user_id,通过 attachments 传递
|
||
}
|
||
|
||
// 登出响应
|
||
message LogoutResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
}
|
||
|
||
// 检查昵称是否被注册请求
|
||
message CheckNicknameRequest {
|
||
string nickname = 1; // 要检查的昵称
|
||
}
|
||
|
||
// 检查昵称是否被注册响应
|
||
message CheckNicknameResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
bool exists = 2; // 昵称是否已存在
|
||
}
|
||
|
||
// 检查手机号是否已被注册请求
|
||
message CheckMobileRequest {
|
||
string mobile = 1; // 要检查的手机号
|
||
}
|
||
|
||
// 检查手机号是否已被注册响应
|
||
message CheckMobileResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
bool exists = 2; // 手机号是否已存在
|
||
}
|
||
|
||
// ==================== 用户信息相关消息 ====================
|
||
|
||
// 获取用户信息请求
|
||
message GetUserRequest {
|
||
int64 user_id = 1;
|
||
}
|
||
|
||
// 获取用户信息响应
|
||
message GetUserResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
User user = 2;
|
||
}
|
||
|
||
// 获取粉丝档案请求
|
||
message GetFanProfileRequest {
|
||
int64 user_id = 1;
|
||
int64 star_id = 2;
|
||
}
|
||
|
||
// 获取粉丝档案响应
|
||
message GetFanProfileResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
FanProfile profile = 2;
|
||
}
|
||
|
||
// 更新粉丝档案social字段请求(内部RPC调用,用于好友数量变更)
|
||
message UpdateFanProfileSocialRequest {
|
||
int64 user_id = 1; // 用户ID
|
||
int64 star_id = 2; // 明星ID
|
||
int32 delta = 3; // 变化量(正数增加,负数减少)
|
||
}
|
||
|
||
// 更新粉丝档案social字段响应
|
||
message UpdateFanProfileSocialResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int32 new_social = 2; // 更新后的好友数量
|
||
}
|
||
|
||
// 更新水晶余额请求(内部RPC调用,用于资产服务扣除/退款水晶)
|
||
message UpdateCrystalBalanceRequest {
|
||
int64 user_id = 1; // 用户ID
|
||
int64 star_id = 2; // 明星ID
|
||
int64 delta = 3; // 变化量(正数增加,负数减少)
|
||
}
|
||
|
||
// 更新水晶余额响应
|
||
message UpdateCrystalBalanceResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int64 new_balance = 2; // 更新后的水晶余额
|
||
}
|
||
|
||
// 更新资产数量请求(内部RPC调用,用于资产服务更新用户资产数量)
|
||
message UpdateAssetsCountRequest {
|
||
int64 user_id = 1; // 用户ID
|
||
int64 star_id = 2; // 明星ID
|
||
int32 delta = 3; // 变化量(正数增加,负数减少)
|
||
}
|
||
|
||
// 更新资产数量响应
|
||
message UpdateAssetsCountResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int32 new_count = 2; // 更新后的资产数量
|
||
}
|
||
|
||
// 获取当前登录用户信息请求
|
||
message GetCurrentUserRequest {
|
||
// 空请求,从Token中获取user_id和star_id
|
||
}
|
||
|
||
// 获取当前登录用户信息响应
|
||
message GetCurrentUserResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
User user = 2;
|
||
FanProfile fan_profile = 3; // 当前粉丝档案
|
||
repeated FanProfile fan_profiles = 4; // 所有粉丝身份
|
||
}
|
||
|
||
// 获取个人信息页请求
|
||
message GetMyProfileRequest {
|
||
// 空请求,从Token中获取user_id和star_id
|
||
}
|
||
|
||
// 获取个人信息页响应
|
||
message GetMyProfileResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
User user = 2;
|
||
FanProfile fan_profile = 3;
|
||
repeated FanProfile fan_profiles = 4; // 所有粉丝身份列表
|
||
}
|
||
|
||
// 修改昵称请求
|
||
message UpdateNicknameRequest {
|
||
string nickname = 1; // 新昵称
|
||
}
|
||
|
||
// 修改昵称响应
|
||
message UpdateNicknameResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
FanProfile fan_profile = 2; // 更新后的粉丝档案
|
||
}
|
||
|
||
// 修改密码请求
|
||
message UpdatePasswordRequest {
|
||
string old_password = 1; // 旧密码
|
||
string new_password = 2; // 新密码
|
||
}
|
||
|
||
// 修改密码响应
|
||
message UpdatePasswordResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
}
|
||
|
||
// 更新头像请求
|
||
message UpdateAvatarRequest {
|
||
string avatar_url = 1; // 头像URL(必填)
|
||
}
|
||
|
||
// 更新头像响应
|
||
message UpdateAvatarResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
string avatar_url = 2; // 更新后的头像URL
|
||
}
|
||
|
||
// ==================== 粉丝身份相关消息 ====================
|
||
|
||
// 获取可选粉丝身份列表请求(所有可用明星)
|
||
message GetFanIdentitiesRequest {
|
||
string keyword = 1; // 搜索关键词(可选,为空则返回所有可用的明星列表)
|
||
}
|
||
|
||
// 获取可选粉丝身份列表响应
|
||
message GetFanIdentitiesResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
repeated Star stars = 2; // 所有可用的明星列表
|
||
}
|
||
|
||
// 获取我的粉丝身份列表请求(当前用户拥有的粉丝身份)
|
||
message GetMyFanIdentitiesRequest {
|
||
// 空请求,从Token中获取user_id
|
||
}
|
||
|
||
// 我的粉丝身份项(包含粉丝档案和明星信息)
|
||
message MyFanIdentityItem {
|
||
FanProfile fan_profile = 1; // 粉丝档案
|
||
Star star = 2; // 对应的明星信息
|
||
}
|
||
|
||
// 获取我的粉丝身份列表响应
|
||
message GetMyFanIdentitiesResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
repeated MyFanIdentityItem items = 2; // 用户拥有的所有粉丝身份列表(包含明星信息)
|
||
int64 current_star_id = 3; // 当前激活的明星ID(从Token中获取)
|
||
}
|
||
|
||
// 新增粉丝身份请求
|
||
message AddIdentityRequest {
|
||
int64 star_id = 1; // 选择的明星ID
|
||
string nickname = 2; // 粉丝身份昵称
|
||
}
|
||
|
||
// 新增粉丝身份响应
|
||
message AddIdentityResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
FanProfile fan_profile = 2; // 新创建的粉丝档案
|
||
}
|
||
|
||
// 切换粉丝身份请求
|
||
message SwitchIdentityRequest {
|
||
int64 new_star_id = 1; // 切换到的新明星ID
|
||
}
|
||
|
||
// 切换粉丝身份响应
|
||
message SwitchIdentityResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
string access_token = 2; // 新的JWT Token(包含新的star_id)
|
||
int64 expires_in = 3; // Token过期时间(秒)
|
||
FanProfile fan_profile = 4; // 切换后的粉丝档案
|
||
}
|
||
|
||
// ==================== 用户与社交服务 ====================
|
||
|
||
service UserSocialService {
|
||
// 用户认证相关
|
||
rpc Register(RegisterRequest) returns (RegisterResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/auth/register"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc Login(LoginRequest) returns (LoginResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/auth/login"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/auth/refresh"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/auth/validate"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc Logout(LogoutRequest) returns (LogoutResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/auth/logout"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc CheckNickname(CheckNicknameRequest) returns (CheckNicknameResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/auth/check-nickname"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc CheckMobile(CheckMobileRequest) returns (CheckMobileResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/auth/check-mobile"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
// 用户信息相关
|
||
rpc GetUser(GetUserRequest) returns (GetUserResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/users/{user_id}"
|
||
};
|
||
}
|
||
|
||
rpc GetFanProfile(GetFanProfileRequest) returns (GetFanProfileResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/users/{user_id}/fan-profiles/{star_id}"
|
||
};
|
||
}
|
||
|
||
// 内部RPC:更新粉丝档案的好友数量(仅供socialService调用)
|
||
rpc UpdateFanProfileSocial(UpdateFanProfileSocialRequest) returns (UpdateFanProfileSocialResponse);
|
||
|
||
// 内部RPC:更新水晶余额(仅供assetService调用)
|
||
rpc UpdateCrystalBalance(UpdateCrystalBalanceRequest) returns (UpdateCrystalBalanceResponse);
|
||
|
||
// 内部RPC:更新资产数量(仅供assetService调用)
|
||
rpc UpdateAssetsCount(UpdateAssetsCountRequest) returns (UpdateAssetsCountResponse);
|
||
|
||
rpc GetCurrentUser(GetCurrentUserRequest) returns (GetCurrentUserResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/auth/me"
|
||
};
|
||
}
|
||
|
||
rpc GetMyProfile(GetMyProfileRequest) returns (GetMyProfileResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/me/profile"
|
||
};
|
||
}
|
||
|
||
rpc UpdateNickname(UpdateNicknameRequest) returns (UpdateNicknameResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/me/profile"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc UpdatePassword(UpdatePasswordRequest) returns (UpdatePasswordResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/account/password"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc UpdateAvatar(UpdateAvatarRequest) returns (UpdateAvatarResponse) {
|
||
option (google.api.http) = {
|
||
put: "/api/v1/me/avatar"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
// 粉丝身份相关
|
||
rpc GetFanIdentities(GetFanIdentitiesRequest) returns (GetFanIdentitiesResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/fan-identities"
|
||
};
|
||
}
|
||
|
||
rpc GetMyFanIdentities(GetMyFanIdentitiesRequest) returns (GetMyFanIdentitiesResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/my/fan-identities"
|
||
};
|
||
}
|
||
|
||
rpc AddIdentity(AddIdentityRequest) returns (AddIdentityResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/my/fan-identities"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
rpc SwitchIdentity(SwitchIdentityRequest) returns (SwitchIdentityResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/my/fan-identities/switch"
|
||
body: "*"
|
||
};
|
||
}
|
||
}
|
||
|