注册服务

This commit is contained in:
2026-02-09 23:59:25 +08:00
parent f145df4fa6
commit 3c03777b97
11 changed files with 865 additions and 456 deletions

View File

@@ -6,6 +6,7 @@ from pydantic import BaseModel
import uuid
import os
from app.config.settings import settings
from app.models.models import AlgorithmService, ServiceGroup, AlgorithmRepository
from app.models.database import SessionLocal
from app.routes.user import get_current_active_user
@@ -42,7 +43,7 @@ class ServiceResponse(BaseModel):
api_url: str
status: str
created_at: str
updated_at: str
updated_at: Optional[str]
class ServiceListResponse(BaseModel):
@@ -127,7 +128,7 @@ class BatchOperationResponse(BaseModel):
# 初始化服务组件
project_analyzer = ProjectAnalyzer()
service_generator = ServiceGenerator()
service_orchestrator = ServiceOrchestrator()
service_orchestrator = ServiceOrchestrator(deployment_mode=settings.DEPLOYMENT_MODE)
@router.post("/register", status_code=status.HTTP_201_CREATED)
@@ -137,7 +138,9 @@ async def register_service(
):
"""注册新服务"""
# 检查用户权限
if current_user.role_name != "admin":
print(f"用户角色: {current_user.role_name}")
print(f"用户角色对象: {current_user.role}")
if not hasattr(current_user, 'role_name') or current_user.role_name != "admin":
raise HTTPException(status_code=403, detail="Insufficient permissions")
# 创建数据库会话
@@ -236,7 +239,7 @@ def main(data):
"api_url": new_service.api_url,
"status": new_service.status,
"created_at": new_service.created_at.isoformat(),
"updated_at": new_service.updated_at.isoformat()
"updated_at": new_service.updated_at.isoformat() if new_service.updated_at else None
}
}
finally:
@@ -272,7 +275,7 @@ async def list_services(
api_url=service.api_url,
status=service.status,
created_at=service.created_at.isoformat(),
updated_at=service.updated_at.isoformat()
updated_at=service.updated_at.isoformat() if service.updated_at else None
))
return ServiceListResponse(
@@ -316,7 +319,7 @@ async def get_service(
api_url=service.api_url,
status=service.status,
created_at=service.created_at.isoformat(),
updated_at=service.updated_at.isoformat()
updated_at=service.updated_at.isoformat() if service.updated_at else None
)
)
finally: