From 01f53663e9e68329d5450ec0a351553dadcd4548 Mon Sep 17 00:00:00 2001 From: darkclip Date: Sat, 30 May 2026 23:40:50 +0800 Subject: [PATCH] update --- main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 5dd1026..d4e5113 100644 --- a/main.py +++ b/main.py @@ -624,11 +624,18 @@ async def import_programs( continue # 检查节目是否已存在 - cursor.execute('SELECT sn FROM programs WHERE sn = ?', (sn,)) + cursor.execute('SELECT sn, batch_id FROM programs WHERE sn = ?', (sn,)) exists = cursor.fetchone() if exists: - # 更新节目信息,保留原有 order_num + # 如果节目已存在且不属于当前导入的批次,则报错,禁止跨批次移动 + if exists['batch_id'] != batch_id: + raise HTTPException( + status_code=400, + detail=f'节目编号 {sn} 已存在于批次ID {exists["batch_id"]} 中,不能通过导入移动到当前批次。' + f'如需移动,请先删除原节目或使用编辑功能修改批次。', + ) + # 同批次更新(保留原有 order_num) cursor.execute( """UPDATE programs SET name = ?, unit = ?, performer = ?, category = ?, batch_id = ?