fix: 成长路径管理API添加权限控制
All checks were successful
continuous-integration/drone/push Build is passing

管理端所有成长路径API现在需要管理员或经理权限才能访问:
- GET/POST /manager/growth-paths
- GET/PUT/DELETE /manager/growth-paths/{path_id}
This commit is contained in:
yuliang_guo
2026-01-31 11:06:02 +08:00
parent bdb91aabea
commit 4a273e627a
2 changed files with 161 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ from typing import Optional
from fastapi import APIRouter, Depends, HTTPException, Query
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.deps import get_db, get_current_user
from app.core.deps import get_db, get_current_user, require_admin_or_manager
from app.models.user import User
from app.services.growth_path_service import growth_path_service
from app.schemas.growth_path import (
@@ -118,7 +118,7 @@ async def list_growth_paths(
page: int = Query(1, ge=1, description="页码"),
page_size: int = Query(20, ge=1, le=100, description="每页数量"),
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
current_user: User = Depends(require_admin_or_manager),
):
"""
获取成长路径列表(管理端)
@@ -141,7 +141,7 @@ async def list_growth_paths(
async def create_growth_path(
data: GrowthPathCreate,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
current_user: User = Depends(require_admin_or_manager),
):
"""
创建成长路径(管理端)
@@ -168,7 +168,7 @@ async def create_growth_path(
async def get_growth_path(
path_id: int,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
current_user: User = Depends(require_admin_or_manager),
):
"""
获取成长路径详情(管理端)
@@ -190,7 +190,7 @@ async def update_growth_path(
path_id: int,
data: GrowthPathUpdate,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
current_user: User = Depends(require_admin_or_manager),
):
"""
更新成长路径(管理端)
@@ -216,7 +216,7 @@ async def update_growth_path(
async def delete_growth_path(
path_id: int,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
current_user: User = Depends(require_admin_or_manager),
):
"""
删除成长路径(管理端)