```
feat: 添加公司AI管理平台基础架构 添加了完整的FastAPI后端项目结构,包括: - 环境配置文件(.env.example)和项目说明文档(README.md、AGENTS.md) - Dockerfile用于容器化部署 - 核心基础设施:配置管理、数据库连接、调度器、安全认证 - 模块化设计:AI代理、审批流程、审计日志、业务台账等功能模块 - 支持多数据库连接(主库和遗留系统只读库) - AI适配器支持OpenClaw、Hermes、OpenAI兼容接口 - 飞书集成、报表生成、风险监控等企业级功能 - 完整的依赖管理和测试指南 ```
This commit is contained in:
3
scripts/init_db.ps1
Normal file
3
scripts/init_db.ps1
Normal file
@@ -0,0 +1,3 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
python -m app.tools.init_db
|
||||
11
scripts/recreate_conda_env.ps1
Normal file
11
scripts/recreate_conda_env.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$envList = conda env list --json | ConvertFrom-Json
|
||||
$exists = $envList.envs | Where-Object { $_ -like "*company-ai-platform" }
|
||||
if ($exists) {
|
||||
conda env remove -n company-ai-platform -y
|
||||
}
|
||||
conda env create -f environment.yml
|
||||
|
||||
Write-Host "Conda environment recreated: company-ai-platform"
|
||||
Write-Host "Run: conda activate company-ai-platform"
|
||||
3
scripts/run_dev.ps1
Normal file
3
scripts/run_dev.ps1
Normal file
@@ -0,0 +1,3 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
uvicorn app.main:app --reload --host 0.0.0.0 --port 8010
|
||||
39
scripts/sample_requests.http
Normal file
39
scripts/sample_requests.http
Normal file
@@ -0,0 +1,39 @@
|
||||
### Health
|
||||
GET http://127.0.0.1:8010/api/v1/health
|
||||
X-API-Key: change-me
|
||||
|
||||
### Create project
|
||||
POST http://127.0.0.1:8010/api/v1/business/projects
|
||||
Content-Type: application/json
|
||||
X-API-Key: change-me
|
||||
|
||||
{
|
||||
"actor": "demo",
|
||||
"data": {
|
||||
"code": "P-2026-001",
|
||||
"name": "公司AI管理系统一期",
|
||||
"owner": "负责人A",
|
||||
"status": "执行中",
|
||||
"budget_amount": 100000,
|
||||
"actual_amount": 25000,
|
||||
"progress_percent": 30,
|
||||
"risk_level": "medium"
|
||||
}
|
||||
}
|
||||
|
||||
### Daily brief
|
||||
GET http://127.0.0.1:8010/api/v1/reports/daily-brief
|
||||
X-API-Key: change-me
|
||||
|
||||
### AI ask
|
||||
POST http://127.0.0.1:8010/api/v1/ai/ask
|
||||
Content-Type: application/json
|
||||
X-API-Key: change-me
|
||||
|
||||
{
|
||||
"actor": "demo",
|
||||
"prompt": "总结当前项目风险。",
|
||||
"context": {
|
||||
"project": "P-2026-001"
|
||||
}
|
||||
}
|
||||
74
scripts/verify_smoke.py
Normal file
74
scripts/verify_smoke.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
db = tempfile.NamedTemporaryFile(delete=False, suffix=".db")
|
||||
db.close()
|
||||
|
||||
os.environ["DATABASE_URL"] = "sqlite:///" + db.name.replace("\\", "/")
|
||||
os.environ["API_KEY"] = "test-key"
|
||||
os.environ["MODEL_PROVIDER"] = "noop"
|
||||
os.environ["SCHEDULER_ENABLED"] = "false"
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.core.database import Base, engine
|
||||
from app.main import app
|
||||
|
||||
|
||||
def request(method: str, url: str, **kwargs):
|
||||
client = TestClient(app)
|
||||
headers = kwargs.pop("headers", {})
|
||||
headers.setdefault("X-API-Key", "test-key")
|
||||
response = getattr(client, method)(url, headers=headers, **kwargs)
|
||||
response.raise_for_status()
|
||||
return response
|
||||
|
||||
|
||||
try:
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
project = request(
|
||||
"post",
|
||||
"/api/v1/business/projects",
|
||||
json={
|
||||
"actor": "smoke",
|
||||
"data": {
|
||||
"code": "P-VERIFY-001",
|
||||
"name": "Verify Project",
|
||||
"owner": "tester",
|
||||
"status": "执行中",
|
||||
"budget_amount": 1000,
|
||||
"actual_amount": 200,
|
||||
},
|
||||
},
|
||||
).json()
|
||||
print("project:", project["data"]["code"])
|
||||
|
||||
report = request("get", "/api/v1/reports/daily-brief").json()
|
||||
print("report:", report["title"])
|
||||
|
||||
command = request(
|
||||
"post",
|
||||
"/api/v1/integrations/feishu/commands/preview",
|
||||
json={"text": "日报", "auto_reply": False},
|
||||
).json()
|
||||
print("command:", command["command"])
|
||||
|
||||
ai = request(
|
||||
"post",
|
||||
"/api/v1/ai/ask",
|
||||
json={"prompt": "生成项目摘要", "context": {"project": "P-VERIFY-001"}},
|
||||
).json()
|
||||
print("ai:", ai["provider"])
|
||||
|
||||
print("smoke verification ok")
|
||||
finally:
|
||||
engine.dispose()
|
||||
path = Path(db.name)
|
||||
if path.exists():
|
||||
path.unlink()
|
||||
Reference in New Issue
Block a user