refactor(数据库): 移除clock_records表中的distance_meters字段并更新相关查询
移除不再使用的distance_meters字段,简化数据库结构 更新前端展示失败的打卡记录样式和添加notes列显示 删除不再需要的SSL证书文件
This commit is contained in:
+4
-5
@@ -41,7 +41,6 @@ async function startServer() {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// --- FIX START ---
|
||||
// Define the geofence polygon by calling the 'polygon' function directly
|
||||
const geofence = polygon([
|
||||
[
|
||||
@@ -55,7 +54,7 @@ async function startServer() {
|
||||
[101.80827335908509, 2.8350045747358337],
|
||||
],
|
||||
])
|
||||
// --- FIX END ---
|
||||
|
||||
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
@@ -128,8 +127,8 @@ async function startServer() {
|
||||
|
||||
// Insert the failed attempt into the database
|
||||
await db.execute(
|
||||
'INSERT INTO clock_records (worker_id, event_type, timestamp, qr_code_id, latitude, longitude, notes, distance_meters) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
[userId, 'failed', new Date(), qrCodeValue, latitude, longitude, notes, distance]
|
||||
'INSERT INTO clock_records (worker_id, event_type, timestamp, qr_code_id, latitude, longitude, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
[userId, 'failed', new Date(), qrCodeValue, latitude, longitude, notes]
|
||||
);
|
||||
|
||||
// Return an error to the user
|
||||
@@ -577,7 +576,7 @@ async function startServer() {
|
||||
const placeholders = idsArray.map(() => '?').join(',')
|
||||
|
||||
// MODIFIED: Use LEFT JOIN and COALESCE to handle manual entries, and select `notes`
|
||||
let query = `SELECT cr.id, w.full_name, cr.event_type, cr.timestamp, COALESCE(qc.name, 'Manual Entry') as qrCodeUsedName, cr.latitude, cr.longitude, cr.notes, cr.distance_meters FROM clock_records cr LEFT JOIN qr_codes qc ON cr.qr_code_id = qc.id JOIN workers w ON cr.worker_id = w.id WHERE cr.worker_id IN (${placeholders})`;
|
||||
let query = `SELECT cr.id, w.full_name, cr.event_type, cr.timestamp, COALESCE(qc.name, 'Manual Entry') as qrCodeUsedName, cr.latitude, cr.longitude, cr.notes FROM clock_records cr LEFT JOIN qr_codes qc ON cr.qr_code_id = qc.id JOIN workers w ON cr.worker_id = w.id WHERE cr.worker_id IN (${placeholders})`;
|
||||
|
||||
const params = [...idsArray]
|
||||
if (startDate && endDate) {
|
||||
|
||||
Reference in New Issue
Block a user