From c136816000616dae0ba5e9ccb3cda5cb95192954 Mon Sep 17 00:00:00 2001 From: pjmw9izve <2308014474@qq.com> Date: Sun, 6 Oct 2024 13:09:54 +0800 Subject: [PATCH] ADD file via upload --- ranking.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ranking.js diff --git a/ranking.js b/ranking.js new file mode 100644 index 0000000..1b2a6b5 --- /dev/null +++ b/ranking.js @@ -0,0 +1,14 @@ +const pool = require('../db'); + +async function getRanking(req, res) { + try { + const connection = await pool.getConnection(); + const [ranking] = await connection.query('SELECT student_name, student_id, score, call_count FROM students ORDER BY score DESC'); + connection.release(); + res.send({ ranking }); + } catch (error) { + res.status(500).send({ error: '无法获取排名' }); + } +} + +module.exports = { getRanking };