feat(health): 添加工作台统计和团队概览 API
- ActionInboxService 新增 get_workbench_stats 和 get_team_overview - Handler 新增 /health/action-inbox/stats 和 /team 端点 - 注册 health.action-inbox.team 权限码
This commit is contained in:
@@ -5,7 +5,7 @@ use erp_core::rbac::require_permission;
|
||||
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
|
||||
|
||||
use crate::service::action_inbox_service::{
|
||||
self, ActionInboxQuery, ActionItem, ThreadResponse,
|
||||
self, ActionInboxQuery, ActionItem, TeamOverview, ThreadResponse, WorkbenchStats,
|
||||
};
|
||||
use crate::state::HealthState;
|
||||
|
||||
@@ -41,3 +41,31 @@ where
|
||||
None => Err(crate::error::HealthError::Validation("行动项未找到".into()).into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_workbench_stats<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
) -> Result<Json<ApiResponse<WorkbenchStats>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
require_permission(&ctx, "health.action-inbox.list")?;
|
||||
let result =
|
||||
action_inbox_service::get_workbench_stats(&state.db, ctx.tenant_id).await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
pub async fn get_team_overview<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
) -> Result<Json<ApiResponse<TeamOverview>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
require_permission(&ctx, "health.action-inbox.team")?;
|
||||
let result =
|
||||
action_inbox_service::get_team_overview(&state.db, ctx.tenant_id).await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user