fix(账号): 批量导入跳过已存在的重复账号
- 导入前按用户名(大小写不敏感)查库去重,同批文本内重复也跳过 - 返回消息区分格式跳过与重复跳过数量
This commit is contained in:
@@ -189,8 +189,9 @@ def import_accounts(
|
||||
"""批量导入账号。格式:用户名|密码|邮箱|邮箱密码|标签(可选)
|
||||
|
||||
req.tag 为统一标签兜底:某行未单独写标签时使用该值,行内标签优先。
|
||||
库中已存在的用户名(大小写不敏感)与同批重复行会自动跳过。
|
||||
"""
|
||||
accounts, skipped = parse_and_build_accounts(req.text, req.tag)
|
||||
accounts, skipped, duplicated = parse_and_build_accounts(db, req.text, req.tag)
|
||||
|
||||
if accounts:
|
||||
db.add_all(accounts)
|
||||
@@ -198,7 +199,12 @@ def import_accounts(
|
||||
action="account:import", target=f"导入{len(accounts)}个"))
|
||||
db.commit()
|
||||
|
||||
return {"message": f"导入成功 {len(accounts)} 个,跳过 {skipped} 个", "success": True, "count": len(accounts)}
|
||||
duplicated_note = f",重复跳过 {duplicated} 个" if duplicated else ""
|
||||
return {
|
||||
"message": f"导入成功 {len(accounts)} 个,跳过 {skipped} 个{duplicated_note}",
|
||||
"success": True,
|
||||
"count": len(accounts),
|
||||
}
|
||||
|
||||
|
||||
@router.put("/{account_id}/assign")
|
||||
|
||||
Reference in New Issue
Block a user