From 0f58ea80fafabbc21ff4c85f27631f72c1578bb4 Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 31 Jan 2023 09:58:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=92=E5=88=97=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rest/custom/list.js | 2 +- src/utils/dbUitls.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rest/custom/list.js b/src/rest/custom/list.js index 8fd5267..b66743f 100644 --- a/src/rest/custom/list.js +++ b/src/rest/custom/list.js @@ -6,7 +6,7 @@ module.exports = { let {size, current, name, type} = request.query dbUtils.list({ table: 'node_custom_config', con: name, - search: {size, current, type} + search: {size, current, type}, sort: 'download' }).then(data => { response.send({code: 0, data}) }).catch(err => { diff --git a/src/utils/dbUitls.js b/src/utils/dbUitls.js index e6fafaa..f82e9ae 100644 --- a/src/utils/dbUitls.js +++ b/src/utils/dbUitls.js @@ -26,7 +26,7 @@ module.exports = { console.log(`${chalk.bgBlue.black(" DATABASE ")} 数据库已连接`) }, query, - list: ({table, search, con = ''}) => { + list: ({table, search, con = '', sort}) => { //列表查询 let total = 0, records = [] if (table) { @@ -38,7 +38,7 @@ module.exports = { query(`select 1 from ${table} where name like '%${con}%' ${sqlCon}`).then(res => { return total = res.length }), - query(`select * from ${table} where name like '%${con}%' ${sqlCon} limit ${((current-1)||0)*size},${size||10}`).then(res => { + query(`select * from ${table} where name like '%${con}%' ${sqlCon} limit ${((current-1)||0)*size},${size||10} order by ${sort||'createTime'} desc`).then(res => { return records = res }) ]).then(() => {