feat: Cookie管理页面增加批量删除功能
This commit is contained in:
@@ -139,3 +139,24 @@ def delete_cookie(
|
||||
task.message = "Cookie已清除"
|
||||
db.commit()
|
||||
return {"message": "已删除", "success": True}
|
||||
|
||||
|
||||
@router.delete("/batch")
|
||||
def delete_cookies_batch(
|
||||
task_ids: str = "",
|
||||
db: Session = Depends(get_db),
|
||||
current: User = Depends(require_permission("cookie:export")),
|
||||
):
|
||||
"""批量删除 Cookie 记录。"""
|
||||
if not task_ids:
|
||||
raise HTTPException(status_code=400, detail="请指定记录ID")
|
||||
ids = [int(x) for x in task_ids.split(",") if x.strip().isdigit()]
|
||||
if not ids:
|
||||
raise HTTPException(status_code=400, detail="无效的ID")
|
||||
tasks = db.query(LoginTask).filter(LoginTask.id.in_(ids)).all()
|
||||
for t in tasks:
|
||||
t.cookie = ""
|
||||
t.status = "failed"
|
||||
t.message = "Cookie已清除"
|
||||
db.commit()
|
||||
return {"message": f"已删除 {len(tasks)} 条", "deleted": len(tasks), "success": True}
|
||||
|
||||
Reference in New Issue
Block a user