2025-05-15 16:59:12 +08:00
|
|
|
const { getDBConnection } = require('./file-utils');
|
2025-04-28 12:25:20 +08:00
|
|
|
|
2025-05-15 16:59:12 +08:00
|
|
|
// 查询Plane表中的所有飞机
|
|
|
|
function getPlanes() {
|
2025-04-28 12:25:20 +08:00
|
|
|
try {
|
2025-05-15 16:59:12 +08:00
|
|
|
const db = getDBConnection(true);
|
2025-04-28 12:25:20 +08:00
|
|
|
|
2025-05-15 16:59:12 +08:00
|
|
|
// 查询所有飞机
|
|
|
|
const planes = db.prepare(`
|
|
|
|
SELECT PlaneName, Description
|
|
|
|
FROM 'Plane'
|
|
|
|
ORDER BY PlaneName
|
2025-04-30 13:47:35 +08:00
|
|
|
`).all();
|
|
|
|
|
2025-05-15 16:59:12 +08:00
|
|
|
return planes;
|
2025-04-30 14:50:27 +08:00
|
|
|
} catch (error) {
|
2025-05-15 16:59:12 +08:00
|
|
|
console.error('获取飞机列表数据失败:', error.message);
|
2025-05-08 17:01:57 +08:00
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取所有用户信息
|
|
|
|
function getUsers() {
|
|
|
|
try {
|
2025-05-15 16:59:12 +08:00
|
|
|
const db = getDBConnection(true);
|
2025-05-08 17:01:57 +08:00
|
|
|
|
|
|
|
const users = db.prepare(`
|
|
|
|
SELECT
|
|
|
|
id,
|
|
|
|
username,
|
2025-05-12 10:13:25 +08:00
|
|
|
password,
|
2025-05-08 17:01:57 +08:00
|
|
|
access_level,
|
|
|
|
full_name,
|
|
|
|
phone,
|
|
|
|
email,
|
|
|
|
department,
|
|
|
|
position
|
|
|
|
FROM users
|
|
|
|
ORDER BY id ASC
|
|
|
|
`).all();
|
|
|
|
|
|
|
|
return users;
|
|
|
|
} catch (error) {
|
|
|
|
console.error('获取用户信息失败:', error);
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-04-28 12:25:20 +08:00
|
|
|
module.exports = {
|
2025-05-15 16:59:12 +08:00
|
|
|
getPlanes,
|
|
|
|
getUsers
|
2025-04-28 12:25:20 +08:00
|
|
|
};
|