add opay data api

This commit is contained in:
Jay 2018-08-23 23:10:45 +08:00
parent 12317413b8
commit ade17c8792

View File

@ -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