diff --git a/src/rest/custom/detail.js b/src/rest/custom/detail.js index 1ccd526..8e48519 100644 --- a/src/rest/custom/detail.js +++ b/src/rest/custom/detail.js @@ -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 || ""}) diff --git a/src/utils/dbUitls.js b/src/utils/dbUitls.js index 8afd5f5..3524afb 100644 --- a/src/utils/dbUitls.js +++ b/src/utils/dbUitls.js @@ -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(" ") }