style: 优化角色/组织管理页面UI布局,采用多列紧凑设计,提升视觉体验
This commit is contained in:
@@ -25,44 +25,12 @@ from app.services.import_export_service import ImportExportService
|
|||||||
from app.schemas.import_export import CharactersExportRequest, CharactersImportResult
|
from app.schemas.import_export import CharactersExportRequest, CharactersImportResult
|
||||||
from app.logger import get_logger
|
from app.logger import get_logger
|
||||||
from app.api.settings import get_user_ai_service
|
from app.api.settings import get_user_ai_service
|
||||||
|
from app.api.common import verify_project_access
|
||||||
|
|
||||||
router = APIRouter(prefix="/characters", tags=["角色管理"])
|
router = APIRouter(prefix="/characters", tags=["角色管理"])
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def verify_project_access(project_id: str, user_id: str, db: AsyncSession) -> Project:
|
|
||||||
"""
|
|
||||||
验证用户是否有权访问指定项目
|
|
||||||
|
|
||||||
Args:
|
|
||||||
project_id: 项目ID
|
|
||||||
user_id: 用户ID
|
|
||||||
db: 数据库会话
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Project: 项目对象
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
HTTPException: 401 未登录,404 项目不存在或无权访问
|
|
||||||
"""
|
|
||||||
if not user_id:
|
|
||||||
raise HTTPException(status_code=401, detail="未登录")
|
|
||||||
|
|
||||||
result = await db.execute(
|
|
||||||
select(Project).where(
|
|
||||||
Project.id == project_id,
|
|
||||||
Project.user_id == user_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
project = result.scalar_one_or_none()
|
|
||||||
|
|
||||||
if not project:
|
|
||||||
logger.warning(f"项目访问被拒绝: project_id={project_id}, user_id={user_id}")
|
|
||||||
raise HTTPException(status_code=404, detail="项目不存在或无权访问")
|
|
||||||
|
|
||||||
return project
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("", response_model=CharacterListResponse, summary="获取角色列表")
|
@router.get("", response_model=CharacterListResponse, summary="获取角色列表")
|
||||||
async def get_characters(
|
async def get_characters(
|
||||||
project_id: str,
|
project_id: str,
|
||||||
|
|||||||
Reference in New Issue
Block a user