消息接口优化
This commit is contained in:
+3
-3
@@ -140,7 +140,7 @@ router.post(
|
||||
authMiddleware,
|
||||
(req, res) => {
|
||||
const currentUserName = req.user.username;
|
||||
const { contactName, limit } = req.body;
|
||||
const { contactName, limit, offset } = req.body;
|
||||
const sql = `
|
||||
SELECT
|
||||
id,
|
||||
@@ -150,9 +150,9 @@ router.post(
|
||||
created_at
|
||||
FROM chat_mysql.messages
|
||||
WHERE (sender_name = ? OR receiver_name = ?) AND (sender_name = ? OR receiver_name = ?)
|
||||
ORDER BY created_at ASC LIMIT ? ;
|
||||
ORDER BY created_at DESC LIMIT ? OFFSET ?;
|
||||
`;
|
||||
db.query(sql, [currentUserName, currentUserName, contactName, contactName, limit], (error, results) => {
|
||||
db.query(sql, [currentUserName, currentUserName, contactName, contactName, limit, offset], (error, results) => {
|
||||
if (error) {
|
||||
console.error("数据库查询失败:", error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user