diff --git a/src/rest/custom/list.js b/src/rest/custom/list.js index ababa5d..8fd5267 100644 --- a/src/rest/custom/list.js +++ b/src/rest/custom/list.js @@ -3,10 +3,10 @@ module.exports = { action: "/node/custom/list", method: "post", execute: (request, response) => { - let {size, current, name} = request.query + let {size, current, name, type} = request.query dbUtils.list({ table: 'node_custom_config', con: name, - search: {size, current} + search: {size, current, type} }).then(data => { response.send({code: 0, data}) }).catch(err => { diff --git a/src/utils/dbUitls.js b/src/utils/dbUitls.js index 3524afb..376c8ad 100644 --- a/src/utils/dbUitls.js +++ b/src/utils/dbUitls.js @@ -25,7 +25,7 @@ module.exports = { this.pool = mysql.createPool(dbConfig) }, query, - list: ({table, search, con}) => { + list: ({table, search, con = ''}) => { //列表查询 let total = 0, records = [] if (table) { @@ -37,7 +37,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)*size},${size||10}`).then(res => { + query(`select * from ${table} where name like '%${con}%' ${sqlCon} limit ${((current-1)||0)*size},${size||10}`).then(res => { return records = res }) ]).then(() => {