feat: 实现安全存储和批量导入功能增强
refactor(前端): 重构认证和存储逻辑使用secureStorage feat(前端): 添加安全存储工具和日志工具 feat(前端): 增强批量导入功能支持服务器和交换机设备 fix(后端): 改进设备端口和网卡批量导入接口 docs: 更新导入模板和操作说明
This commit is contained in:
@@ -165,13 +165,22 @@ router.post('/batch', async (req, res) => {
|
||||
const portData = ports[i];
|
||||
|
||||
try {
|
||||
if (!portData.portId || !portData.deviceId || !portData.portName) {
|
||||
if (!portData.portId || !(portData.deviceId || portData.deviceSn) || !portData.portName) {
|
||||
throw new Error('缺少必填字段');
|
||||
}
|
||||
|
||||
const device = await Device.findByPk(portData.deviceId, { transaction });
|
||||
if (!device) {
|
||||
throw new Error(`设备 ${portData.deviceId} 不存在`);
|
||||
let device;
|
||||
if (portData.deviceSn) {
|
||||
device = await Device.findOne({ where: { serialNumber: portData.deviceSn }, transaction });
|
||||
if (!device) {
|
||||
throw new Error(`设备SN ${portData.deviceSn} 不存在`);
|
||||
}
|
||||
portData.deviceId = device.deviceId;
|
||||
} else {
|
||||
device = await Device.findByPk(portData.deviceId, { transaction });
|
||||
if (!device) {
|
||||
throw new Error(`设备ID ${portData.deviceId} 不存在`);
|
||||
}
|
||||
}
|
||||
|
||||
const isServer = device.type && device.type.toLowerCase().includes('server');
|
||||
|
||||
Reference in New Issue
Block a user