diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index 8055d5c..3d7887b 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -70,7 +70,7 @@ async function login (ctx, next) { await ctx.redis.hmset(emisLoginRes.token, { expired: moment().add(1, 'day'), - userInfo:JSON.stringify(emisLoginRes) + userInfo: JSON.stringify(emisLoginRes) }); ctx.status = 200; @@ -93,13 +93,19 @@ async function login (ctx, next) { } } -async function complement (ctx) { +async function loginWithToken (ctx) { try { const { models } = ctx.fs.dc; - - ctx.status = 20; + const { token } = ctx.request.body + + const emisLoginRes = await ctx.app.fs.emisRequest.get('user-info', { + query: { token, code: 'POMS' } + }) + + ctx.status = 200; + ctx.body = {} } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -130,4 +136,5 @@ async function logout (ctx) { module.exports = { login, logout, + loginWithToken, }; \ No newline at end of file diff --git a/api/app/lib/routes/auth/index.js b/api/app/lib/routes/auth/index.js index c4df619..db2b20c 100644 --- a/api/app/lib/routes/auth/index.js +++ b/api/app/lib/routes/auth/index.js @@ -6,6 +6,9 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['POST/login'] = { content: '登录', visible: true }; router.post('/login', auth.login); + app.fs.api.logAttr['POST/login/with_token'] = { content: '使用项企token登录', visible: true }; + router.post('/login/with_token', auth.loginWithToken); + app.fs.api.logAttr['PUT/logout'] = { content: '登出', visible: false }; router.put('/logout', auth.logout); }; \ No newline at end of file diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index c98f033..3074b5a 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -678,10 +678,12 @@ module.exports = function (app, opts) { console.log(dataAlarms); } if (dataAlarms.length) { + const alarmIds = dataAlarms + .map(ar => "'" + ar.AlarmId + "'") dataAlarmDetails = await clickHouse.dataAlarm.query(` SELECT * FROM alarm_details - WHERE AlarmId IN (${dataAlarms.map(da => da.AlarmId).join(',')}, '-1') + WHERE AlarmId IN (${alarmIds.join(',')}, '-1') AND AlarmState = 0 `).toPromise() }