修复筛选条件

This commit is contained in:
aixianling
2022-05-20 09:54:40 +08:00
parent 530eecaed7
commit 1b887f6837

View File

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