调整列表工具类
This commit is contained in:
@@ -5,8 +5,8 @@ module.exports = {
|
|||||||
execute: (request, response) => {
|
execute: (request, response) => {
|
||||||
let {size, current, name, type} = request.query
|
let {size, current, name, type} = request.query
|
||||||
dbUtils.list({
|
dbUtils.list({
|
||||||
table: 'node_custom_config', con: name,
|
table: 'node_custom_config',
|
||||||
search: {size, current, type}, sort: 'download'
|
search: {size, current, type, name}, sort: 'download'
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
response.send({code: 0, data})
|
response.send({code: 0, data})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
16
src/rest/monitorApi/list.js
Normal file
16
src/rest/monitorApi/list.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const dbUtils = require("../../utils/dbUitls");
|
||||||
|
module.exports = {
|
||||||
|
action: "/node/monitorApi/list",
|
||||||
|
method: "post",
|
||||||
|
execute: (request, response) => {
|
||||||
|
let {size, current, name: path, status} = request.query
|
||||||
|
dbUtils.list({
|
||||||
|
table: 'node_api_logs', con: 'path',
|
||||||
|
search: {size, current, status, path}, sort: 'createTime'
|
||||||
|
}).then(data => {
|
||||||
|
response.send({code: 0, data})
|
||||||
|
}).catch(err => {
|
||||||
|
response.send({code: 1, err: err?.sqlMessage || err || ""})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,8 @@ module.exports = {
|
|||||||
execute: (request, response) => {
|
execute: (request, response) => {
|
||||||
const {size, current, name, type} = request.query
|
const {size, current, name, type} = request.query
|
||||||
dbUtils.list({
|
dbUtils.list({
|
||||||
table: 'node_wxmp_deploy', con: name,
|
table: 'node_wxmp_deploy',
|
||||||
search: {size, current, type}
|
search: {size, current, type, name}
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
response.send({code: 0, data})
|
response.send({code: 0, data})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
@@ -26,19 +26,21 @@ module.exports = {
|
|||||||
console.log(`${chalk.bgBlue.black(" DATABASE ")} 数据库已连接`)
|
console.log(`${chalk.bgBlue.black(" DATABASE ")} 数据库已连接`)
|
||||||
},
|
},
|
||||||
query,
|
query,
|
||||||
list: ({table, search, con = '', sort}) => {
|
list: ({table, search, con = 'name', sort}) => {
|
||||||
//列表查询
|
//列表查询
|
||||||
let total = 0, records = []
|
let total = 0, records = []
|
||||||
if (table) {
|
if (table) {
|
||||||
const {current, size = 10} = search, params = JSON.parse(JSON.stringify(search))
|
const {current, size = 10} = search, params = JSON.parse(JSON.stringify(search))
|
||||||
|
const conValue = params[con]
|
||||||
delete params.current
|
delete params.current
|
||||||
delete params.size
|
delete params.size
|
||||||
|
delete params[con]
|
||||||
const sqlCon = Object.keys(params).map(e => `and ${e}='${params[e]}'`).join(" ")
|
const sqlCon = Object.keys(params).map(e => `and ${e}='${params[e]}'`).join(" ")
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
query(`select 1 from ${table} where name like '%${con}%' ${sqlCon}`).then(res => {
|
query(`select 1 from ${table} where ${con} like '%${conValue}%' ${sqlCon}`).then(res => {
|
||||||
return total = res.length
|
return total = res.length
|
||||||
}),
|
}),
|
||||||
query(`select * from ${table} where name like '%${con}%' ${sqlCon} order by ${sort||'createTime'} desc limit ${((current-1)||0)*size},${size}`).then(res => {
|
query(`select * from ${table} where ${con} like '%${conValue}%' ${sqlCon} order by ${sort||'createTime'} desc limit ${((current-1)||0)*size},${size}`).then(res => {
|
||||||
return records = res
|
return records = res
|
||||||
})
|
})
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user