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(() => {