Browse Source

Merge branch 'dev' of ssh://gitea.anxinyun.cn:2022/gao.zhiyuan/OperationalService into dev

dev
deartibers 2 years ago
parent
commit
f257601adb
  1. 10
      api/app/lib/controllers/alarm/app.js
  2. 9
      api/app/lib/controllers/organization/index.js
  3. 2
      api/app/lib/controllers/project/bind.js
  4. 6
      api/app/lib/controllers/project/index.js
  5. 6
      api/app/lib/controllers/push/config.js
  6. 14
      api/app/lib/middlewares/duration-calc.js
  7. 1
      api/app/lib/routes/organization/index.js

10
api/app/lib/controllers/alarm/app.js

@ -89,7 +89,7 @@ async function inspectionList (ctx) {
ctx.status = 200; ctx.status = 200;
ctx.body = inspectionRes ctx.body = inspectionRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -114,7 +114,7 @@ async function notedInspection (ctx) {
ctx.status = 204; ctx.status = 204;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -159,7 +159,7 @@ async function apiError (ctx) {
ctx.status = 200; ctx.status = 200;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -176,7 +176,7 @@ async function apiErrorList (ctx) {
ctx.status = 200; ctx.status = 200;
ctx.body = [] ctx.body = []
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -199,7 +199,7 @@ async function confirmApiError (ctx) {
ctx.status = 204; ctx.status = 204;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined

9
api/app/lib/controllers/organization/index.js

@ -5,13 +5,16 @@ async function allDeps (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { redis } = ctx.app const { redis } = ctx.app
const start = moment()
let depRes = await redis.get('allDepartments') let depRes = await redis.get('allDepartments')
console.log(`DurationCalc: 1 用时 ${moment().diff(start, 'milliseconds')}`);
if (depRes) { if (depRes) {
depRes = JSON.parse(depRes) depRes = JSON.parse(depRes)
console.log(`DurationCalc: 2 用时 ${moment().diff(start, 'milliseconds')}`);
depRes = depRes.departments depRes = depRes.departments
console.log(`DurationCalc: 3 用时 ${moment().diff(start, 'milliseconds')}`);
} }
console.log(`DurationCalc: 4 用时 ${moment().diff(start, 'milliseconds')}`);
ctx.status = 200; ctx.status = 200;
ctx.body = depRes || [] ctx.body = depRes || []
} catch (error) { } catch (error) {
@ -147,7 +150,7 @@ async function delAdmin (ctx) {
ctx.status = 204; ctx.status = 204;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined

2
api/app/lib/controllers/project/bind.js

@ -9,7 +9,7 @@ async function bindAnxin2pep (ctx) {
ctx.status = 20; ctx.status = 20;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined

6
api/app/lib/controllers/project/index.js

@ -12,7 +12,7 @@ async function appList (ctx) {
ctx.status = 200; ctx.status = 200;
ctx.body = appRes ctx.body = appRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -30,7 +30,7 @@ async function projectAnxincloud (ctx) {
ctx.status = 200; ctx.status = 200;
ctx.body = projectRes ctx.body = projectRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -48,7 +48,7 @@ async function projectPManage (ctx) {
ctx.status = 200; ctx.status = 200;
ctx.body = projectRes ctx.body = projectRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined

6
api/app/lib/controllers/push/config.js

@ -37,7 +37,7 @@ async function list (ctx) {
ctx.status = 200; ctx.status = 200;
ctx.body = listRes ctx.body = listRes
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -68,7 +68,7 @@ async function edit (ctx) {
ctx.status = 204; ctx.status = 204;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined
@ -100,7 +100,7 @@ async function state (ctx) {
ctx.status = 204; ctx.status = 204;
} catch (error) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;
ctx.body = { ctx.body = {
message: typeof error == 'string' ? error : undefined message: typeof error == 'string' ? error : undefined

14
api/app/lib/middlewares/duration-calc.js

@ -0,0 +1,14 @@
'use strict';
const moment = require('moment');
async function factory (ctx, next) {
try {
const start = moment()
await next()
ctx.fs.logger.log(`DurationCalc: ${ctx.path} 用时 ${moment().diff(start, 'milliseconds')}`);
} catch (error) {
ctx.fs.logger.error(`DurationCalc, error: ${error}`);
}
}
module.exports = factory;

1
api/app/lib/routes/organization/index.js

@ -1,5 +1,4 @@
'use strict'; 'use strict';
const organization = require('../../controllers/organization'); const organization = require('../../controllers/organization');
module.exports = function (app, router, opts) { module.exports = function (app, router, opts) {

Loading…
Cancel
Save