仓库模块完了
This commit is contained in:
@@ -8,6 +8,7 @@ import uuid
|
||||
from app.models.models import AlgorithmRepository
|
||||
from app.models.database import SessionLocal
|
||||
from app.routes.user import get_current_active_user
|
||||
from app.schemas.user import UserResponse
|
||||
from app.gitea.service import gitea_service
|
||||
|
||||
router = APIRouter(prefix="/repositories", tags=["repositories"])
|
||||
@@ -38,11 +39,11 @@ class UpdateRepositoryRequest(BaseModel):
|
||||
@router.post("", status_code=status.HTTP_201_CREATED)
|
||||
async def create_repository(
|
||||
request: CreateRepositoryRequest,
|
||||
current_user: dict = Depends(get_current_active_user)
|
||||
current_user: UserResponse = Depends(get_current_active_user)
|
||||
):
|
||||
"""创建算法仓库"""
|
||||
# 检查用户权限
|
||||
if current_user.role != "admin":
|
||||
if current_user.role_name != "admin":
|
||||
raise HTTPException(status_code=403, detail="Insufficient permissions")
|
||||
|
||||
# 创建数据库会话
|
||||
@@ -92,11 +93,11 @@ async def create_repository(
|
||||
@router.get("")
|
||||
async def list_repositories(
|
||||
algorithm_id: Optional[str] = None,
|
||||
current_user: dict = Depends(get_current_active_user)
|
||||
current_user: UserResponse = Depends(get_current_active_user)
|
||||
):
|
||||
"""获取算法仓库列表"""
|
||||
# 检查用户权限
|
||||
if current_user.role != "admin":
|
||||
if current_user.role_name != "admin":
|
||||
raise HTTPException(status_code=403, detail="Insufficient permissions")
|
||||
|
||||
# 创建数据库会话
|
||||
@@ -139,11 +140,11 @@ async def list_repositories(
|
||||
@router.get("/{repo_id}")
|
||||
async def get_repository(
|
||||
repo_id: str,
|
||||
current_user: dict = Depends(get_current_active_user)
|
||||
current_user: UserResponse = Depends(get_current_active_user)
|
||||
):
|
||||
"""获取单个算法仓库"""
|
||||
# 检查用户权限
|
||||
if current_user.role != "admin":
|
||||
if current_user.role_name != "admin":
|
||||
raise HTTPException(status_code=403, detail="Insufficient permissions")
|
||||
|
||||
# 创建数据库会话
|
||||
@@ -179,11 +180,11 @@ async def get_repository(
|
||||
async def update_repository(
|
||||
repo_id: str,
|
||||
request: UpdateRepositoryRequest,
|
||||
current_user: dict = Depends(get_current_active_user)
|
||||
current_user: UserResponse = Depends(get_current_active_user)
|
||||
):
|
||||
"""更新算法仓库"""
|
||||
# 检查用户权限
|
||||
if current_user.role != "admin":
|
||||
if current_user.role_name != "admin":
|
||||
raise HTTPException(status_code=403, detail="Insufficient permissions")
|
||||
|
||||
# 创建数据库会话
|
||||
@@ -239,11 +240,11 @@ async def update_repository(
|
||||
@router.delete("/{repo_id}")
|
||||
async def delete_repository(
|
||||
repo_id: str,
|
||||
current_user: dict = Depends(get_current_active_user)
|
||||
current_user: UserResponse = Depends(get_current_active_user)
|
||||
):
|
||||
"""删除算法仓库"""
|
||||
# 检查用户权限
|
||||
if current_user.role != "admin":
|
||||
if current_user.role_name != "admin":
|
||||
raise HTTPException(status_code=403, detail="Insufficient permissions")
|
||||
|
||||
# 创建数据库会话
|
||||
|
||||
Reference in New Issue
Block a user