fix(devices): 修复 batch-status 路由 affectedCount 未定义导致崩溃

- 添加缺失的 Device.update() 调用,实际执行批量状态更新
- 定义 affectedCount 变量,解决 ReferenceError 崩溃问题
- 修复前 PUT /batch-status 必定抛出 500 错误
This commit is contained in:
zhang96110
2026-04-01 03:31:42 +00:00
parent b306c75aae
commit fa65eecf5e
+6
View File
@@ -1628,6 +1628,12 @@ router.put('/batch-status', async (req, res) => {
.map(d => `${d.name}(编号:${d.deviceId}${d.rackName ? `,机柜:${d.rackName}` : ''})`)
.join('、');
// 执行批量状态更新
const [affectedCount] = await Device.update(
{ status },
{ where: { deviceId: { [Op.in]: deviceIds } } }
);
const statusChangeDesc = `批量变更${affectedCount}台设备状态:${deviceSummary}${statusText[status]}`;
await logDeviceOperation('status_change', statusChangeDesc, {