2026-05-11 19:26:01 +08:00

421 lines
10 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package hyapp.user.v1;
import "proto/user/v1/user.proto";
option go_package = "hyapp.local/api/proto/user/v1;userv1";
// HostProfile 是用户长期主播身份,不等同于 room-service 的房间 host_user_id。
message HostProfile {
int64 user_id = 1;
string status = 2;
int64 region_id = 3;
int64 current_agency_id = 4;
int64 current_membership_id = 5;
string source = 6;
int64 first_became_host_at_ms = 7;
int64 created_at_ms = 8;
int64 updated_at_ms = 9;
}
// Agency 是主播组织owner 自动拥有 host 身份和 owner membership。
message Agency {
int64 agency_id = 1;
int64 owner_user_id = 2;
int64 region_id = 3;
int64 parent_bd_user_id = 4;
string name = 5;
string status = 6;
bool join_enabled = 7;
int32 max_hosts = 8;
int64 created_by_user_id = 9;
int64 created_at_ms = 10;
int64 updated_at_ms = 11;
}
// BDProfile 表达 BD 或 BD Leader 拓展角色。BD 默认不是 host。
message BDProfile {
int64 user_id = 1;
string role = 2;
int64 region_id = 3;
int64 parent_leader_user_id = 4;
string status = 5;
int64 created_by_user_id = 6;
int64 created_at_ms = 7;
int64 updated_at_ms = 8;
}
// CoinSellerProfile 表达币商身份;余额在 wallet-service不在 user-service。
message CoinSellerProfile {
int64 user_id = 1;
string status = 2;
string merchant_asset_type = 3;
int64 created_by_user_id = 4;
int64 created_at_ms = 5;
int64 updated_at_ms = 6;
}
// UserRoleSummary 是 App 我的页和入口显隐使用的轻量角色摘要。
// 它把 host、Agency、BD 和币商身份收敛到一次 user-service RPC避免 gateway 随角色扩张继续 fanout。
message UserRoleSummary {
int64 user_id = 1;
bool is_host = 2;
bool is_agency = 3;
bool is_bd = 4;
bool is_bd_leader = 5;
bool is_coin_seller = 6;
string host_status = 7;
int64 agency_id = 8;
int64 bd_id = 9;
string bd_status = 10;
string coin_seller_status = 11;
int64 pending_role_invitations = 12;
}
// AgencyMembership 是 host 与 Agency 的有时效关系事实。
message AgencyMembership {
int64 membership_id = 1;
int64 agency_id = 2;
int64 host_user_id = 3;
int64 region_id = 4;
string membership_type = 5;
string status = 6;
int64 joined_at_ms = 7;
int64 ended_at_ms = 8;
int64 ended_by_user_id = 9;
string ended_reason = 10;
int64 created_at_ms = 11;
int64 updated_at_ms = 12;
}
// AgencyApplication 是用户主动申请加入 Agency 的 App 事实。
message AgencyApplication {
int64 application_id = 1;
string command_id = 2;
int64 applicant_user_id = 3;
int64 agency_id = 4;
int64 region_id = 5;
string status = 6;
int64 reviewed_by_user_id = 7;
string review_reason = 8;
int64 reviewed_at_ms = 9;
int64 created_at_ms = 10;
int64 updated_at_ms = 11;
}
// RoleInvitation 是 BD/BD Leader 邀请用户成为 Agency 或 BD 的 App 事实。
message RoleInvitation {
int64 invitation_id = 1;
string command_id = 2;
string invitation_type = 3;
string status = 4;
int64 inviter_user_id = 5;
int64 inviter_bd_user_id = 6;
int64 target_user_id = 7;
int64 region_id = 8;
string agency_name = 9;
int64 parent_bd_user_id = 10;
int64 parent_leader_user_id = 11;
int64 processed_by_user_id = 12;
string process_reason = 13;
int64 processed_at_ms = 14;
int64 created_at_ms = 15;
int64 updated_at_ms = 16;
}
message SearchAgenciesRequest {
RequestMeta meta = 1;
int64 user_id = 2;
string keyword = 3;
int32 page_size = 4;
}
message SearchAgenciesResponse {
repeated Agency agencies = 1;
}
message ApplyToAgencyRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 user_id = 3;
int64 agency_id = 4;
}
message ApplyToAgencyResponse {
AgencyApplication application = 1;
}
message ReviewAgencyApplicationRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 reviewer_user_id = 3;
int64 application_id = 4;
string decision = 5;
string reason = 6;
}
message ReviewAgencyApplicationResponse {
AgencyApplication application = 1;
HostProfile host_profile = 2;
AgencyMembership membership = 3;
}
message KickAgencyHostRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 operator_user_id = 3;
int64 agency_id = 4;
int64 host_user_id = 5;
string reason = 6;
}
message KickAgencyHostResponse {
AgencyMembership membership = 1;
HostProfile host_profile = 2;
}
message InviteAgencyRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 inviter_user_id = 3;
int64 target_user_id = 4;
string agency_name = 5;
}
message InviteAgencyResponse {
RoleInvitation invitation = 1;
}
message InviteBDRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 inviter_user_id = 3;
int64 target_user_id = 4;
}
message InviteBDResponse {
RoleInvitation invitation = 1;
}
message ProcessRoleInvitationRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 actor_user_id = 3;
int64 invitation_id = 4;
string action = 5;
string reason = 6;
}
message ProcessRoleInvitationResponse {
RoleInvitation invitation = 1;
HostProfile host_profile = 2;
Agency agency = 3;
AgencyMembership membership = 4;
BDProfile bd_profile = 5;
}
message GetHostProfileRequest {
RequestMeta meta = 1;
int64 user_id = 2;
}
message GetHostProfileResponse {
HostProfile host_profile = 1;
}
message GetBDProfileRequest {
RequestMeta meta = 1;
int64 user_id = 2;
}
message GetBDProfileResponse {
BDProfile bd_profile = 1;
}
message GetCoinSellerProfileRequest {
RequestMeta meta = 1;
int64 user_id = 2;
}
message GetCoinSellerProfileResponse {
CoinSellerProfile coin_seller_profile = 1;
}
message GetUserRoleSummaryRequest {
RequestMeta meta = 1;
int64 user_id = 2;
}
message GetUserRoleSummaryResponse {
UserRoleSummary summary = 1;
}
message CheckBusinessCapabilityRequest {
RequestMeta meta = 1;
int64 actor_user_id = 2;
string capability = 3;
}
message CheckBusinessCapabilityResponse {
bool allowed = 1;
string reason = 2;
}
message GetAgencyMembersRequest {
RequestMeta meta = 1;
int64 agency_id = 2;
string status = 3;
}
message GetAgencyMembersResponse {
repeated AgencyMembership memberships = 1;
}
message GetAgencyApplicationsRequest {
RequestMeta meta = 1;
int64 agency_id = 2;
string status = 3;
}
message GetAgencyApplicationsResponse {
repeated AgencyApplication applications = 1;
}
message CreateBDLeaderRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 target_user_id = 4;
string reason = 5;
int64 region_id = 6;
}
message CreateBDLeaderResponse {
BDProfile bd_profile = 1;
}
message CreateBDRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 target_user_id = 4;
int64 parent_leader_user_id = 5;
string reason = 6;
}
message CreateBDResponse {
BDProfile bd_profile = 1;
}
message SetBDStatusRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 target_user_id = 4;
string status = 5;
string reason = 6;
}
message SetBDStatusResponse {
BDProfile bd_profile = 1;
}
message CreateCoinSellerRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 target_user_id = 4;
string reason = 5;
}
message CreateCoinSellerResponse {
CoinSellerProfile coin_seller_profile = 1;
}
message SetCoinSellerStatusRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 target_user_id = 4;
string status = 5;
string reason = 6;
}
message SetCoinSellerStatusResponse {
CoinSellerProfile coin_seller_profile = 1;
}
message CreateAgencyRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 owner_user_id = 4;
int64 parent_bd_user_id = 5;
string name = 6;
bool join_enabled = 7;
int32 max_hosts = 8;
string reason = 9;
}
message CreateAgencyResponse {
Agency agency = 1;
HostProfile host_profile = 2;
AgencyMembership membership = 3;
}
message CloseAgencyRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 agency_id = 4;
string reason = 5;
}
message CloseAgencyResponse {
Agency agency = 1;
}
message SetAgencyJoinEnabledRequest {
RequestMeta meta = 1;
string command_id = 2;
int64 admin_user_id = 3;
int64 agency_id = 4;
bool join_enabled = 5;
string reason = 6;
}
message SetAgencyJoinEnabledResponse {
Agency agency = 1;
}
// UserHostService 是 user-service 内部 host domain 的 gRPC 面,不是独立微服务。
service UserHostService {
rpc SearchAgencies(SearchAgenciesRequest) returns (SearchAgenciesResponse);
rpc ApplyToAgency(ApplyToAgencyRequest) returns (ApplyToAgencyResponse);
rpc ReviewAgencyApplication(ReviewAgencyApplicationRequest) returns (ReviewAgencyApplicationResponse);
rpc KickAgencyHost(KickAgencyHostRequest) returns (KickAgencyHostResponse);
rpc InviteAgency(InviteAgencyRequest) returns (InviteAgencyResponse);
rpc InviteBD(InviteBDRequest) returns (InviteBDResponse);
rpc ProcessRoleInvitation(ProcessRoleInvitationRequest) returns (ProcessRoleInvitationResponse);
rpc GetHostProfile(GetHostProfileRequest) returns (GetHostProfileResponse);
rpc GetBDProfile(GetBDProfileRequest) returns (GetBDProfileResponse);
rpc GetCoinSellerProfile(GetCoinSellerProfileRequest) returns (GetCoinSellerProfileResponse);
rpc GetUserRoleSummary(GetUserRoleSummaryRequest) returns (GetUserRoleSummaryResponse);
rpc CheckBusinessCapability(CheckBusinessCapabilityRequest) returns (CheckBusinessCapabilityResponse);
rpc GetAgencyMembers(GetAgencyMembersRequest) returns (GetAgencyMembersResponse);
rpc GetAgencyApplications(GetAgencyApplicationsRequest) returns (GetAgencyApplicationsResponse);
}
// UserHostAdminService 是后台关系管理入口;公网 admin 鉴权由 admin-server 承担。
service UserHostAdminService {
rpc CreateBDLeader(CreateBDLeaderRequest) returns (CreateBDLeaderResponse);
rpc CreateBD(CreateBDRequest) returns (CreateBDResponse);
rpc SetBDStatus(SetBDStatusRequest) returns (SetBDStatusResponse);
rpc CreateCoinSeller(CreateCoinSellerRequest) returns (CreateCoinSellerResponse);
rpc SetCoinSellerStatus(SetCoinSellerStatusRequest) returns (SetCoinSellerStatusResponse);
rpc CreateAgency(CreateAgencyRequest) returns (CreateAgencyResponse);
rpc CloseAgency(CloseAgencyRequest) returns (CloseAgencyResponse);
rpc SetAgencyJoinEnabled(SetAgencyJoinEnabledRequest) returns (SetAgencyJoinEnabledResponse);
}