修改 手机端 显示名称错位的问题
This commit is contained in:
25
server2.js
25
server2.js
@@ -99,6 +99,31 @@ app.get("/test-db", async (req, res) => {
|
||||
res.send("FAIL");
|
||||
}
|
||||
});
|
||||
app.post("/user", async (req, res) => {
|
||||
try {
|
||||
const { userId } = req.body; // 从请求体里拿到 user_id
|
||||
|
||||
if (!userId) {
|
||||
return res.status(400).send("缺少 user_id");
|
||||
}
|
||||
|
||||
// 查询 user_name
|
||||
const [rows] = await pool.query(
|
||||
"SELECT user_name FROM sys_user WHERE user_id = ?",
|
||||
[userId]
|
||||
);
|
||||
|
||||
if (rows.length === 0) {
|
||||
return res.status(404).send("未找到该用户");
|
||||
}
|
||||
|
||||
res.json({ code:0,userId, userName: rows[0].user_name });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).send("服务器错误");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 查询用户所有会话列表
|
||||
app.get("/sessions", async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user