From d62de12d1fb3e7f751e5036215815d0299cbe128 Mon Sep 17 00:00:00 2001 From: wangxiaoxian <1094175543@qq.com> Date: Sun, 8 Mar 2026 19:14:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=9F=E6=88=BF=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/roomController.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/controllers/roomController.js b/controllers/roomController.js index db460da..6a0df53 100644 --- a/controllers/roomController.js +++ b/controllers/roomController.js @@ -135,13 +135,14 @@ const getAllRooms = async (req, res) => { const formattedRooms = await Promise.all(rows.map(async (room) => { const formattedRoom = formatRoomData(room); - // 查询非过期且未删除的租房信息 + // 查询非过期且未删除的租房信息,按创建时间倒序排列 const rentals = await Rental.findAll({ where: { roomId: room.id, status: { [Op.ne]: 'expired' }, isDeleted: 0 - } + }, + order: [['createTime', 'DESC']] }); // 格式化租房信息