From 3334a68f06f76af17de6d49bac56b564830503f4 Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 4 Jul 2022 10:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=A6=E6=83=85=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rest/custom/detail.js | 13 +++++++++++++ src/utils/dbUitls.js | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 src/rest/custom/detail.js diff --git a/src/rest/custom/detail.js b/src/rest/custom/detail.js new file mode 100644 index 0000000..8e27404 --- /dev/null +++ b/src/rest/custom/detail.js @@ -0,0 +1,13 @@ +const dbUtils = require("../../utils/dbUitls"); +module.exports = { + action: "/node/custom/addOrUpdate", + method: "post", + execute: (request, response) => { + let {id} = request.query + dbUtils.detail({table: 'node_custom_config', id}).then(data => { + 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 28aa2cb..8afd5f5 100644 --- a/src/utils/dbUitls.js +++ b/src/utils/dbUitls.js @@ -70,5 +70,8 @@ module.exports = { ids = ids?.split(",")?.map(e => `'${e}'`)?.toString() return query(`delete from ${table} where id in (${ids})`) }, + detail: ({table, id}) => { + return query(`select * from ${table} where id='${id}' limit 0,1`) + }, format: args => args.map(e => `${e.prop}`).join(" ") }