feat(health): 新增公开文章列表端点 /public/articles 供小程序访客首页使用
访客首页文章列表调用 /health/articles 需要 JWT 认证导致 401。 新增 GET /public/articles?tenant_id=xxx 端点,强制只返回已发布文章, 无需认证。小程序访客首页改用此公开端点。
This commit is contained in:
@@ -48,6 +48,30 @@ where
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
pub async fn list_public_articles(
|
||||
State(state): State<HealthState>,
|
||||
Query(params): Query<ArticleListParams>,
|
||||
) -> Result<Json<ApiResponse<PaginatedResponse<ArticleListItem>>>, AppError> {
|
||||
let tenant_id = params
|
||||
.tenant_id
|
||||
.ok_or_else(|| AppError::Validation("tenant_id is required".into()))?;
|
||||
let page = params.page.unwrap_or(1);
|
||||
let page_size = params.page_size.unwrap_or(20);
|
||||
let result = article_service::list_articles(
|
||||
&state,
|
||||
tenant_id,
|
||||
page,
|
||||
page_size,
|
||||
params.category,
|
||||
Some("published".to_string()),
|
||||
params.category_id,
|
||||
params.tag_id,
|
||||
params.keyword,
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
pub async fn get_article<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
|
||||
Reference in New Issue
Block a user