提交一波定制项目

This commit is contained in:
aixianling
2022-07-04 14:17:59 +08:00
parent c60a7362e7
commit d553307ea8
2 changed files with 4 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ module.exports = {
execute: (request, response) => {
let {id} = request.query
dbUtils.detail({table: 'node_custom_config', id}).then(data => {
data.apps && (data.apps = JSON.parse(data.apps))
response.send({code: 0, data})
}).catch(err => {
response.send({code: 1, err: err?.sqlMessage || err || ""})

View File

@@ -1,6 +1,7 @@
const mysql = require("mysql");
const dbConfig = require("../config/db");
const {v4: uuid} = require("uuid");
const dayjs = require("dayjs");
const query = sql => new Promise((resolve, reject) => {
this.pool?.getConnection((err, conn) => {
if (err) {
@@ -62,7 +63,7 @@ module.exports = {
arr.push(`'${form[e]}'`)
}
})
sql = `insert into ${table} (id,${cols.join(",")}) values('${uuid()}',${arr.join(",")})`
sql = `insert into ${table} (id,createTime,${cols.join(",")}) values('${uuid()}','${dayjs().format("YYYY-MM-DD hh:mm:ss")}',${arr.join(",")})`
}
return query(sql)
},
@@ -71,7 +72,7 @@ module.exports = {
return query(`delete from ${table} where id in (${ids})`)
},
detail: ({table, id}) => {
return query(`select * from ${table} where id='${id}' limit 0,1`)
return query(`select * from ${table} where id='${id}' limit 0,1`).then(res => res?.[0])
},
format: args => args.map(e => `${e.prop}`).join(" ")
}