From d553307ea8051a3dcc25f2b2c647c7643b407be1 Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 4 Jul 2022 14:17:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=80=E6=B3=A2=E5=AE=9A?= =?UTF-8?q?=E5=88=B6=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rest/custom/detail.js | 1 + src/utils/dbUitls.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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(" ") }