From ade17c8792b3e27485e4ab5d2e3f603f5500f07d Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 23 Aug 2018 23:10:45 +0800 Subject: [PATCH] add opay data api --- route/api/twitch/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/route/api/twitch/index.js b/route/api/twitch/index.js index 9e39961..b5707a8 100644 --- a/route/api/twitch/index.js +++ b/route/api/twitch/index.js @@ -140,4 +140,26 @@ r.put('/channel/:chid/opay/setting', checkSession, getChannelList, hasChannel('c c.obj = resObject('Success') }) +r.get('/channel/:chid/opay/bar', async (c, n) => { + let chid = c.params.chid || '' + if (typeof chid !== 'string' || chid.trim().length === 0) throw genError('DataFormat') + let text = `select ds.* from "public"."donate_setting" ds + left join "public"."twitch_channel" tw + on tw.id = ds.twitch + where + tw.opayid != '' + and tw.id = $1` + let values = [chid] + + let result = await c.db.query({ + text, + values + }) + let setting = {} + if (result.rowCount === 0) setting = {} + setting = result.rows[0] + + c.obj = resObject('Success', {setting}) +}) + module.exports = r