Browse Source

AlarmId IN uuid 引号包裹

dev
巴林闲侠 2 years ago
parent
commit
7dbce51c9f
  1. 17
      api/app/lib/controllers/auth/index.js
  2. 3
      api/app/lib/routes/auth/index.js
  3. 4
      api/app/lib/schedule/alarms_push.js

17
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,
};

3
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);
};

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

Loading…
Cancel
Save