update
This commit is contained in:
1 file changed
+9
-2
@@ -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 = ?
|
||||
|
||||
Reference in new issue
Block a user