feat(diary): 添加发现页 Discover API — 每日灵感/热门标签/精选模板/专家日记
新增 DiscoverService 并发聚合 4 个数据区: - daily_inspiration: MD5 哈希确定性日更推荐,匿名作者名 - hot_topics: 标签频率统计 Top 8 - featured_templates: 官方模板最多 6 个 - expert_diaries: 评论数热度排序,去重最多 5 位作者 GET /api/v1/diary/discover + utoipa 文档 + diary.journal.read 权限守卫
This commit is contained in:
@@ -380,6 +380,51 @@ pub struct TemplateResp {
|
||||
pub is_free: bool,
|
||||
}
|
||||
|
||||
// ========== 发现页 ==========
|
||||
|
||||
/// 发现页聚合响应 — 一次返回全部板块数据
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct DiscoverResp {
|
||||
/// 每日推荐(无共享日记时为 null)
|
||||
pub daily_inspiration: Option<InspirationItem>,
|
||||
/// 热门话题(标签频率 TOP 8)
|
||||
pub hot_topics: Vec<TagCount>,
|
||||
/// 精选模板(官方模板)
|
||||
pub featured_templates: Vec<TemplateResp>,
|
||||
/// 达人日记(不同作者最近共享日记)
|
||||
pub expert_diaries: Vec<ExpertDiaryItem>,
|
||||
}
|
||||
|
||||
/// 每日推荐条目
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct InspirationItem {
|
||||
pub journal_id: uuid::Uuid,
|
||||
pub title: String,
|
||||
pub author_name: String,
|
||||
pub mood: String,
|
||||
pub date: chrono::NaiveDate,
|
||||
}
|
||||
|
||||
/// 热门话题
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct TagCount {
|
||||
pub tag: String,
|
||||
pub count: i64,
|
||||
}
|
||||
|
||||
/// 达人日记条目
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct ExpertDiaryItem {
|
||||
pub journal_id: uuid::Uuid,
|
||||
pub title: String,
|
||||
pub author_id: uuid::Uuid,
|
||||
pub author_name: String,
|
||||
pub author_emoji: String,
|
||||
pub content_preview: String,
|
||||
pub like_count: i64,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
/// 成就响应
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct AchievementResp {
|
||||
|
||||
Reference in New Issue
Block a user