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(" ") }