feat(server): 添加公共路径认证中间件和批量操作功能
refactor(routes): 重新组织路由顺序并添加批量删除功能 - 在server.js中添加公共路径认证中间件 - 为cables、devicePorts等路由添加批量删除功能 - 重新组织路由顺序,将相关操作分组 - 添加工单导出功能
This commit is contained in:
@@ -131,6 +131,39 @@ router.get('/device/:deviceId/with-ports', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 查询网卡
|
||||
router.get('/find', async (req, res) => {
|
||||
try {
|
||||
const { deviceId, deviceSn, name } = req.query;
|
||||
|
||||
if ((!deviceId && !deviceSn) || !name) {
|
||||
return res.status(400).json({ error: '缺少设备ID/SN或网卡名称' });
|
||||
}
|
||||
|
||||
let device;
|
||||
if (deviceSn) {
|
||||
device = await Device.findOne({ where: { serialNumber: deviceSn } });
|
||||
if (!device) {
|
||||
return res.json({ nicId: null });
|
||||
}
|
||||
}
|
||||
|
||||
const networkCard = await NetworkCard.findOne({
|
||||
where: { deviceId: device ? device.deviceId : deviceId, name },
|
||||
});
|
||||
|
||||
if (!networkCard) {
|
||||
return res.json({ nicId: null });
|
||||
}
|
||||
|
||||
res.json(networkCard);
|
||||
} catch (error) {
|
||||
console.error('查找网卡失败:', error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 获取单个网卡
|
||||
router.get('/:nicId', async (req, res) => {
|
||||
try {
|
||||
const networkCard = await NetworkCard.findByPk(req.params.nicId, {
|
||||
@@ -170,37 +203,6 @@ router.get('/:nicId/ports', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/find', async (req, res) => {
|
||||
try {
|
||||
const { deviceId, deviceSn, name } = req.query;
|
||||
|
||||
if ((!deviceId && !deviceSn) || !name) {
|
||||
return res.status(400).json({ error: '缺少设备ID/SN或网卡名称' });
|
||||
}
|
||||
|
||||
let device;
|
||||
if (deviceSn) {
|
||||
device = await Device.findOne({ where: { serialNumber: deviceSn } });
|
||||
if (!device) {
|
||||
return res.json({ nicId: null });
|
||||
}
|
||||
}
|
||||
|
||||
const networkCard = await NetworkCard.findOne({
|
||||
where: { deviceId: device ? device.deviceId : deviceId, name },
|
||||
});
|
||||
|
||||
if (!networkCard) {
|
||||
return res.json({ nicId: null });
|
||||
}
|
||||
|
||||
res.json(networkCard);
|
||||
} catch (error) {
|
||||
console.error('查找网卡失败:', error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
try {
|
||||
const { nicId, deviceId, name, description, slotNumber, model, manufacturer, status } =
|
||||
|
||||
Reference in New Issue
Block a user