优化排列顺序

This commit is contained in:
aixianling
2023-01-31 09:58:01 +08:00
parent e7fd86b1e2
commit 0f58ea80fa
2 changed files with 3 additions and 3 deletions

View File

@@ -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 => {

View File

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