diff --git a/src/rest/wechatapps/list.js b/src/rest/wechatapps/list.js index 794d486..9b90907 100644 --- a/src/rest/wechatapps/list.js +++ b/src/rest/wechatapps/list.js @@ -5,12 +5,13 @@ module.exports = { execute: (request, response) => { let total = 0, records = [], {size, current = 1, name = "", type} = request.query if (type) { + let condition = `where type='${type}' and (name like '%${name}%' or label like '%${name}%')` Promise.all([ - dbUtils.query(`select 1 from node_wechat_apps where type='${type}'`).then(res => { + dbUtils.query(`select 1 from node_wechat_apps ${condition}`).then(res => { return total = res.length }), new Promise(resolve => { - let sql = `select * from node_wechat_apps where type='${type}' and name like '%${name}%' or label like '%${name}%' limit ${(current-1)*size},${size}` + let sql = `select * from node_wechat_apps ${condition} limit ${(current-1)*size},${size}` dbUtils.query(sql).then(res => { records = res resolve()