refactor: 仓库结构扁平化 + PHP前端合并到Nexus仓库
- 将 Nexus/Nexus/* 移到仓库根目录(消除双层嵌套) - 删除旧的多层空壳目录 (server/, web/, agent/, deploy/, docs/) - 将PHP前端 (web/) 合并进Nexus仓库 — 统一管理 - 部署时 git clone Nexus 仓库即可,不再需要两个仓库 目录结构: server/ ← Python FastAPI后端 web/ ← PHP前端 (install.php, config.php, etc) deploy/ ← Supervisor + Shell健康检查 docs/ ← 部署文档 tests/ ← 测试 .env ← 不在git中 (install.php生成) .gitignore ← 排除 .env, SECRETS.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
"""Nexus — Script & ScriptExecution Repository (Async SQLAlchemy)"""
|
||||
|
||||
from typing import Optional, List
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from server.domain.models import Script, ScriptExecution
|
||||
|
||||
|
||||
class ScriptRepositoryImpl:
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.session = session
|
||||
|
||||
async def get_by_id(self, id: int) -> Optional[Script]:
|
||||
result = await self.session.execute(select(Script).where(Script.id == id))
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
async def get_all(self) -> List[Script]:
|
||||
result = await self.session.execute(select(Script).order_by(Script.id))
|
||||
return list(result.scalars().all())
|
||||
|
||||
async def get_by_category(self, category: str) -> List[Script]:
|
||||
result = await self.session.execute(
|
||||
select(Script).where(Script.category == category).order_by(Script.id)
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
async def create(self, script: Script) -> Script:
|
||||
self.session.add(script)
|
||||
await self.session.commit()
|
||||
await self.session.refresh(script)
|
||||
return script
|
||||
|
||||
async def update(self, script: Script) -> Script:
|
||||
await self.session.commit()
|
||||
await self.session.refresh(script)
|
||||
return script
|
||||
|
||||
async def delete(self, id: int) -> bool:
|
||||
script = await self.get_by_id(id)
|
||||
if script:
|
||||
await self.session.delete(script)
|
||||
await self.session.commit()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class ScriptExecutionRepositoryImpl:
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.session = session
|
||||
|
||||
async def get_by_id(self, id: int) -> Optional[ScriptExecution]:
|
||||
result = await self.session.execute(
|
||||
select(ScriptExecution).where(ScriptExecution.id == id)
|
||||
)
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
async def create(self, execution: ScriptExecution) -> ScriptExecution:
|
||||
self.session.add(execution)
|
||||
await self.session.commit()
|
||||
await self.session.refresh(execution)
|
||||
return execution
|
||||
|
||||
async def update_status(self, id: int, status: str, results: str) -> ScriptExecution:
|
||||
execution = await self.session.get(ScriptExecution, id)
|
||||
if execution:
|
||||
execution.status = status
|
||||
execution.results = results
|
||||
await self.session.commit()
|
||||
await self.session.refresh(execution)
|
||||
return execution
|
||||
Reference in New Issue
Block a user