完善项目级权限与项目管理入口

- 新增项目成员候选用户接口,避免 PM 读取全局用户列表
- 按项目角色和权限矩阵控制项目管理、成员、中心与审计入口
- 合并侧边栏管理后台入口,统一从项目管理进入成员等模块
- 加强成员管理安全约束,禁止 PM 修改自己、系统管理员或更高权限角色
- 修复多项目角色缓存串用问题,并补充前后端回归测试
This commit is contained in:
Cheng Zhou
2026-05-13 14:16:15 +08:00
parent ab1975d3c6
commit a17f4cc522
21 changed files with 452 additions and 134 deletions
+23
View File
@@ -85,6 +85,29 @@ async def list_users(db: AsyncSession, skip: int = 0, limit: int = 100) -> Seque
return result.scalars().all()
async def list_active_member_candidates_for_study(
db: AsyncSession,
study_id: uuid.UUID,
skip: int = 0,
limit: int = 100,
) -> Sequence[User]:
existing_member = (
select(StudyMember.id)
.where(StudyMember.study_id == study_id, StudyMember.user_id == User.id)
.exists()
)
stmt = (
select(User)
.where(User.status == UserStatus.ACTIVE)
.where(~existing_member)
.order_by(User.full_name.asc(), User.email.asc())
.offset(skip)
.limit(limit)
)
result = await db.execute(stmt)
return result.scalars().all()
async def count_active_admins(db: AsyncSession) -> int:
result = await db.execute(
select(func.count())