topfans/backend/proto/statistic.proto

147 lines
4.6 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 topfans.statistic;
option go_package = "github.com/topfans/backend/pkg/proto/statistic;statistic";
import "proto/event.proto";
// ==================== StatisticService ====================
// 看板 7 RPC经 gateway 暴露给前端)+ 事件采集 2 RPC内部
// Go 侧由 mobile_provider.go / internal_provider.go 两个文件实现同名服务。
service StatisticService {
// ============ 看板 7 RPC经 gateway 暴露) ============
rpc GetTodayOverview(GetTodayOverviewRequest) returns (GetTodayOverviewResponse);
rpc Get7DayIncomeCurve(Get7DayIncomeCurveRequest) returns (Get7DayIncomeCurveResponse);
rpc GetExhibitionIncomeSummary(GetExhibitionIncomeSummaryRequest) returns (GetExhibitionIncomeSummaryResponse);
rpc GetLikeIncomeByLevel(GetLikeIncomeByLevelRequest) returns (GetLikeIncomeByLevelResponse);
rpc GetTopAssetsByEarning(GetTopAssetsByEarningRequest) returns (GetTopAssetsByEarningResponse);
rpc GetAssetLevelDistribution(GetAssetLevelDistributionRequest) returns (GetAssetLevelDistributionResponse);
rpc GetAssetUpgradeProgress(GetAssetUpgradeProgressRequest) returns (GetAssetUpgradeProgressResponse);
// ============ 事件采集(内部 RPC ============
rpc TrackEvent(topfans.event.Event) returns (TrackEventResponse);
rpc BatchTrackEvent(topfans.event.BatchEventRequest) returns (TrackEventResponse);
}
// ====== 1. 今日概览 ======
message GetTodayOverviewRequest {
int64 star_id = 1;
}
message GetTodayOverviewResponse {
int64 crystal_balance = 1;
int64 today_income = 2;
int32 week_rank = 3; // 本期完整实现
int32 week_total_users = 4; // 用于"击败 X%"展示
}
// ====== 2. 七日收益曲线 ======
message Get7DayIncomeCurveRequest {
int64 star_id = 1;
}
message DailyIncomePoint {
string date = 1; // "YYYY-MM-DD"
int64 income = 2;
bool is_today = 3;
bool is_peak = 4;
}
message Get7DayIncomeCurveResponse {
repeated DailyIncomePoint points = 1;
int64 total_income = 2;
int64 avg_income = 3;
}
// ====== 3. 展出收益中心 ======
message GetExhibitionIncomeSummaryRequest {
int64 star_id = 1;
}
message TopExhibitionItem {
int64 asset_id = 1;
string asset_name = 2;
string asset_thumb = 3;
string duration_7d = 4; // 7 天累计展示时长("D:HH:MM:SS"
int64 earnings_7d = 5;
int32 avg_earnings = 6;
}
message GetExhibitionIncomeSummaryResponse {
int32 exhibiting_count = 1; // 当前在展藏品数
int32 starbook_count = 2; // 星图册数
string total_duration = 3; // 累计展示时长
int64 total_earnings = 4; // 累计收益
repeated TopExhibitionItem top5 = 5;
}
// ====== 4. 点赞收益按等级 ======
message GetLikeIncomeByLevelRequest {
int64 star_id = 1;
}
message LikeIncomeLevelItem {
string level = 1; // 藏品等级N/R/SR/SSR/UR
int32 asset_count = 2;
int64 total_income = 3;
string thumb = 4; // 等级代表缩略图
}
message GetLikeIncomeByLevelResponse {
int64 total_like_count = 1;
int64 total_income = 2;
repeated LikeIncomeLevelItem levels = 3;
}
// ====== 5. 藏品 TOP5按收益 ======
message GetTopAssetsByEarningRequest {
int64 star_id = 1;
}
message TopAssetItem {
int64 asset_id = 1;
string asset_name = 2;
string asset_thumb = 3;
int64 total_earnings = 4;
int32 rank = 5;
}
message GetTopAssetsByEarningResponse {
repeated TopAssetItem items = 1;
}
// ====== 6. 藏品等级分布 ======
message GetAssetLevelDistributionRequest {
int64 star_id = 1;
}
message AssetLevelItem {
string level = 1; // 藏品等级
int32 count = 2; // 当前持有该等级的藏品数
int32 total = 3; // 累计(历史)该等级藏品数
}
message GetAssetLevelDistributionResponse {
repeated AssetLevelItem items = 1;
}
// ====== 7. 升级进度 ======
message GetAssetUpgradeProgressRequest {
int64 star_id = 1;
}
message UpcomingLevelUpItem {
int64 asset_id = 1;
string asset_name = 2;
string asset_thumb = 3;
int32 like_progress = 4; // 0-100 进度
int32 duration_progress = 5; // 0-100 进度
}
message RecentLevelUpItem {
int64 asset_id = 1;
string asset_name = 2;
string asset_thumb = 3;
string new_level = 4;
int64 upgrade_time = 5; // ms timestamp
}
message GetAssetUpgradeProgressResponse {
repeated UpcomingLevelUpItem upcoming = 1;
repeated RecentLevelUpItem recent = 2;
}
// ====== 事件采集响应 ======
message TrackEventResponse {
int32 accepted = 1; // 成功接收并进入 channel 的事件数
int32 rejected = 2; // 被拒收的事件数(格式错误、限流等)
}