feat: 支持网站目标分组轻量管理(新增、编辑、描述展示),不修改和不提交倍率

This commit is contained in:
liumangmang
2026-07-01 17:47:36 +08:00
parent e5d7af8906
commit 8c2f1c13bb
7 changed files with 248 additions and 2 deletions
+45
View File
@@ -30,6 +30,8 @@ from app.schemas.website import (
TestResult,
WebsiteCreate,
WebsiteGroupResponse,
WebsiteGroupCreate,
WebsiteGroupUpdate,
WebsiteResponse,
WebsiteSyncLogResponse,
WebsiteUpdate,
@@ -291,6 +293,49 @@ def list_website_groups(wid: int, db: Session = Depends(get_db), _=Depends(get_c
raise HTTPException(502, str(exc))
@router.post("/api/websites/{wid}/groups", response_model=dict)
def create_website_group(
wid: int,
body: WebsiteGroupCreate,
db: Session = Depends(get_db),
_=Depends(get_current_user),
):
row = db.query(Website).filter(Website.id == wid).first()
if not row:
raise HTTPException(404, "website not found")
try:
with _client(row) as c:
payload = {
"name": body.name,
"description": body.description,
}
return c.create_group(payload, row.groups_endpoint)
except Exception as exc:
raise HTTPException(502, str(exc))
@router.put("/api/websites/{wid}/groups/{group_id}", response_model=dict)
def update_website_group(
wid: int,
group_id: str,
body: WebsiteGroupUpdate,
db: Session = Depends(get_db),
_=Depends(get_current_user),
):
row = db.query(Website).filter(Website.id == wid).first()
if not row:
raise HTTPException(404, "website not found")
try:
with _client(row) as c:
payload = {
"name": body.name,
"description": body.description,
}
return c.update_group(row.group_update_endpoint, group_id, payload)
except Exception as exc:
raise HTTPException(502, str(exc))
@router.post("/api/websites/{wid}/groups/import-from-upstream/{upstream_id}", response_model=ImportGroupsResponse)
def import_groups_from_upstream(
wid: int,