feat(auth): 用户管理页面过滤纯患者用户 + fix(health): clippy 修复

后端 list_users API 新增 exclude_only_roles 参数,排除仅有指定角色的用户。
前端用户管理页面默认传 'patient' 过滤,wx_* 微信患者不再混入员工列表。
同时修复 erp-health dashboard.rs 的 clippy 警告(unused import + collapsible if)。
This commit is contained in:
iven
2026-06-05 10:17:59 +08:00
parent a5c67d6bec
commit 201a91580c
5 changed files with 335 additions and 82 deletions

View File

@@ -21,6 +21,9 @@ pub struct UserListParams {
pub page_size: Option<u64>,
/// Optional search term — filters by username (case-insensitive contains).
pub search: Option<String>,
/// Exclude users whose *only* role is one of these comma-separated role codes.
/// Example: `exclude_only_roles=patient` hides users that have no role other than "patient".
pub exclude_only_roles: Option<String>,
}
#[utoipa::path(
@@ -54,10 +57,17 @@ where
page: params.page,
page_size: params.page_size,
};
let exclude_only_roles: Option<Vec<String>> = params
.exclude_only_roles
.as_deref()
.filter(|s| !s.is_empty())
.map(|s| s.split(',').map(|c| c.trim().to_string()).collect());
let (users, total) = UserService::list(
ctx.tenant_id,
&pagination,
params.search.as_deref(),
exclude_only_roles.as_deref(),
&state.db,
)
.await?;