正在显示
26 个修改的文件
包含
2390 行增加
和
1558 行删除
Dockerfile
0 → 100644
@@ -35,17 +35,17 @@ var settings = IoC.create('igloo/settings'); | @@ -35,17 +35,17 @@ var settings = IoC.create('igloo/settings'); | ||
35 | app.boot(function(err) { | 35 | app.boot(function(err) { |
36 | 36 | ||
37 | if (err) { | 37 | if (err) { |
38 | - logger.error(err.message); | 38 | + logger.debug(err.message); |
39 | 39 | ||
40 | if (settings.showStack) { | 40 | if (settings.showStack) { |
41 | - logger.error(err.stack); | 41 | + logger.debug(err.stack); |
42 | } | 42 | } |
43 | 43 | ||
44 | process.exit(-1); | 44 | process.exit(-1); |
45 | return; | 45 | return; |
46 | } | 46 | } |
47 | 47 | ||
48 | - logger.info('app booted'); | 48 | + logger.debug('app booted'); |
49 | 49 | ||
50 | }); | 50 | }); |
51 | 51 |
@@ -2,10 +2,10 @@ | @@ -2,10 +2,10 @@ | ||
2 | 2 | ||
3 | var path = require('path'); | 3 | var path = require('path'); |
4 | 4 | ||
5 | -var parentDir = path.join(__dirname, '..'); | 5 | +var parentDir = path.join(__dirname, '..', '..'); |
6 | var appDir = path.join(parentDir, 'server'); | 6 | var appDir = path.join(parentDir, 'server'); |
7 | 7 | ||
8 | -var pkg = require(path.join(parentDir, 'package')); | 8 | +// var pkg = require(path.join(parentDir, 'package')); |
9 | 9 | ||
10 | var assetsDir = path.join(parentDir, 'build'); | 10 | var assetsDir = path.join(parentDir, 'build'); |
11 | var publicDir = path.join(assetsDir, 'public'); | 11 | var publicDir = path.join(assetsDir, 'public'); |
@@ -18,6 +18,9 @@ exports = module.exports = function () { | @@ -18,6 +18,9 @@ exports = module.exports = function () { | ||
18 | 18 | ||
19 | return { | 19 | return { |
20 | defaults: { | 20 | defaults: { |
21 | + hostConfig: { | ||
22 | + jincao:[ ], | ||
23 | + }, | ||
21 | basicAuth: { | 24 | basicAuth: { |
22 | enabled: false, | 25 | enabled: false, |
23 | name: 'admin', | 26 | name: 'admin', |
@@ -38,7 +41,7 @@ exports = module.exports = function () { | @@ -38,7 +41,7 @@ exports = module.exports = function () { | ||
38 | clientID: '', | 41 | clientID: '', |
39 | clientSecret: '' | 42 | clientSecret: '' |
40 | }, | 43 | }, |
41 | - pkg: pkg, | 44 | + // pkg: pkg, |
42 | cache: false, | 45 | cache: false, |
43 | showStack: true, | 46 | showStack: true, |
44 | assetsDir: assetsDir, | 47 | assetsDir: assetsDir, |
@@ -86,7 +89,7 @@ exports = module.exports = function () { | @@ -86,7 +89,7 @@ exports = module.exports = function () { | ||
86 | path: '/', | 89 | path: '/', |
87 | httpOnly: true, | 90 | httpOnly: true, |
88 | secure: false, | 91 | secure: false, |
89 | - sameSite: 'strict', | 92 | + // sameSite: 'strict', |
90 | maxAge: maxAge | 93 | maxAge: maxAge |
91 | }, | 94 | }, |
92 | resave: true, | 95 | resave: true, |
@@ -112,7 +115,7 @@ exports = module.exports = function () { | @@ -112,7 +115,7 @@ exports = module.exports = function () { | ||
112 | }, | 115 | }, |
113 | cookieParser: 'igloo-change-me', | 116 | cookieParser: 'igloo-change-me', |
114 | csrf: { | 117 | csrf: { |
115 | - enabled: false, | 118 | + enabled: true, |
116 | options: { | 119 | options: { |
117 | cookie: { | 120 | cookie: { |
118 | maxAge: maxAge | 121 | maxAge: maxAge |
@@ -133,10 +136,12 @@ exports = module.exports = function () { | @@ -133,10 +136,12 @@ exports = module.exports = function () { | ||
133 | redis: { | 136 | redis: { |
134 | host: '192.168.2.70', | 137 | host: '192.168.2.70', |
135 | port: 38888, | 138 | port: 38888, |
136 | - pass: 'Workai123', | ||
137 | - maxAge: maxAge | 139 | + pass: 'Q*Kr4?#Rg!', |
140 | + maxAge: maxAge, | ||
141 | + name: '' | ||
138 | }, | 142 | }, |
139 | output: { | 143 | output: { |
144 | + level: 'info', | ||
140 | handleExceptions: false, | 145 | handleExceptions: false, |
141 | colorize: true, | 146 | colorize: true, |
142 | prettyPrint: false | 147 | prettyPrint: false |
@@ -168,9 +173,9 @@ exports = module.exports = function () { | @@ -168,9 +173,9 @@ exports = module.exports = function () { | ||
168 | // url: 'http://154.8.229.55:20000/', | 173 | // url: 'http://154.8.229.55:20000/', |
169 | // url:'http://192.144.144.220:20000/', | 174 | // url:'http://192.144.144.220:20000/', |
170 | //url:'http://127.0.0.1:20000/', | 175 | //url:'http://127.0.0.1:20000/', |
171 | - url: 'http://47.110.250.177:20000', | 176 | + url: 'http://47.110.250.177:7003/', |
172 | // url:'http://140.143.196.80:20000/', | 177 | // url:'http://140.143.196.80:20000/', |
173 | - ossUrl: 'http://192.168.2.72:20000/', | 178 | + ossUrl: 'http://47.110.250.177:7003/', |
174 | version: '/v1' | 179 | version: '/v1' |
175 | }, | 180 | }, |
176 | prefix: '/', | 181 | prefix: '/', |
@@ -203,7 +208,8 @@ exports = module.exports = function () { | @@ -203,7 +208,8 @@ exports = module.exports = function () { | ||
203 | prefix: 'igloo_production_test_develop', | 208 | prefix: 'igloo_production_test_develop', |
204 | host: '172.21.0.8', | 209 | host: '172.21.0.8', |
205 | port: 38888, | 210 | port: 38888, |
206 | - pass: 'Workai123' | 211 | + pass: 'Q*Kr4?#Rg!', |
212 | + name: '' | ||
207 | }, | 213 | }, |
208 | logger: { | 214 | logger: { |
209 | 'console': true, | 215 | 'console': true, |
@@ -240,6 +246,7 @@ exports = module.exports = function () { | @@ -240,6 +246,7 @@ exports = module.exports = function () { | ||
240 | host: '127.0.0.1', | 246 | host: '127.0.0.1', |
241 | port: 6379, | 247 | port: 6379, |
242 | pass: '', | 248 | pass: '', |
249 | + name: '' | ||
243 | } | 250 | } |
244 | }, | 251 | }, |
245 | production: { | 252 | production: { |
@@ -254,11 +261,22 @@ exports = module.exports = function () { | @@ -254,11 +261,22 @@ exports = module.exports = function () { | ||
254 | enabled: false, | 261 | enabled: false, |
255 | }, | 262 | }, |
256 | restful: { | 263 | restful: { |
257 | - url: 'http://192.168.2.72:20000/', | ||
258 | - ossUrl: 'http://192.168.2.72:20000/', | 264 | + // url: 'http://192.168.2.72:20000/', |
265 | + // ossUrl: 'http://192.168.2.72:20000/', | ||
266 | + url: 'http://47.110.250.177:7003/', | ||
267 | + ossUrl: 'http://47.110.250.177:7003/', | ||
268 | + redirectMobileUrl: 'http://dev.workai.com.cn/authorization-code', | ||
259 | version: '/v1', | 269 | version: '/v1', |
260 | - host: '192.168.2.72', | ||
261 | - port: 20000 | 270 | + // host: '192.168.2.72', |
271 | + host: '47.110.250.177', | ||
272 | + // port: 20000 | ||
273 | + port: 7003 | ||
274 | + }, | ||
275 | + excellentRestful: { | ||
276 | + url: 'http://47.110.250.177:8000/', | ||
277 | + version: '/v1', | ||
278 | + host: '47.110.250.177', | ||
279 | + port: 8000 | ||
262 | }, | 280 | }, |
263 | server: { | 281 | server: { |
264 | host: '0.0.0.0', | 282 | host: '0.0.0.0', |
@@ -279,17 +297,18 @@ exports = module.exports = function () { | @@ -279,17 +297,18 @@ exports = module.exports = function () { | ||
279 | } | 297 | } |
280 | }, | 298 | }, |
281 | redis: { | 299 | redis: { |
282 | - prefix: 'igloo_production', | ||
283 | - host: '127.0.0.1', | ||
284 | - port: 6379, | ||
285 | - pass: 'Workai123' | 300 | + prefix: 'igloo_production', |
301 | + host:'redis', | ||
302 | + port: 38888, | ||
303 | + pass: 'Q*Kr4?#Rg!', | ||
304 | + name: '' | ||
286 | }, | 305 | }, |
287 | csrf: { | 306 | csrf: { |
288 | enabled: true, | 307 | enabled: true, |
289 | options: { | 308 | options: { |
290 | cookie: { | 309 | cookie: { |
291 | maxAge: maxAge, | 310 | maxAge: maxAge, |
292 | - sameSite: 'strict', | 311 | + // sameSite: 'strict', |
293 | path: '/', | 312 | path: '/', |
294 | key: '_csrf', | 313 | key: '_csrf', |
295 | httpOnly: true | 314 | httpOnly: true |
@@ -297,6 +316,7 @@ exports = module.exports = function () { | @@ -297,6 +316,7 @@ exports = module.exports = function () { | ||
297 | } | 316 | } |
298 | }, | 317 | }, |
299 | output: { | 318 | output: { |
319 | + level: 'info', | ||
300 | colorize: false | 320 | colorize: false |
301 | }, | 321 | }, |
302 | logger: { | 322 | logger: { |
@@ -337,7 +357,7 @@ exports = module.exports = function () { | @@ -337,7 +357,7 @@ exports = module.exports = function () { | ||
337 | prefix: 'igloo_production_recruitIterative', | 357 | prefix: 'igloo_production_recruitIterative', |
338 | host: '127.0.0.1', | 358 | host: '127.0.0.1', |
339 | port: 38888, | 359 | port: 38888, |
340 | - pass: 'Workai123' | 360 | + pass: 'Q*Kr4?#Rg!' |
341 | }, | 361 | }, |
342 | csrf: { | 362 | csrf: { |
343 | enabled: true, | 363 | enabled: true, |
@@ -372,6 +392,7 @@ exports = module.exports = function () { | @@ -372,6 +392,7 @@ exports = module.exports = function () { | ||
372 | // url: 'http://47.110.158.110:20000/', | 392 | // url: 'http://47.110.158.110:20000/', |
373 | url: 'http://47.110.250.177:20000/', | 393 | url: 'http://47.110.250.177:20000/', |
374 | ossUrl: 'http://140.143.196.80:10001/v1/', | 394 | ossUrl: 'http://140.143.196.80:10001/v1/', |
395 | + redirectMobileUrl: 'http://dev.workai.com.cn/authorization-code', | ||
375 | version: '/v1', | 396 | version: '/v1', |
376 | // host: '47.110.158.110', | 397 | // host: '47.110.158.110', |
377 | host: '47.110.250.177', | 398 | host: '47.110.250.177', |
@@ -385,9 +406,9 @@ exports = module.exports = function () { | @@ -385,9 +406,9 @@ exports = module.exports = function () { | ||
385 | }, | 406 | }, |
386 | redis: { | 407 | redis: { |
387 | prefix: 'igloo_production_hroRecruit', | 408 | prefix: 'igloo_production_hroRecruit', |
388 | - host: '127.0.0.1', | 409 | + host: '10.95.222.102', |
389 | port: 38888, | 410 | port: 38888, |
390 | - pass: 'Workai123' | 411 | + pass: 'Q*Kr4?#Rg!' |
391 | }, | 412 | }, |
392 | csrf: { | 413 | csrf: { |
393 | enabled: true, | 414 | enabled: true, |
@@ -406,7 +427,7 @@ exports = module.exports = function () { | @@ -406,7 +427,7 @@ exports = module.exports = function () { | ||
406 | requests: true, | 427 | requests: true, |
407 | mongo: false, | 428 | mongo: false, |
408 | file: { | 429 | file: { |
409 | - filename: '/opt/work/hro/frontend/hro-tax/igloo.log', | 430 | + filename: '/opt/work/hro/frontend/hro-recruit/igloo.log', |
410 | timestamp: true | 431 | timestamp: true |
411 | } | 432 | } |
412 | } | 433 | } |
@@ -438,7 +459,7 @@ exports = module.exports = function () { | @@ -438,7 +459,7 @@ exports = module.exports = function () { | ||
438 | host: '172.26.212.124', //外服环境 | 459 | host: '172.26.212.124', //外服环境 |
439 | // host: '127.0.0.1', | 460 | // host: '127.0.0.1', |
440 | port: 38888, | 461 | port: 38888, |
441 | - pass: 'Workai123' | 462 | + pass: 'Q*Kr4?#Rg!' |
442 | }, | 463 | }, |
443 | csrf: { | 464 | csrf: { |
444 | enabled: true, | 465 | enabled: true, |
@@ -471,13 +492,21 @@ exports = module.exports = function () { | @@ -471,13 +492,21 @@ exports = module.exports = function () { | ||
471 | }, | 492 | }, |
472 | restful: { | 493 | restful: { |
473 | // url: 'http://47.110.158.110:20000/', | 494 | // url: 'http://47.110.158.110:20000/', |
474 | - url: 'http://47.110.250.177:20000/', | 495 | + // url: 'http://47.110.250.177:20000/', |
496 | + url: 'http://39.104.52.206:20000/', | ||
475 | ossUrl: 'http://140.143.196.80:10001/v1/', | 497 | ossUrl: 'http://140.143.196.80:10001/v1/', |
476 | version: '/v1', | 498 | version: '/v1', |
477 | // host: '47.110.158.110', | 499 | // host: '47.110.158.110', |
478 | - host: '47.110.250.177', | 500 | + // host: '47.110.250.177', |
501 | + host: '39.104.52.206', | ||
479 | port: 20000 | 502 | port: 20000 |
480 | }, | 503 | }, |
504 | + excellentRestful: { | ||
505 | + url: 'http://39.104.52.206:8000/', | ||
506 | + version: '/v1', | ||
507 | + host: '39.104.52.206', | ||
508 | + port: 8000 | ||
509 | + }, | ||
481 | server: { | 510 | server: { |
482 | host: '0.0.0.0', | 511 | host: '0.0.0.0', |
483 | env: 'production', | 512 | env: 'production', |
@@ -488,7 +517,8 @@ exports = module.exports = function () { | @@ -488,7 +517,8 @@ exports = module.exports = function () { | ||
488 | prefix: 'igloo_production_hroSalary', | 517 | prefix: 'igloo_production_hroSalary', |
489 | host: '172.26.212.124', | 518 | host: '172.26.212.124', |
490 | port: 38888, | 519 | port: 38888, |
491 | - pass: 'Workai123' | 520 | + pass: 'Q*Kr4?#Rg!', |
521 | + name: '' | ||
492 | }, | 522 | }, |
493 | csrf: { | 523 | csrf: { |
494 | enabled: true, | 524 | enabled: true, |
@@ -536,7 +566,7 @@ exports = module.exports = function () { | @@ -536,7 +566,7 @@ exports = module.exports = function () { | ||
536 | prefix: 'igloo_production_sipolicyIterative', | 566 | prefix: 'igloo_production_sipolicyIterative', |
537 | host: '127.0.0.1', | 567 | host: '127.0.0.1', |
538 | port: 38888, | 568 | port: 38888, |
539 | - pass: 'Workai123' | 569 | + pass: 'Q*Kr4?#Rg!' |
540 | }, | 570 | }, |
541 | logger: { | 571 | logger: { |
542 | 'console': true, | 572 | 'console': true, |
@@ -571,7 +601,7 @@ exports = module.exports = function () { | @@ -571,7 +601,7 @@ exports = module.exports = function () { | ||
571 | prefix: 'igloo_production_hroSipolicy', | 601 | prefix: 'igloo_production_hroSipolicy', |
572 | host: '127.0.0.1', | 602 | host: '127.0.0.1', |
573 | port: 38888, | 603 | port: 38888, |
574 | - pass: 'Workai123' | 604 | + pass: 'Q*Kr4?#Rg!' |
575 | }, | 605 | }, |
576 | logger: { | 606 | logger: { |
577 | 'console': true, | 607 | 'console': true, |
@@ -591,13 +621,12 @@ exports = module.exports = function () { | @@ -591,13 +621,12 @@ exports = module.exports = function () { | ||
591 | enabled: false, | 621 | enabled: false, |
592 | }, | 622 | }, |
593 | restful: { | 623 | restful: { |
594 | - url: 'http://47.110.158.110:20000/', | ||
595 | - // url: 'http://47.110.250.177:20000/', | 624 | + url: 'http://47.110.250.177:20000/', |
596 | // url: 'http://39.104.52.206:20000/', | 625 | // url: 'http://39.104.52.206:20000/', |
597 | ossUrl: 'http://172.21.0.8:10001/v1/', | 626 | ossUrl: 'http://172.21.0.8:10001/v1/', |
598 | version: '/v1', | 627 | version: '/v1', |
599 | - host: '47.110.158.110', | ||
600 | - // host: '47.110.250.177', | 628 | + // host: '47.110.158.110', |
629 | + host: '47.110.250.177', | ||
601 | // host: '39.104.52.206', | 630 | // host: '39.104.52.206', |
602 | port: 20000 | 631 | port: 20000 |
603 | }, | 632 | }, |
@@ -610,10 +639,10 @@ exports = module.exports = function () { | @@ -610,10 +639,10 @@ exports = module.exports = function () { | ||
610 | }, | 639 | }, |
611 | redis: { | 640 | redis: { |
612 | prefix: 'igloo_production_settlemgmIterative', | 641 | prefix: 'igloo_production_settlemgmIterative', |
613 | - host: '127.0.0.1', | ||
614 | - // host: '172.26.212.124', | 642 | + // host: '127.0.0.1', |
643 | + host: '172.26.212.124', | ||
615 | port: 38888, | 644 | port: 38888, |
616 | - pass: 'Workai123' | 645 | + pass: 'Q*Kr4?#Rg!' |
617 | 646 | ||
618 | }, | 647 | }, |
619 | logger: { | 648 | logger: { |
@@ -648,13 +677,15 @@ exports = module.exports = function () { | @@ -648,13 +677,15 @@ exports = module.exports = function () { | ||
648 | restful: { | 677 | restful: { |
649 | // url: 'http://47.110.158.110:20000/', | 678 | // url: 'http://47.110.158.110:20000/', |
650 | // url: 'http://47.110.250.177:20000/', | 679 | // url: 'http://47.110.250.177:20000/', |
651 | - url: 'http://39.104.52.206:20000/', | 680 | + url: 'http://47.110.250.177:9103/', |
681 | + // url: 'http://39.104.52.206:20000/', | ||
652 | ossUrl: 'http://140.143.196.80:10001/v1/', | 682 | ossUrl: 'http://140.143.196.80:10001/v1/', |
653 | version: '/v1', | 683 | version: '/v1', |
654 | // host: '47.110.158.110', | 684 | // host: '47.110.158.110', |
655 | - // host: '47.110.250.177', | ||
656 | - host: '39.104.52.206', | ||
657 | - port: 20000 | 685 | + host: '47.110.250.177', |
686 | + // host: '39.104.52.206', | ||
687 | + // port: 20000, | ||
688 | + port: 9103, | ||
658 | }, | 689 | }, |
659 | server: { | 690 | server: { |
660 | host: '0.0.0.0', | 691 | host: '0.0.0.0', |
@@ -664,17 +695,16 @@ exports = module.exports = function () { | @@ -664,17 +695,16 @@ exports = module.exports = function () { | ||
664 | }, | 695 | }, |
665 | redis: { | 696 | redis: { |
666 | prefix: 'igloo_production_hroSettlemgm', | 697 | prefix: 'igloo_production_hroSettlemgm', |
667 | - // host: '127.0.0.1', | ||
668 | - host: '172.26.212.124', | 698 | + host: '127.0.0.1', |
669 | port: 38888, | 699 | port: 38888, |
670 | - pass: 'Workai123' | 700 | + pass: 'Q*Kr4?#Rg!' |
671 | }, | 701 | }, |
672 | logger: { | 702 | logger: { |
673 | 'console': true, | 703 | 'console': true, |
674 | requests: true, | 704 | requests: true, |
675 | mongo: false, | 705 | mongo: false, |
676 | file: { | 706 | file: { |
677 | - filename: '/opt/work/hro/frontend/hro-settlemgm/igloo.log', | 707 | + filename: '/opt/work/hro/frontend/hro/igloo.log', |
678 | timestamp: true | 708 | timestamp: true |
679 | } | 709 | } |
680 | }, | 710 | }, |
@@ -714,7 +744,7 @@ exports = module.exports = function () { | @@ -714,7 +744,7 @@ exports = module.exports = function () { | ||
714 | prefix: 'igloo_production_hroTemp', | 744 | prefix: 'igloo_production_hroTemp', |
715 | host: '172.21.0.8', | 745 | host: '172.21.0.8', |
716 | port: 38888, | 746 | port: 38888, |
717 | - pass: 'Workai123' | 747 | + pass: 'Q*Kr4?#Rg!' |
718 | }, | 748 | }, |
719 | logger: { | 749 | logger: { |
720 | 'console': true, | 750 | 'console': true, |
@@ -750,7 +780,7 @@ exports = module.exports = function () { | @@ -750,7 +780,7 @@ exports = module.exports = function () { | ||
750 | prefix: 'igloo_production_hroOddjobs', | 780 | prefix: 'igloo_production_hroOddjobs', |
751 | host: '192.168.12.188', | 781 | host: '192.168.12.188', |
752 | port: 38888, | 782 | port: 38888, |
753 | - pass: 'Workai123' | 783 | + pass: 'Q*Kr4?#Rg!' |
754 | }, | 784 | }, |
755 | logger: { | 785 | logger: { |
756 | 'console': true, | 786 | 'console': true, |
boot/config.local.js
0 → 100644
1 | +/* | ||
2 | + * @Descripttion: | ||
3 | + * @version: | ||
4 | + * @Author: sueRimn | ||
5 | + * @Date: 2020-06-28 15:34:13 | ||
6 | + * @LastEditors: genglw | ||
7 | + * @LastEditTime: 2022-08-30 20:30:09 | ||
8 | + */ | ||
9 | + | ||
10 | +// # local config (make sure it is ignored by git) | ||
11 | +// | ||
12 | +// This configuration file is specific to each developer's environment, | ||
13 | +// and will merge on top of all other settings from ./config.js | ||
14 | +// (but only will merge in development environment) | ||
15 | +// | ||
16 | +var maxAge = 60 * 60 * 1000 * 25; | ||
17 | +exports = module.exports = function () { | ||
18 | + return { | ||
19 | + cache: false, | ||
20 | + server: { | ||
21 | + host: "0.0.0.0", | ||
22 | + port: 3000, | ||
23 | + }, | ||
24 | + email: { | ||
25 | + // <https://github.com/andris9/Nodemailer> | ||
26 | + transport: { | ||
27 | + service: "gmail", | ||
28 | + auth: { | ||
29 | + user: "user@gmail.com", | ||
30 | + pass: "abc123", | ||
31 | + }, | ||
32 | + }, | ||
33 | + }, | ||
34 | + restful: { | ||
35 | + url: 'http://47.110.250.177:9201/', | ||
36 | + // url: 'http://47.110.250.177:7002/', | ||
37 | + ossUrl: 'http://47.110.250.177:7003/', | ||
38 | + version: '/v1', | ||
39 | + host: '47.110.250.177', | ||
40 | + // port: 7002, | ||
41 | + port: 9201, | ||
42 | + }, | ||
43 | + excellentRestful: { | ||
44 | + url: "http://47.110.250.177:8000/", | ||
45 | + version: "/v1", | ||
46 | + host: "47.110.250.177", | ||
47 | + port: 8000, | ||
48 | + }, | ||
49 | + csrf: { | ||
50 | + enabled: false, | ||
51 | + options: { | ||
52 | + cookie: { | ||
53 | + maxAge: maxAge, | ||
54 | + key: "_csrf", | ||
55 | + path: "/", | ||
56 | + httpOnly: true, | ||
57 | + sameSite: "strict", | ||
58 | + }, | ||
59 | + ignoreMethods: ["HEAD", "OPTIONS", "GET"], | ||
60 | + }, | ||
61 | + }, | ||
62 | + output: { | ||
63 | + level: 'debug', | ||
64 | + colorize: true, | ||
65 | + prettyPrint: true | ||
66 | + }, | ||
67 | + liveReload: { | ||
68 | + enabled: true, | ||
69 | + port: 35729, | ||
70 | + }, | ||
71 | + }; | ||
72 | +}; | ||
73 | + | ||
74 | +exports['@singleton'] = true; |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * @Author: sueRimn | 4 | * @Author: sueRimn |
5 | * @Date: 2020-06-28 15:34:13 | 5 | * @Date: 2020-06-28 15:34:13 |
6 | * @LastEditors: genglw | 6 | * @LastEditors: genglw |
7 | - * @LastEditTime: 2021-12-23 14:56:59 | 7 | + * @LastEditTime: 2022-08-30 20:30:09 |
8 | */ | 8 | */ |
9 | 9 | ||
10 | // # local config (make sure it is ignored by git) | 10 | // # local config (make sure it is ignored by git) |
@@ -18,51 +18,56 @@ exports = module.exports = function () { | @@ -18,51 +18,56 @@ exports = module.exports = function () { | ||
18 | return { | 18 | return { |
19 | cache: false, | 19 | cache: false, |
20 | server: { | 20 | server: { |
21 | - host: '0.0.0.0', | ||
22 | - port: 3009 | 21 | + host: "0.0.0.0", |
22 | + port: 3000, | ||
23 | }, | 23 | }, |
24 | email: { | 24 | email: { |
25 | // <https://github.com/andris9/Nodemailer> | 25 | // <https://github.com/andris9/Nodemailer> |
26 | transport: { | 26 | transport: { |
27 | - service: 'gmail', | 27 | + service: "gmail", |
28 | auth: { | 28 | auth: { |
29 | - user: 'user@gmail.com', | ||
30 | - pass: 'abc123' | ||
31 | - } | ||
32 | - } | 29 | + user: "user@gmail.com", |
30 | + pass: "abc123", | ||
31 | + }, | ||
32 | + }, | ||
33 | }, | 33 | }, |
34 | restful: { | 34 | restful: { |
35 | - // url: 'http://118.178.181.180:20000/', | ||
36 | - url: 'http://47.110.250.177:9201/', | ||
37 | - // url: 'http://47.110.158.110:20000/', | ||
38 | - // url:'http://120.27.220.60:20000/', | ||
39 | - // url: 'http://39.104.52.206:20000/', | ||
40 | - // url: 'http://47.99.189.12:20000/', | ||
41 | - ossUrl: 'http://47.110.250.177:9201/', | 35 | + // url: 'http://47.110.250.177:9201/', |
36 | + url: 'http://47.110.250.177:7002/', | ||
37 | + ossUrl: 'http://47.110.250.177:7003/', | ||
42 | version: '/v1', | 38 | version: '/v1', |
43 | host: '47.110.250.177', | 39 | host: '47.110.250.177', |
44 | - // host: '47.110.158.110', | ||
45 | - // host: '120.27.220.60', | ||
46 | - // host: '39.104.52.206', | ||
47 | - port: 9201 | 40 | + port: 7002, |
41 | + // port: 9201, | ||
42 | + }, | ||
43 | + excellentRestful: { | ||
44 | + url: "http://47.110.250.177:8000/", | ||
45 | + version: "/v1", | ||
46 | + host: "47.110.250.177", | ||
47 | + port: 8000, | ||
48 | }, | 48 | }, |
49 | csrf: { | 49 | csrf: { |
50 | - enabled: true, | 50 | + enabled: false, |
51 | options: { | 51 | options: { |
52 | cookie: { | 52 | cookie: { |
53 | maxAge: maxAge, | 53 | maxAge: maxAge, |
54 | - key: '_csrf', | ||
55 | - path: '/', | 54 | + key: "_csrf", |
55 | + path: "/", | ||
56 | httpOnly: true, | 56 | httpOnly: true, |
57 | - sameSite: 'strict', | 57 | + sameSite: "strict", |
58 | }, | 58 | }, |
59 | - ignoreMethods: ['HEAD', 'OPTIONS', 'GET'] | ||
60 | - } | 59 | + ignoreMethods: ["HEAD", "OPTIONS", "GET"], |
60 | + }, | ||
61 | + }, | ||
62 | + output: { | ||
63 | + level: 'debug', | ||
64 | + colorize: true, | ||
65 | + prettyPrint: true | ||
61 | }, | 66 | }, |
62 | liveReload: { | 67 | liveReload: { |
63 | enabled: true, | 68 | enabled: true, |
64 | - port: 35729 | ||
65 | - } | 69 | + port: 35729, |
70 | + }, | ||
66 | }; | 71 | }; |
67 | }; | 72 | }; |
68 | 73 |
@@ -13,7 +13,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -13,7 +13,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
13 | 'headers': { | 13 | 'headers': { |
14 | "Accept": "application/json", | 14 | "Accept": "application/json", |
15 | "Content-Type": "application/json", | 15 | "Content-Type": "application/json", |
16 | - 'User-Agent': 'Request for Express' | 16 | + 'Proxy-User-Agent': 'Request for Express' |
17 | } | 17 | } |
18 | }; | 18 | }; |
19 | } | 19 | } |
@@ -27,10 +27,19 @@ exports = module.exports = function (logger, rest, settings) { | @@ -27,10 +27,19 @@ exports = module.exports = function (logger, rest, settings) { | ||
27 | } | 27 | } |
28 | if (req.ip) { | 28 | if (req.ip) { |
29 | options.headers['Client-Ip'] = req.ip | 29 | options.headers['Client-Ip'] = req.ip |
30 | + } | ||
31 | + if (req.headers['x-request-id']) { | ||
32 | + options.headers['X-Request-Id'] = req.headers['x-request-id'] | ||
30 | } | 33 | } |
31 | return options; | 34 | return options; |
32 | } | 35 | } |
33 | 36 | ||
37 | + function addReqResOptions(options, req,res){ | ||
38 | + options['req']=req; | ||
39 | + options['res']=res; | ||
40 | + return options; | ||
41 | + } | ||
42 | + | ||
34 | function addParams(options, req) { | 43 | function addParams(options, req) { |
35 | var postData = !req.body ? '' : JSON.stringify(req.body || {}); | 44 | var postData = !req.body ? '' : JSON.stringify(req.body || {}); |
36 | // options.headers['Content-Length'] = postData.length; | 45 | // options.headers['Content-Length'] = postData.length; |
@@ -54,7 +63,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -54,7 +63,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
54 | var tempParam = param.split("=") | 63 | var tempParam = param.split("=") |
55 | tempParam[1] = urlencode.decode(tempParam[1], 'utf8'); | 64 | tempParam[1] = urlencode.decode(tempParam[1], 'utf8'); |
56 | tempParam[1] = tempParam[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | 65 | tempParam[1] = tempParam[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); |
57 | - console.log(tempParam[1]); | 66 | + logger.debug(tempParam[1]); |
58 | if (i < (params.length - 1)) { | 67 | if (i < (params.length - 1)) { |
59 | if (/[:&+/?%#=]/g.test(tempParam[1])) { | 68 | if (/[:&+/?%#=]/g.test(tempParam[1])) { |
60 | temp.push(tempParam[0] + "=" + encodeUrl(tempParam[1]) + "&"); | 69 | temp.push(tempParam[0] + "=" + encodeUrl(tempParam[1]) + "&"); |
@@ -100,13 +109,13 @@ exports = module.exports = function (logger, rest, settings) { | @@ -100,13 +109,13 @@ exports = module.exports = function (logger, rest, settings) { | ||
100 | if (settings.prefix && settings.prefix.length > 1) { | 109 | if (settings.prefix && settings.prefix.length > 1) { |
101 | fullUrl = fullUrl.substring(settings.prefix.length - 1); | 110 | fullUrl = fullUrl.substring(settings.prefix.length - 1); |
102 | } | 111 | } |
103 | - var url = fullUrl.substring(4); | 112 | + var url = fullUrl.substring(fullUrl.indexOf('/', 1)); |
104 | return url; | 113 | return url; |
105 | } | 114 | } |
106 | 115 | ||
107 | function searchService(services, name) { | 116 | function searchService(services, name) { |
108 | if (services[name]) { | 117 | if (services[name]) { |
109 | - console.log(services[name]); | 118 | + logger.debug(services[name]); |
110 | return false; | 119 | return false; |
111 | } else { | 120 | } else { |
112 | return true; | 121 | return true; |
@@ -145,9 +154,10 @@ exports = module.exports = function (logger, rest, settings) { | @@ -145,9 +154,10 @@ exports = module.exports = function (logger, rest, settings) { | ||
145 | var url = splitUrl(req.originalUrl); | 154 | var url = splitUrl(req.originalUrl); |
146 | var options = getOptions(url, 'GET'); | 155 | var options = getOptions(url, 'GET'); |
147 | addToken(options, req); | 156 | addToken(options, req); |
157 | + addReqResOptions(options, req,res); | ||
148 | function _success(data, response) { | 158 | function _success(data, response) { |
149 | if (response.statusCode >= 400 || !data) { | 159 | if (response.statusCode >= 400 || !data) { |
150 | - logger.error(options, data); | 160 | + logger.debug(options, data); |
151 | res.status(response.statusCode); | 161 | res.status(response.statusCode); |
152 | res.send(data); | 162 | res.send(data); |
153 | } else { | 163 | } else { |
@@ -155,7 +165,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -155,7 +165,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
155 | } | 165 | } |
156 | } | 166 | } |
157 | function _fail(err) { | 167 | function _fail(err) { |
158 | - logger.error(options, err); | 168 | + logger.debug(options, err); |
159 | res.send(err); | 169 | res.send(err); |
160 | } | 170 | } |
161 | rest.restClient(options, _success, _fail); | 171 | rest.restClient(options, _success, _fail); |
@@ -166,9 +176,10 @@ exports = module.exports = function (logger, rest, settings) { | @@ -166,9 +176,10 @@ exports = module.exports = function (logger, rest, settings) { | ||
166 | var options = getOptions(url, 'POST'); | 176 | var options = getOptions(url, 'POST'); |
167 | addToken(options, req); | 177 | addToken(options, req); |
168 | addParams(options, req); | 178 | addParams(options, req); |
179 | + addReqResOptions(options, req,res); | ||
169 | function _success(data, response) { | 180 | function _success(data, response) { |
170 | if (response.statusCode >= 400) { | 181 | if (response.statusCode >= 400) { |
171 | - logger.error(options, data); | 182 | + logger.debug(options, data); |
172 | res.status(response.statusCode); | 183 | res.status(response.statusCode); |
173 | res.send(data); | 184 | res.send(data); |
174 | } else if (!data || 'null' == data || "null\n" == data || '{}' == data) { | 185 | } else if (!data || 'null' == data || "null\n" == data || '{}' == data) { |
@@ -181,7 +192,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -181,7 +192,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
181 | } | 192 | } |
182 | } | 193 | } |
183 | function _fail(err) { | 194 | function _fail(err) { |
184 | - logger.error(options, err); | 195 | + logger.debug(options, err); |
185 | res.send(err); | 196 | res.send(err); |
186 | } | 197 | } |
187 | rest.restClient(options, _success, _fail); | 198 | rest.restClient(options, _success, _fail); |
@@ -192,9 +203,10 @@ exports = module.exports = function (logger, rest, settings) { | @@ -192,9 +203,10 @@ exports = module.exports = function (logger, rest, settings) { | ||
192 | var options = getOptions(url, 'PUT'); | 203 | var options = getOptions(url, 'PUT'); |
193 | addToken(options, req); | 204 | addToken(options, req); |
194 | addParams(options, req); | 205 | addParams(options, req); |
206 | + addReqResOptions(options, req,res); | ||
195 | function _success(data, response) { | 207 | function _success(data, response) { |
196 | if (response.statusCode >= 400) { | 208 | if (response.statusCode >= 400) { |
197 | - logger.error(options, data); | 209 | + logger.debug(options, data); |
198 | res.status(response.statusCode); | 210 | res.status(response.statusCode); |
199 | res.send(data); | 211 | res.send(data); |
200 | } else if (!data || 'null' == data || "null\n" == data || '{}' == data) { | 212 | } else if (!data || 'null' == data || "null\n" == data || '{}' == data) { |
@@ -207,7 +219,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -207,7 +219,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
207 | } | 219 | } |
208 | } | 220 | } |
209 | function _fail(err) { | 221 | function _fail(err) { |
210 | - logger.error(options, err); | 222 | + logger.debug(options, err); |
211 | res.send(err); | 223 | res.send(err); |
212 | } | 224 | } |
213 | rest.restClient(options, _success, _fail); | 225 | rest.restClient(options, _success, _fail); |
@@ -218,9 +230,10 @@ exports = module.exports = function (logger, rest, settings) { | @@ -218,9 +230,10 @@ exports = module.exports = function (logger, rest, settings) { | ||
218 | var options = getOptions(url, 'PATCH'); | 230 | var options = getOptions(url, 'PATCH'); |
219 | addToken(options, req); | 231 | addToken(options, req); |
220 | addParams(options, req); | 232 | addParams(options, req); |
233 | + addReqResOptions(options, req,res); | ||
221 | function _success(data, response) { | 234 | function _success(data, response) { |
222 | if (response.statusCode >= 400) { | 235 | if (response.statusCode >= 400) { |
223 | - logger.error(options, data); | 236 | + logger.debug(options, data); |
224 | res.send(data); | 237 | res.send(data); |
225 | } else if (!data) { | 238 | } else if (!data) { |
226 | res.send({ | 239 | res.send({ |
@@ -232,7 +245,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -232,7 +245,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
232 | } | 245 | } |
233 | } | 246 | } |
234 | function _fail(err) { | 247 | function _fail(err) { |
235 | - logger.error(options, err); | 248 | + logger.debug(options, err); |
236 | res.send(err); | 249 | res.send(err); |
237 | } | 250 | } |
238 | rest.restClient(options, _success, _fail); | 251 | rest.restClient(options, _success, _fail); |
@@ -243,9 +256,10 @@ exports = module.exports = function (logger, rest, settings) { | @@ -243,9 +256,10 @@ exports = module.exports = function (logger, rest, settings) { | ||
243 | var options = getOptions(url, 'HEAD'); | 256 | var options = getOptions(url, 'HEAD'); |
244 | addToken(options, req); | 257 | addToken(options, req); |
245 | addParams(options, req); | 258 | addParams(options, req); |
259 | + addReqResOptions(options, req,res); | ||
246 | function _success(data, response) { | 260 | function _success(data, response) { |
247 | if (response.statusCode >= 400) { | 261 | if (response.statusCode >= 400) { |
248 | - logger.error(options, data); | 262 | + logger.debug(options, data); |
249 | res.send(data); | 263 | res.send(data); |
250 | } else if (!data) { | 264 | } else if (!data) { |
251 | res.send({ | 265 | res.send({ |
@@ -257,7 +271,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -257,7 +271,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
257 | } | 271 | } |
258 | } | 272 | } |
259 | function _fail(err) { | 273 | function _fail(err) { |
260 | - logger.error(options, err); | 274 | + logger.debug(options, err); |
261 | res.send(err); | 275 | res.send(err); |
262 | } | 276 | } |
263 | rest.restClient(options, _success, _fail); | 277 | rest.restClient(options, _success, _fail); |
@@ -269,9 +283,10 @@ exports = module.exports = function (logger, rest, settings) { | @@ -269,9 +283,10 @@ exports = module.exports = function (logger, rest, settings) { | ||
269 | addToken(options, req); | 283 | addToken(options, req); |
270 | addParams(options, req); | 284 | addParams(options, req); |
271 | addContentLength(options); | 285 | addContentLength(options); |
286 | + addReqResOptions(options, req,res); | ||
272 | function _success(data, response) { | 287 | function _success(data, response) { |
273 | if (response.statusCode >= 400) { | 288 | if (response.statusCode >= 400) { |
274 | - logger.error(options, data); | 289 | + logger.debug(options, data); |
275 | res.status(response.statusCode); | 290 | res.status(response.statusCode); |
276 | res.send(data); | 291 | res.send(data); |
277 | } else if (!data || (data && !data.message)) { | 292 | } else if (!data || (data && !data.message)) { |
@@ -285,7 +300,7 @@ exports = module.exports = function (logger, rest, settings) { | @@ -285,7 +300,7 @@ exports = module.exports = function (logger, rest, settings) { | ||
285 | } | 300 | } |
286 | } | 301 | } |
287 | function _fail(err) { | 302 | function _fail(err) { |
288 | - logger.error(options, err); | 303 | + logger.debug(options, err); |
289 | res.send(err); | 304 | res.send(err); |
290 | } | 305 | } |
291 | rest.restClient(options, _success, _fail); | 306 | rest.restClient(options, _success, _fail); |
1 | -const passport = require("passport"); | ||
2 | -const urlencode = require("urlencode"); | ||
3 | -const async = require("async"); | ||
4 | -const crypto = require("crypto"); | ||
5 | -const fs =require('fs') | ||
6 | -const path = require("path"); | ||
7 | - | ||
8 | -exports = module.exports = function (logger, rest, settings) { | ||
9 | - function index(req, res, next) { | ||
10 | - logger.info(req); | ||
11 | - // res.redirect("https://www.baidu.com"); | ||
12 | - } | ||
13 | - | ||
14 | - function getImg(req, res, next) { | ||
15 | - logger.info(req.url, "1231231231"); | ||
16 | - const parentdir = path.resolve(__dirname, "..") | ||
17 | - const paths = parentdir+'/build/public'+urlencode.decode(req.url, 'utf8') | ||
18 | - fs.readFile(paths,function(err,data){ | ||
19 | - console.log(err,data) | ||
20 | - if (err) { | ||
21 | - res.send('读取错误') | ||
22 | - } else { | ||
23 | - res.send(data) | ||
24 | - } | ||
25 | - }) | ||
26 | - } | ||
27 | - | ||
28 | - function indexPrefix(req, res) { | ||
29 | - // logger.info(req.csrfToken(),'req.cssadasdas'); | ||
30 | - res.send({data:req.csrfToken()}) | ||
31 | - // if (req.csrfToken) { | ||
32 | - // if (settings.prefix && settings.prefix.length > 1) { | ||
33 | - // res.redirect(settings.prefix.substring(0, settings.prefix.length - 1)); | ||
34 | - // } else { | ||
35 | - // res.render("index", { csrfToken: req.csrfToken() }); | ||
36 | - // } | ||
37 | - // } else res.render("index", { csrfToken: "" }); | ||
38 | - } | ||
39 | - | ||
40 | - function productDes(req, res, next) { | ||
41 | - if (req.csrfToken) | ||
42 | - res.render("chat/new-chat", { csrfToken: req.csrfToken() }); | ||
43 | - else res.render("chat/new-chat", { csrfToken: "" }); | ||
44 | - } | ||
45 | - | ||
46 | - function recharge(req, res) { | ||
47 | - var params = JSON.parse(urlencode.decode(req.query.params)); | ||
48 | - console.log(params); | ||
49 | - if (req.csrfToken) | ||
50 | - res.render("recharge", { recharge: params, csrfToken: req.csrfToken() }); | ||
51 | - else res.render("recharge", { recharge: params, csrfToken: "" }); | ||
52 | - } | ||
53 | - | ||
54 | - function register(req, res, next) { | ||
55 | - if (req.csrfToken) | ||
56 | - res.render("newRegister", { csrfToken: req.csrfToken() }); | ||
57 | - else res.render("newRegister", { csrfToken: "" }); | ||
58 | - } | ||
59 | - | ||
60 | - function mobileRegister(req, res) { | ||
61 | - if (req.csrfToken) | ||
62 | - res.render("registerMobile", { csrfToken: req.csrfToken() }); | ||
63 | - else res.render("registerMobile", { csrfToken: "" }); | ||
64 | - } | ||
65 | - | ||
66 | - function mobileRegisterSuccess(req, res) { | ||
67 | - if (req.csrfToken) | ||
68 | - res.render("registerMobileSuccess", { csrfToken: req.csrfToken() }); | ||
69 | - else res.render("registerMobileSuccess", { csrfToken: "" }); | ||
70 | - } | ||
71 | - | ||
72 | - function signIn(req, res, next) { | ||
73 | - // console.log(req); | ||
74 | - if (req.csrfToken) res.render("newLogin", { csrfToken: req.csrfToken() }); | ||
75 | - else res.render("newLogin", { csrfToken: "" }); | ||
76 | - } | ||
77 | - | ||
78 | - function doLogin(req, res, next) { | ||
79 | - passport.authenticate("local", function (err, user, info) { | ||
80 | - console.log("doLogin:", err, user, info); | ||
81 | - if (err) { | ||
82 | - return next(err); | ||
83 | - } | ||
84 | - if (!user) { | ||
85 | - return res.send(info); | ||
86 | - } | ||
87 | - req.logIn(user, function (err) { | ||
88 | - if (err) { | ||
89 | - return next(err); | ||
90 | - } | ||
91 | - return res.send({ | ||
92 | - ok: "登录成功", | ||
93 | - user_info: req.session.passport.user.user_info, | ||
94 | - }); | ||
95 | - }); | ||
96 | - })(req, res, next); | ||
97 | - } | ||
98 | - | ||
99 | - function signOut(req, res, next) { | ||
100 | - if ( | ||
101 | - req.session.passport && | ||
102 | - req.session.passport.user && | ||
103 | - req.session.passport.user.user_info && | ||
104 | - req.session.passport.user.user_info.user | ||
105 | - ) | ||
106 | - logger.info( | ||
107 | - req.session.passport.user.user_info.user, | ||
108 | - "You have successfully logged out" | ||
109 | - ); | ||
110 | - req.logout(); | ||
111 | - req.flash("success", "You have successfully logged out"); | ||
112 | - res.redirect("/"); | ||
113 | - } | ||
114 | - | ||
115 | - function smsCodes(req, res, next) { | ||
116 | - rest.postJson({ | ||
117 | - baseUrl: "url", | ||
118 | - url: "auth/smscodes", | ||
119 | - params: req.body, | ||
120 | - callback: _cb, | ||
121 | - req: req, | ||
122 | - res: res, | ||
123 | - options: {}, | ||
124 | - excludeToken: true, | ||
125 | - }); | ||
126 | - function _cb(data, response) { | ||
127 | - logger.info("back data:", data); | ||
128 | - if (response.statusCode < 300) { | ||
129 | - res.send({ code: 200, message: "发送成功" }); | ||
130 | - } else { | ||
131 | - res.send(data); | ||
132 | - } | ||
133 | - } | ||
134 | - } | ||
135 | - | ||
136 | - function tenants(req, res, next) { | ||
137 | - rest.register({ | ||
138 | - baseUrl: "url", | ||
139 | - url: "tenants", | ||
140 | - params: req.body, | ||
141 | - callback: _cb, | ||
142 | - req: req, | ||
143 | - res: res, | ||
144 | - options: {}, | ||
145 | - excludeToken: true, | ||
146 | - }); | ||
147 | - function _cb(data, response) { | ||
148 | - logger.info("back data:", data); | ||
149 | - res.send(data); | ||
150 | - } | ||
151 | - } | ||
152 | - | ||
153 | - function resetPass(req, res) { | ||
154 | - rest.putJson({ | ||
155 | - baseUrl: "url", | ||
156 | - url: "auth/user", | ||
157 | - params: { | ||
158 | - user: req.body.user, | ||
159 | - password: req.body.password, | ||
160 | - again_password: req.body.again_password, | ||
161 | - }, | ||
162 | - callback: _cb, | ||
163 | - req: req, | ||
164 | - res: res, | ||
165 | - options: {}, | ||
166 | - }); | ||
167 | - function _cb(data, response) { | ||
168 | - logger.info("back data:", data); | ||
169 | - res.send(data); | ||
170 | - } | ||
171 | - } | ||
172 | - | ||
173 | - function updatePassword(req, res) { | ||
174 | - rest.patchJson({ | ||
175 | - baseUrl: "url", | ||
176 | - url: "users/" + req.body.userId, | ||
177 | - params: { | ||
178 | - password: req.body.password, | ||
179 | - }, | ||
180 | - callback: _cb, | ||
181 | - req: req, | ||
182 | - res: res, | ||
183 | - options: {}, | ||
184 | - }); | ||
185 | - function _cb(data, response) { | ||
186 | - logger.info("back data:", data); | ||
187 | - res.send(data); | ||
188 | - } | ||
189 | - } | ||
190 | - | ||
191 | - function loadUserInfo(req, res) { | ||
192 | - settings; | ||
193 | - if (req.session.passport.user && req.session.passport.user.user_info) { | ||
194 | - res.send({ | ||
195 | - user_info: req.session.passport.user.user_info, | ||
196 | - prefix: settings.prefix, | ||
197 | - }); | ||
198 | - } else { | ||
199 | - res.send({ user_info: null, prefix: settings.prefix }); | ||
200 | - } | ||
201 | - } | ||
202 | - | ||
203 | - function getUploaderToken(req, res) { | ||
204 | - rest.postJson({ | ||
205 | - baseUrl: "ossUrl", | ||
206 | - url: "inits", | ||
207 | - params: req.body, | ||
208 | - callback: _cb, | ||
209 | - req: req, | ||
210 | - res: res, | ||
211 | - options: {}, | ||
212 | - }); | ||
213 | - function _cb(data, response) { | ||
214 | - logger.info("back data:", data); | ||
215 | - res.send(data); | ||
216 | - } | ||
217 | - } | ||
218 | - | ||
219 | - function getObjectTokenByID(req, res) { | ||
220 | - rest.get({ | ||
221 | - baseUrl: "ossUrl", | ||
222 | - url: "objects/" + req.body.file_id, | ||
223 | - params: {}, | ||
224 | - callback: _cb, | ||
225 | - req: req, | ||
226 | - res: res, | ||
227 | - options: {}, | ||
228 | - }); | ||
229 | - function _cb(data, response) { | ||
230 | - logger.info("back data:", data); | ||
231 | - res.send(data); | ||
232 | - } | ||
233 | - } | ||
234 | - | ||
235 | - function delOSSObject(req, res) { | ||
236 | - rest.del({ | ||
237 | - baseUrl: "ossUrl", | ||
238 | - url: | ||
239 | - "s3objects/" + | ||
240 | - req.body.request_id + | ||
241 | - "?bucket=" + | ||
242 | - req.body.bucket + | ||
243 | - "&file=" + | ||
244 | - req.body.name, | ||
245 | - params: {}, | ||
246 | - callback: _cb, | ||
247 | - req: req, | ||
248 | - res: res, | ||
249 | - options: {}, | ||
250 | - }); | ||
251 | - function _cb(data, response) { | ||
252 | - logger.info("back data:", data); | ||
253 | - console.log(response.statusCode); | ||
254 | - if (response.statusCode < 300) { | ||
255 | - res.send({ delete: "ok" }); | ||
256 | - } | ||
257 | - } | ||
258 | - } | ||
259 | - | ||
260 | - function smsVerification(req, res) { | ||
261 | - rest.postJson({ | ||
262 | - baseUrl: "url", | ||
263 | - url: "auth/sms_verification", | ||
264 | - params: req.body, | ||
265 | - callback: _cb, | ||
266 | - req: req, | ||
267 | - res: res, | ||
268 | - options: {}, | ||
269 | - excludeToken: true, | ||
270 | - }); | ||
271 | - function _cb(data, response) { | ||
272 | - logger.info("back data:", data); | ||
273 | - if (response.statusCode < 300) { | ||
274 | - res.send({ code: 200, message: "发送成功" }); | ||
275 | - } else { | ||
276 | - res.send({ | ||
277 | - code: response.statusCode, | ||
278 | - message: data.message, | ||
279 | - errors: data.errors, | ||
280 | - }); | ||
281 | - } | ||
282 | - } | ||
283 | - } | ||
284 | - | ||
285 | - function healthMonitor(res) { | ||
286 | - res.statusCode = 200; | ||
287 | - return res.send("status ok"); | ||
288 | - } | ||
289 | - | ||
290 | - function updateUserRoles(req, res) { | ||
291 | - rest.putJson({ | ||
292 | - baseUrl: "url", | ||
293 | - url: "user_roles/" + req.body.user_id, | ||
294 | - params: req.body.roles, | ||
295 | - callback: _cb, | ||
296 | - req: req, | ||
297 | - res: res, | ||
298 | - options: {}, | ||
299 | - }); | ||
300 | - function _cb(data, response) { | ||
301 | - logger.info("back data:", data); | ||
302 | - if (response.statusCode < 300) { | ||
303 | - res.send({ back: "ok" }); | ||
304 | - } else { | ||
305 | - res.send(data); | ||
306 | - } | ||
307 | - } | ||
308 | - } | ||
309 | - | ||
310 | - function getRoles(req, res) { | ||
311 | - rest.get({ | ||
312 | - baseUrl: "url", | ||
313 | - url: "roles", | ||
314 | - params: {}, | ||
315 | - callback: _cb, | ||
316 | - req: req, | ||
317 | - res: res, | ||
318 | - options: {}, | ||
319 | - }); | ||
320 | - function _cb(data, response) { | ||
321 | - logger.info("back data:", data); | ||
322 | - res.send(data); | ||
323 | - } | ||
324 | - } | ||
325 | - | ||
326 | - function getUserRoles(req, res) { | ||
327 | - rest.get({ | ||
328 | - baseUrl: "url", | ||
329 | - url: | ||
330 | - "user_roles?user=" + | ||
331 | - urlencode(req.body.user) + | ||
332 | - "&limit=" + | ||
333 | - req.body.limit + | ||
334 | - "&offset=" + | ||
335 | - req.body.offset, | ||
336 | - params: {}, | ||
337 | - callback: _cb, | ||
338 | - req: req, | ||
339 | - res: res, | ||
340 | - options: {}, | ||
341 | - }); | ||
342 | - function _cb(data, response) { | ||
343 | - logger.info("back data:", data); | ||
344 | - res.send(data); | ||
345 | - } | ||
346 | - } | ||
347 | - | ||
348 | - function getTenant(req, res) { | ||
349 | - rest.get({ | ||
350 | - baseUrl: "url", | ||
351 | - url: "tenants/" + req.body.tenant_id, | ||
352 | - params: {}, | ||
353 | - callback: _cb, | ||
354 | - req: req, | ||
355 | - res: res, | ||
356 | - options: {}, | ||
357 | - }); | ||
358 | - function _cb(data, response) { | ||
359 | - logger.info("back data:", data); | ||
360 | - res.send(data); | ||
361 | - } | ||
362 | - } | ||
363 | - | ||
364 | - function updateTenant(req, res) { | ||
365 | - rest.putJson({ | ||
366 | - baseUrl: "url", | ||
367 | - url: "tenants/" + req.body.tenant_id, | ||
368 | - params: req.body.tenant, | ||
369 | - callback: _cb, | ||
370 | - req: req, | ||
371 | - res: res, | ||
372 | - options: {}, | ||
373 | - }); | ||
374 | - function _cb(data, response) { | ||
375 | - logger.info("back data:", data); | ||
376 | - res.send(data); | ||
377 | - } | ||
378 | - } | ||
379 | - | ||
380 | - function offer(req, res) { | ||
381 | - rest.get({ | ||
382 | - baseUrl: "hrUrl", | ||
383 | - url: | ||
384 | - "offers/" + req.params.requestId + "?tenant_id=" + req.query.tenant_id, | ||
385 | - params: {}, | ||
386 | - callback: _cb, | ||
387 | - req: req, | ||
388 | - res: res, | ||
389 | - options: {}, | ||
390 | - excludeToken: true, | ||
391 | - }); | ||
392 | - function _cb(data, response) { | ||
393 | - logger.info("back data:", data); | ||
394 | - //res.send(data); | ||
395 | - console.log(data); | ||
396 | - data["offerId"] = req.params.requestId; | ||
397 | - data["tenantId"] = req.query.tenant_id; | ||
398 | - res.render("offer", data); | ||
399 | - } | ||
400 | - } | ||
401 | - | ||
402 | - function onboardStatus(req, res) { | ||
403 | - rest.get({ | ||
404 | - baseUrl: "hrUrl", | ||
405 | - url: "onboard-status", | ||
406 | - params: {}, | ||
407 | - callback: _cb, | ||
408 | - req: req, | ||
409 | - res: res, | ||
410 | - options: {}, | ||
411 | - useUrl: true, | ||
412 | - }); | ||
413 | - function _cb(data, response) { | ||
414 | - logger.info("back data:", data); | ||
415 | - res.send(data); | ||
416 | - } | ||
417 | - } | ||
418 | - | ||
419 | - function dowloadApp(req, res) { | ||
420 | - var mobileAgent = req.headers["user-agent"].toLowerCase(); | ||
421 | - var agent = { | ||
422 | - android: | ||
423 | - mobileAgent.indexOf("android") > -1 || mobileAgent.indexOf("Adr") > -1, | ||
424 | - iPhone: mobileAgent.indexOf("iphone") > -1, | ||
425 | - iPad: mobileAgent.indexOf("ipad") > -1, | ||
426 | - }; | ||
427 | - if (agent.iPhone || agent.iPad) { | ||
428 | - res.redirect( | ||
429 | - 301, | ||
430 | - "https://itunes.apple.com/cn/app/%E8%96%AA%E5%91%97/id1140779439?l=en&mt=8" | ||
431 | - ); | ||
432 | - } else if (agent.android) { | ||
433 | - res.redirect( | ||
434 | - 301, | ||
435 | - "http://krhrimg.oss-cn-beijing.aliyuncs.com/appdownload/production/android/krhr-android.apk" | ||
436 | - ); | ||
437 | - } else { | ||
438 | - res.redirect( | ||
439 | - 301, | ||
440 | - "http://krhrimg.oss-cn-beijing.aliyuncs.com/appdownload/production/android/krhr-android.apk" | ||
441 | - ); | ||
442 | - } | ||
443 | - } | ||
444 | - | ||
445 | - function softwareLicense(res) { | ||
446 | - res.render("softwareLicense"); | ||
447 | - } | ||
448 | - | ||
449 | - function changePassForRegister(req, res) { | ||
450 | - var options = { | ||
451 | - baseUrl: "url", | ||
452 | - url: "users/" + req.body.user_id, | ||
453 | - params: { | ||
454 | - password: req.body.password, | ||
455 | - }, | ||
456 | - callback: _cb, | ||
457 | - req: req, | ||
458 | - res: res, | ||
459 | - options: {}, | ||
460 | - }; | ||
461 | - if (req.body.access_token) { | ||
462 | - console.log("@@@!!!!!!!!!!!!!!!!"); | ||
463 | - options.options = { | ||
464 | - accessToken: req.body.access_token, | ||
465 | - }; | ||
466 | - options["excludeToken"] = true; | ||
467 | - } | ||
468 | - rest.patchJson(options); | ||
469 | - function _cb(data, response) { | ||
470 | - logger.info("back data:", data); | ||
471 | - res.send(data); | ||
472 | - } | ||
473 | - } | ||
474 | - | ||
475 | - function changeTenant(req, res) { | ||
476 | - var params = { | ||
477 | - grant_type: "refresh_token", | ||
478 | - scope: "global_access:tenant_admin,tenant:" + req.body.id, | ||
479 | - refresh_token: req.session.passport.user.refreshToken, | ||
480 | - }; | ||
481 | - req.session.passport.user.token = ""; | ||
482 | - rest.postJson({ | ||
483 | - baseUrl: "url", | ||
484 | - url: | ||
485 | - settings.restful.url + | ||
486 | - "uaa" + | ||
487 | - settings.restful.version + | ||
488 | - "/auth/tokens", | ||
489 | - useUrl: true, | ||
490 | - params: params, | ||
491 | - callback: _cb, | ||
492 | - req: req, | ||
493 | - res: res, | ||
494 | - options: {}, | ||
495 | - excludeToken: true, | ||
496 | - }); | ||
497 | - function _cb(data, response) { | ||
498 | - console.log(data); | ||
499 | - logger.info("back data:", data); | ||
500 | - if (response.statusCode < 300) { | ||
501 | - req.session.passport.user.token = data.access_token; | ||
502 | - req.session.passport.user.refreshToken = data.refresh_token; | ||
503 | - req.session.passport.user.user_info = { | ||
504 | - user: data.user, | ||
505 | - perms: [], | ||
506 | - tenant: data.tenant, | ||
507 | - scope: data.scope, | ||
508 | - oss: req.session.passport.user.user_info.oss, | ||
509 | - }; | ||
510 | - req.session.save(function () { | ||
511 | - rest.get({ | ||
512 | - baseUrl: "url", | ||
513 | - url: | ||
514 | - settings.restful.url + | ||
515 | - "uaa" + | ||
516 | - settings.restful.version + | ||
517 | - "/perms/detail", | ||
518 | - useUrl: true, | ||
519 | - params: {}, | ||
520 | - callback: _scb, | ||
521 | - req: req, | ||
522 | - res: res, | ||
523 | - options: {}, | ||
524 | - }); | ||
525 | - }); | ||
526 | - } else { | ||
527 | - res.send({ | ||
528 | - code: response.statusCode, | ||
529 | - message: data.message, | ||
530 | - initialize_done: "n", | ||
531 | - }); | ||
532 | - } | ||
533 | - } | ||
534 | - function _scb(data1, response) { | ||
535 | - if (response.statusCode < 300 && data1.items) { | ||
536 | - req.session.passport.user.user_info.perms = data1.items; | ||
537 | - req.session.save(function () { | ||
538 | - // res.send({"code":200,"message":"切换租户成功"}); | ||
539 | - rest.get({ | ||
540 | - baseUrl: "url", | ||
541 | - url: | ||
542 | - settings.restful.url + | ||
543 | - "filemeta" + | ||
544 | - settings.restful.version + | ||
545 | - "/config", | ||
546 | - useUrl: true, | ||
547 | - params: {}, | ||
548 | - callback: _scb1, | ||
549 | - req: req, | ||
550 | - res: res, | ||
551 | - options: {}, | ||
552 | - }); | ||
553 | - }); | ||
554 | - } else { | ||
555 | - res.send({ code: response.statusCode, message: data1.message }); | ||
556 | - } | ||
557 | - } | ||
558 | - function _scb1(data2, response) { | ||
559 | - if (response.statusCode < 300 && data2 && data2.bucket) { | ||
560 | - req.session.passport.user.user_info.oss = data2; | ||
561 | - req.session.save(function () { | ||
562 | - res.send({ code: 200, message: "切换租户成功" }); | ||
563 | - }); | ||
564 | - } else { | ||
565 | - res.send({ code: 200, message: "切换租户失败" }); | ||
566 | - } | ||
567 | - } | ||
568 | - } | ||
569 | - | ||
570 | - function sendRejectOffer(req, res) { | ||
571 | - rest.get({ | ||
572 | - baseUrl: "hrUrl", | ||
573 | - url: req.body.url, //传一个参数 | ||
574 | - params: {}, | ||
575 | - callback: _cb, | ||
576 | - req: req, | ||
577 | - res: res, | ||
578 | - options: {}, | ||
579 | - excludeToken: true, | ||
580 | - useUrl: true, | ||
581 | - }); | ||
582 | - function _cb(data, response) { | ||
583 | - logger.info("back data:", data); | ||
584 | - if (response.statusCode < 300) { | ||
585 | - res.send({ action: "ok" }); | ||
586 | - } else { | ||
587 | - res.send(data); | ||
588 | - } | ||
589 | - } | ||
590 | - } | ||
591 | - | ||
592 | - function acceptOffer(req, res) { | ||
593 | - rest.get({ | ||
594 | - baseUrl: "hrUrl", | ||
595 | - url: req.body.url, //传一个参数 | ||
596 | - params: {}, | ||
597 | - callback: _cb, | ||
598 | - req: req, | ||
599 | - res: res, | ||
600 | - options: {}, | ||
601 | - excludeToken: true, | ||
602 | - useUrl: true, | ||
603 | - }); | ||
604 | - function _cb(data, response) { | ||
605 | - logger.info("back data:", data); | ||
606 | - if (response.statusCode < 300) { | ||
607 | - res.send({ action: "ok" }); | ||
608 | - } else { | ||
609 | - res.send(data); | ||
610 | - } | ||
611 | - } | ||
612 | - } | ||
613 | - | ||
614 | - function imTokens(req, res) { | ||
615 | - rest.post({ | ||
616 | - url: "auth/im_tokens", | ||
617 | - params: req.body, | ||
618 | - callback: _cb, | ||
619 | - req: req, | ||
620 | - res: res, | ||
621 | - options: {}, | ||
622 | - }); | ||
623 | - function _cb(data, response) { | ||
624 | - logger.info("back data:", data); | ||
625 | - res.send(data); | ||
626 | - } | ||
627 | - } | ||
628 | - | ||
629 | - function listChannels(req, res) { | ||
630 | - rest.get({ | ||
631 | - baseUrl: "chatUrl", | ||
632 | - url: "channels?page_size=10&page=0&status=active", | ||
633 | - params: req.body, | ||
634 | - callback: _cb, | ||
635 | - req: req, | ||
636 | - res: res, | ||
637 | - options: {}, | ||
638 | - }); | ||
639 | - function _cb(data, response) { | ||
640 | - logger.info("back data:", data); | ||
641 | - res.send(data); | ||
642 | - } | ||
643 | - } | ||
644 | - | ||
645 | - function filemeta(req, res) { | ||
646 | - var fullPath = | ||
647 | - settings.restful.url + | ||
648 | - "filemeta" + | ||
649 | - settings.restful.version + | ||
650 | - "/object-redirect"; | ||
651 | - fullPath = | ||
652 | - fullPath + | ||
653 | - "?" + | ||
654 | - "bucket=" + | ||
655 | - req.query.bucket + | ||
656 | - "&object=" + | ||
657 | - encodeURIComponent(req.query.object); | ||
658 | - console.info("fullPath::::::", fullPath); | ||
659 | - var options = { | ||
660 | - service_catalog: "", | ||
661 | - url: fullPath, | ||
662 | - useUrl: true, | ||
663 | - params: req.body, | ||
664 | - callback: _cb, | ||
665 | - req: req, | ||
666 | - res: res, | ||
667 | - options: {}, | ||
668 | - }; | ||
669 | - rest.get(options); | ||
670 | - function _cb(data, response) { | ||
671 | - if (data && data.download_url) { | ||
672 | - if (req.query.type && "json" == req.query.type) { | ||
673 | - res.send(data); | ||
674 | - } else { | ||
675 | - var url = data.download_url; | ||
676 | - let path = url.split("?")[0]; | ||
677 | - let pathArray = path.split("/"); | ||
678 | - let result = []; | ||
679 | - for (var i = 0; i < pathArray.length; i++) { | ||
680 | - if (i == pathArray.length - 1) { | ||
681 | - result.push(encodeURIComponent(pathArray[i])); | ||
682 | - } else { | ||
683 | - result.push(pathArray[i]); | ||
684 | - } | ||
685 | - } | ||
686 | - let result1 = result.join("/"); | ||
687 | - if (url.indexOf("?") !== -1) { | ||
688 | - result1 += "?" + url.split("?")[1]; | ||
689 | - } | ||
690 | - if (req.query.result_callback) { | ||
691 | - res.send(data); | ||
692 | - } else { | ||
693 | - res.redirect(301, result1); | ||
694 | - } | ||
695 | - } | ||
696 | - } else { | ||
697 | - res.send(data); | ||
698 | - } | ||
699 | - } | ||
700 | - } | ||
701 | - | ||
702 | - function getCustomerQrcode(req, res) { | ||
703 | - var fullPath = | ||
704 | - settings.restful.url + | ||
705 | - "crm" + | ||
706 | - settings.restful.version + | ||
707 | - "/customers/" + | ||
708 | - req.query.id + | ||
709 | - "/qrcode"; | ||
710 | - var options = { | ||
711 | - service_catalog: "", | ||
712 | - url: fullPath, | ||
713 | - useUrl: true, | ||
714 | - params: req.body, | ||
715 | - callback: _cb, | ||
716 | - req: req, | ||
717 | - res: res, | ||
718 | - options: {}, | ||
719 | - }; | ||
720 | - rest.get(options); | ||
721 | - function _cb(data, response) { | ||
722 | - if (data && data.url_path) { | ||
723 | - res.redirect(301, data.url_path); | ||
724 | - } else { | ||
725 | - res.send(data); | ||
726 | - } | ||
727 | - } | ||
728 | - } | ||
729 | - | ||
730 | - function getPositionQrcode(req, res) { | ||
731 | - var fullPath = | ||
732 | - settings.restful.url + | ||
733 | - "recruit" + | ||
734 | - settings.restful.version + | ||
735 | - "/positions/" + | ||
736 | - req.query.id + | ||
737 | - "/qrcode"; | ||
738 | - var options = { | ||
739 | - service_catalog: "", | ||
740 | - url: fullPath, | ||
741 | - useUrl: true, | ||
742 | - params: req.body, | ||
743 | - callback: _cb, | ||
744 | - req: req, | ||
745 | - res: res, | ||
746 | - options: {}, | ||
747 | - }; | ||
748 | - rest.get(options); | ||
749 | - function _cb(data, response) { | ||
750 | - if (data && data.url_path) { | ||
751 | - res.redirect(301, data.url_path); | ||
752 | - } else { | ||
753 | - res.send(data); | ||
754 | - } | ||
755 | - } | ||
756 | - } | ||
757 | - | ||
758 | - function getOSSConfig(req, res) { | ||
759 | - var fullPath = | ||
760 | - settings.restful.url + "filemeta" + settings.restful.version + "/config"; | ||
761 | - var options = { | ||
762 | - service_catalog: "", | ||
763 | - url: fullPath, | ||
764 | - useUrl: true, | ||
765 | - params: req.body, | ||
766 | - callback: _cb, | ||
767 | - req: req, | ||
768 | - res: res, | ||
769 | - options: {}, | ||
770 | - }; | ||
771 | - rest.get(options); | ||
772 | - function _cb(data, response) { | ||
773 | - if (data && data.bucket) { | ||
774 | - req.session.passport.user.user_info.oss = data; | ||
775 | - req.session.save(function () { | ||
776 | - res.send({ code: 200, message: "oss配置加载成功" }); | ||
777 | - }); | ||
778 | - } else { | ||
779 | - res.send({ code: 200, message: "oss配置加载失败" }); | ||
780 | - } | ||
781 | - } | ||
782 | - } | ||
783 | - | ||
784 | - function weidianTempLate(req, res) { | ||
785 | - const { params } = req; | ||
786 | - var fullPath = | ||
787 | - settings.restful.url + "socialwork/internal/minishop/" + params.id; | ||
788 | - var options = { | ||
789 | - service_catalog: "", | ||
790 | - url: fullPath, | ||
791 | - useUrl: true, | ||
792 | - params: req.body, | ||
793 | - callback: _cb, | ||
794 | - req: req, | ||
795 | - res: res, | ||
796 | - options: {}, | ||
797 | - excludeToken: true, | ||
798 | - }; | ||
799 | - rest.get(options); | ||
800 | - function _cb(data, response) { | ||
801 | - logger.info("back data:", data); | ||
802 | - if (response.statusCode < 300) { | ||
803 | - const { shop_logo = [], shop_name = "", shop_comment = "" } = data; | ||
804 | - let imgUrl = ""; | ||
805 | - if (shop_logo.length > 0) { | ||
806 | - imgUrl = "http://oss.workai.com.cn/public/" + shop_logo[0].object; | ||
807 | - } | ||
808 | - res.render("template/weiDian", { | ||
809 | - imgUrl: imgUrl, | ||
810 | - shop_name: shop_name, | ||
811 | - shop_comment: shop_comment, | ||
812 | - }); | ||
813 | - } else { | ||
814 | - res.render("template/weiDian"); | ||
815 | - } | ||
816 | - } | ||
817 | - } | ||
818 | - | ||
819 | - function workaiSecurityOAuth(req, res) { | ||
820 | - var params = req.query; | ||
821 | - if (params.authorization_code) { | ||
822 | - var passport = { | ||
823 | - user: { | ||
824 | - refreshToken: "", | ||
825 | - token: "", | ||
826 | - service_catalog: {}, | ||
827 | - user_info: {}, | ||
828 | - err: null, | ||
829 | - }, | ||
830 | - }; | ||
831 | - async.waterfall( | ||
832 | - [ | ||
833 | - function (callback) { | ||
834 | - //第三方登录 | ||
835 | - var tempParams = { | ||
836 | - grant_type: "authorization_code_v1", | ||
837 | - code: params.authorization_code, | ||
838 | - }; | ||
839 | - // var tempParams={ | ||
840 | - // "grant_type":"password", | ||
841 | - // "username":"18510929499", | ||
842 | - // "scope":"global_access:tenant_admin", | ||
843 | - // "password":"a123456" | ||
844 | - // }; | ||
845 | - logger.info( | ||
846 | - "Third login", | ||
847 | - settings.restful.url + "uaa/v1/auth/tokens", | ||
848 | - tempParams | ||
849 | - ); | ||
850 | - rest.restful | ||
851 | - .postJson( | ||
852 | - settings.restful.url + "uaa/v1/auth/tokens", | ||
853 | - tempParams, | ||
854 | - { | ||
855 | - headers: { | ||
856 | - "Content-Type": "application/json", | ||
857 | - Accept: "application/json", | ||
858 | - }, | ||
859 | - } | ||
860 | - ) | ||
861 | - .on("success", function (data) { | ||
862 | - logger.info("Third login json data:", data); | ||
863 | - if (data.access_token) { | ||
864 | - var scopes = data.scope.split(","); | ||
865 | - passport.user.token = data.access_token; | ||
866 | - passport.user.refreshToken = data.refresh_token; | ||
867 | - passport.user.user_info = data.user || {}; | ||
868 | - passport.user.tenant_info = data.tenant; | ||
869 | - passport.user.customer_info = data.customer; | ||
870 | - passport.user.user_info.perms = data.perms; | ||
871 | - passport.user.type = data.user.type; | ||
872 | - passport.user.real_auth_status = data.user.real_auth_status; | ||
873 | - passport.user.credential_status = data.user.credential_status; | ||
874 | - passport.user.user_info.scope = scopes[0]; | ||
875 | - callback(null, data); | ||
876 | - } else { | ||
877 | - var err = new Error("Third login err"); | ||
878 | - passport.user.err = data.message; | ||
879 | - callback(err, data); | ||
880 | - } | ||
881 | - }) | ||
882 | - .on("error", function (err, response) { | ||
883 | - logger.error("Third login error", err); | ||
884 | - var err = new Error("Third login err"); | ||
885 | - callback(err, response); | ||
886 | - }) | ||
887 | - .on("fail", function (data, response) { | ||
888 | - logger.error("Third login fail", data); | ||
889 | - callback(data, response); | ||
890 | - }); | ||
891 | - }, | ||
892 | - function (data, callback) { | ||
893 | - //获取机构列表 | ||
894 | - var tempHead = {}; | ||
895 | - var ip = req.ip.match(/\d+\.\d+\.\d+\.\d+/)[0]; | ||
896 | - var user_agent = req.headers["user-agent"] || ""; | ||
897 | - tempHead["SXClientIP"] = ip; | ||
898 | - tempHead["User-Agent"] = user_agent; | ||
899 | - logger.info( | ||
900 | - "Third login tenants", | ||
901 | - settings.restful.url + "uaa/v1/tenants?all=true", | ||
902 | - { accessToken: data.access_token, headers: tempHead } | ||
903 | - ); | ||
904 | - rest.restful | ||
905 | - .get(settings.restful.url + "uaa/v1/tenants?all=true", { | ||
906 | - accessToken: data.access_token, | ||
907 | - headers: tempHead, | ||
908 | - }) | ||
909 | - .on("success", function (data1) { | ||
910 | - logger.info("Third login tenants list:", data1); | ||
911 | - if (data1 && data1.items && data1.items.length > 0) { | ||
912 | - callback(null, data1.items); | ||
913 | - } else { | ||
914 | - var err = new Error("Third login tenants list err"); | ||
915 | - passport.user.err = data.message; | ||
916 | - callback(err, data); | ||
917 | - } | ||
918 | - }) | ||
919 | - .on("error", function (err, response) { | ||
920 | - var err = new Error("Third login tenants list err"); | ||
921 | - callback(err, response); | ||
922 | - }) | ||
923 | - .on("fail", function (data, response) { | ||
924 | - callback(data, response); | ||
925 | - }); | ||
926 | - }, | ||
927 | - function (data, callback) { | ||
928 | - //刷新token | ||
929 | - if (data && data.length == 1) { | ||
930 | - var params = { | ||
931 | - grant_type: "refresh_token", | ||
932 | - scope: "global_access:tenant_admin,tenant:" + data[0].id, | ||
933 | - refresh_token: passport.user.refreshToken, | ||
934 | - }; | ||
935 | - passport.user.token = ""; | ||
936 | - logger.info( | ||
937 | - "Third login tokens", | ||
938 | - settings.restful.url + "uaa/v1/auth/tokens", | ||
939 | - params | ||
940 | - ); | ||
941 | - rest.restful | ||
942 | - .postJson(settings.restful.url + "uaa/v1/auth/tokens", params, { | ||
943 | - headers: { | ||
944 | - "Content-Type": "application/json", | ||
945 | - Accept: "application/json", | ||
946 | - }, | ||
947 | - }) | ||
948 | - .on("success", function (data2) { | ||
949 | - logger.info("Third login json data2:", data2); | ||
950 | - if (data2.access_token) { | ||
951 | - var scopes = data2.scope.split(","); | ||
952 | - passport.user.token = data2.access_token; | ||
953 | - passport.user.refreshToken = data2.refresh_token; | ||
954 | - passport.user.user_info = data2.user || {}; | ||
955 | - passport.user.tenant_info = data2.tenant; | ||
956 | - passport.user.customer_info = data2.customer; | ||
957 | - passport.user.user_info.perms = data2.perms; | ||
958 | - passport.user.type = data2.user.type; | ||
959 | - passport.user.real_auth_status = | ||
960 | - data2.user.real_auth_status; | ||
961 | - passport.user.credential_status = | ||
962 | - data2.user.credential_status; | ||
963 | - passport.user.user_info.scope = scopes[0]; | ||
964 | - passport.user.user_info.tenant = data2.tenant; | ||
965 | - passport.user.user_info.user = { | ||
966 | - credential_status: data2.credential_status, | ||
967 | - id: data2.id, | ||
968 | - is_root: data2.is_root, | ||
969 | - mobile: data2.mobile, | ||
970 | - name: data2.name, | ||
971 | - real_auth_status: data2.real_auth_status, | ||
972 | - status: data2.status, | ||
973 | - type: data2.type, | ||
974 | - wx_open_id: data2.wx_open_id, | ||
975 | - }; | ||
976 | - callback(null, data2); | ||
977 | - } else { | ||
978 | - var err = new Error("Third login err"); | ||
979 | - passport.user.err = data2.message; | ||
980 | - callback(err, data2); | ||
981 | - } | ||
982 | - }) | ||
983 | - .on("error", function (err, response) { | ||
984 | - logger.error("Third login error", err); | ||
985 | - var err = new Error("Third login err"); | ||
986 | - callback(err, response); | ||
987 | - }) | ||
988 | - .on("fail", function (data2, response) { | ||
989 | - logger.error("Third login fail", data2); | ||
990 | - callback(data2, response); | ||
991 | - }); | ||
992 | - } else if (data && data.length > 1) { | ||
993 | - // #/login/choose-tenant | ||
994 | - callback(null, data); | ||
995 | - } else { | ||
996 | - var err = new Error("Third login tenants list item error"); | ||
997 | - callback(err, data); | ||
998 | - } | ||
999 | - }, | ||
1000 | - ], | ||
1001 | - function (err, result) { | ||
1002 | - if (err) { | ||
1003 | - //登陆失败跳转失败页 | ||
1004 | - res.render("loginerr", { err: err }); | ||
1005 | - } else if (result instanceof Array && result.length > 1) { | ||
1006 | - //登陆成功跳转选择机构页 | ||
1007 | - req.session.passport = passport; | ||
1008 | - req.session.save(function () { | ||
1009 | - res.redirect(301, settings.prefix + "#login/choose-tenant"); | ||
1010 | - }); | ||
1011 | - } else { | ||
1012 | - req.session.passport = passport; | ||
1013 | - req.session.save(function () { | ||
1014 | - rest.get({ | ||
1015 | - baseUrl: "url", | ||
1016 | - url: | ||
1017 | - settings.restful.url + | ||
1018 | - "uaa" + | ||
1019 | - settings.restful.version + | ||
1020 | - "/perms/detail", | ||
1021 | - useUrl: true, | ||
1022 | - params: {}, | ||
1023 | - callback: _scb, | ||
1024 | - req: req, | ||
1025 | - res: res, | ||
1026 | - options: {}, | ||
1027 | - }); | ||
1028 | - }); | ||
1029 | - function _scb(data1, response) { | ||
1030 | - if (response.statusCode < 300 && data1.items) { | ||
1031 | - req.session.passport.user.user_info.perms = data1.items; | ||
1032 | - req.session.save(function () { | ||
1033 | - if (params.redirect_page) { | ||
1034 | - res.redirect( | ||
1035 | - 301, | ||
1036 | - settings.prefix + "#" + params.redirect_page | ||
1037 | - ); //登陆成功跳转首页 | ||
1038 | - } else { | ||
1039 | - res.redirect(301, settings.prefix + "#container/home"); //登陆成功跳转首页 | ||
1040 | - } | ||
1041 | - }); | ||
1042 | - } else { | ||
1043 | - if (params.redirect_page) { | ||
1044 | - res.redirect( | ||
1045 | - 301, | ||
1046 | - settings.prefix + "#" + params.redirect_page | ||
1047 | - ); //登陆成功跳转首页 | ||
1048 | - } else { | ||
1049 | - res.redirect(301, settings.prefix + "#container/home"); //登陆成功跳转首页 | ||
1050 | - } | ||
1051 | - } | ||
1052 | - } | ||
1053 | - } | ||
1054 | - } | ||
1055 | - ); | ||
1056 | - } | ||
1057 | - } | ||
1058 | - | ||
1059 | - function getTastLink(req, res) { | ||
1060 | - var url = crypto.createHash("md5").update(req.body.id).digest("hex"); | ||
1061 | - if (settings.prefix && settings.prefix.length > 1) { | ||
1062 | - res.send( | ||
1063 | - req.protocol + | ||
1064 | - "://" + | ||
1065 | - req.get("host") + | ||
1066 | - settings.prefix.substring(0, settings.prefix.length - 1) + | ||
1067 | - "/socialwork/freedom-jobs/emps/" + | ||
1068 | - req.body.id + | ||
1069 | - "/" + | ||
1070 | - url | ||
1071 | - ); | ||
1072 | - } else { | ||
1073 | - res.send({ | ||
1074 | - url: | ||
1075 | - req.protocol + | ||
1076 | - "://" + | ||
1077 | - req.get("host") + | ||
1078 | - "/socialwork/freedom-jobs/emps/" + | ||
1079 | - req.body.id + | ||
1080 | - "/" + | ||
1081 | - url, | ||
1082 | - }); | ||
1083 | - } | ||
1084 | - } | ||
1085 | - | ||
1086 | - function freedomJobsEmp(req, res) { | ||
1087 | - var id = req.params.id; | ||
1088 | - // var url = crypto.createHash('md5').update(id).digest('hex'); | ||
1089 | - if (false) { | ||
1090 | - //验证未通过verification != url | ||
1091 | - if (settings.prefix && settings.prefix.length > 1) { | ||
1092 | - res.redirect(settings.prefix.substring(0, settings.prefix.length - 1)); | ||
1093 | - } else { | ||
1094 | - res.redirect("/"); | ||
1095 | - } | ||
1096 | - } else { | ||
1097 | - //验证通过跳转,获取token存到session里 | ||
1098 | - var passport = { | ||
1099 | - user: { | ||
1100 | - refreshToken: "", | ||
1101 | - token: "", | ||
1102 | - service_catalog: {}, | ||
1103 | - user_info: {}, | ||
1104 | - err: null, | ||
1105 | - }, | ||
1106 | - }; | ||
1107 | - var tempParams = { | ||
1108 | - grant_type: "client_credential", | ||
1109 | - client_id: "340161778618994688", //多宝鱼环境 | ||
1110 | - client_secret: "0f8c30aa3d15332652f62c3eaf22fdea", | ||
1111 | - }; | ||
1112 | - rest.restful | ||
1113 | - .postJson(settings.restful.url + "uaa/v1/auth/tokens", tempParams, { | ||
1114 | - headers: { | ||
1115 | - "Content-Type": "application/json", | ||
1116 | - Accept: "application/json", | ||
1117 | - }, | ||
1118 | - }) | ||
1119 | - .on("success", function (data) { | ||
1120 | - if (data.access_token) { | ||
1121 | - var scopes = data.scope.split(","); | ||
1122 | - passport.user.token = data.access_token; | ||
1123 | - passport.user.refreshToken = data.refresh_token; | ||
1124 | - passport.user.user_info = data.user; | ||
1125 | - passport.user.tenant_info = data.tenant; | ||
1126 | - passport.user.customer_info = data.customer; | ||
1127 | - passport.user.user_info.perms = data.perms; | ||
1128 | - passport.user.type = data.user.type; | ||
1129 | - passport.user.real_auth_status = data.user.real_auth_status; | ||
1130 | - passport.user.credential_status = data.user.credential_status; | ||
1131 | - passport.user.user_info.scope = scopes[0]; | ||
1132 | - req.session.passport = passport; | ||
1133 | - req.session.save(function () { | ||
1134 | - if (settings.prefix && settings.prefix.length > 1) { | ||
1135 | - res.redirect( | ||
1136 | - 301, | ||
1137 | - settings.prefix.substring(0, settings.prefix.length - 1) + | ||
1138 | - "/#task_assign/" + | ||
1139 | - id | ||
1140 | - ); | ||
1141 | - } else { | ||
1142 | - res.redirect(301, "/#task_assign/" + id); | ||
1143 | - } | ||
1144 | - }); | ||
1145 | - } else { | ||
1146 | - passport.user.err = data.message; | ||
1147 | - } | ||
1148 | - }) | ||
1149 | - .on("error", function (err, response) { | ||
1150 | - logger.error("Third login error", err); | ||
1151 | - var err = new Error("Third login err"); | ||
1152 | - callback(err, response); | ||
1153 | - }) | ||
1154 | - .on("fail", function (data) { | ||
1155 | - logger.error("Third login fail", data); | ||
1156 | - }); | ||
1157 | - } | ||
1158 | - } | ||
1159 | - | ||
1160 | - function getShortToken(req, res) { | ||
1161 | - var params = { | ||
1162 | - grant_type: "refresh_token", | ||
1163 | - scope: req.session.passport.user.scope, | ||
1164 | - refresh_token: req.session.passport.user.refreshToken, | ||
1165 | - }; | ||
1166 | - logger.info("getShortToken:", params); | ||
1167 | - rest.postJson({ | ||
1168 | - baseUrl: "url", | ||
1169 | - url: | ||
1170 | - settings.restful.url + | ||
1171 | - "uaa" + | ||
1172 | - settings.restful.version + | ||
1173 | - "/auth/tokens", | ||
1174 | - useUrl: true, | ||
1175 | - params: params, | ||
1176 | - callback: _cb, | ||
1177 | - req: req, | ||
1178 | - res: res, | ||
1179 | - options: {}, | ||
1180 | - excludeToken: true, | ||
1181 | - }); | ||
1182 | - function _cb(data, response) { | ||
1183 | - console.log(data); | ||
1184 | - logger.info("back data:", data); | ||
1185 | - res.send({ code: response.statusCode, access_token: data.access_token }); | ||
1186 | - } | ||
1187 | - } | ||
1188 | - | ||
1189 | - return { | ||
1190 | - index: index, | ||
1191 | - indexPrefix, | ||
1192 | - register: register, | ||
1193 | - signIn: signIn, | ||
1194 | - doLogin: doLogin, | ||
1195 | - signOut: signOut, | ||
1196 | - smsCodes: smsCodes, | ||
1197 | - tenants: tenants, | ||
1198 | - productDes: productDes, | ||
1199 | - resetPass: resetPass, | ||
1200 | - updatePassword: updatePassword, | ||
1201 | - loadUserInfo: loadUserInfo, | ||
1202 | - getUploaderToken: getUploaderToken, | ||
1203 | - getObjectTokenByID, | ||
1204 | - delOSSObject: delOSSObject, | ||
1205 | - healthMonitor, | ||
1206 | - smsVerification, | ||
1207 | - updateUserRoles, | ||
1208 | - getRoles, | ||
1209 | - getUserRoles, | ||
1210 | - getTenant, | ||
1211 | - updateTenant, | ||
1212 | - offer, | ||
1213 | - onboardStatus, | ||
1214 | - dowloadApp, | ||
1215 | - mobileRegister, | ||
1216 | - mobileRegisterSuccess, | ||
1217 | - softwareLicense, | ||
1218 | - recharge, | ||
1219 | - changePassForRegister, | ||
1220 | - changeTenant, | ||
1221 | - sendRejectOffer, | ||
1222 | - acceptOffer, | ||
1223 | - imTokens, | ||
1224 | - listChannels, | ||
1225 | - filemeta, | ||
1226 | - getCustomerQrcode, | ||
1227 | - getPositionQrcode, | ||
1228 | - getOSSConfig, | ||
1229 | - weidianTempLate, | ||
1230 | - workaiSecurityOAuth, | ||
1231 | - getTastLink, | ||
1232 | - freedomJobsEmp, | ||
1233 | - getShortToken, | ||
1234 | - getImg | ||
1235 | - }; | 1 | +var passport = require('passport'); |
2 | +var clientRest = require('restler'); | ||
3 | +var urlencode = require('urlencode'); | ||
4 | +var async = require('async'); | ||
5 | +var crypto = require('crypto'); | ||
6 | + | ||
7 | +exports = module.exports = function (logger, rest, redis, settings) { | ||
8 | + function index(req, res, next) { | ||
9 | + logger.debug(req.user); | ||
10 | + if (req.csrfToken) { | ||
11 | + res.render('index', { 'csrfToken': req.csrfToken() }); | ||
12 | + } else | ||
13 | + res.render('index', { 'csrfToken': '' }); | ||
14 | + } | ||
15 | + | ||
16 | + function indexPrefix(req, res, next) { | ||
17 | + logger.debug(req.user); | ||
18 | + if (req.csrfToken) { | ||
19 | + if (settings.prefix && settings.prefix.length > 1) { | ||
20 | + res.redirect(settings.prefix.substring(0, settings.prefix.length - 1)); | ||
21 | + } else { | ||
22 | + res.render('index', { 'csrfToken': req.csrfToken() }); | ||
23 | + } | ||
24 | + } else | ||
25 | + res.render('index', { 'csrfToken': '' }); | ||
26 | + } | ||
27 | + | ||
28 | + function productDes(req, res, next) { | ||
29 | + if (req.csrfToken) | ||
30 | + res.render('chat/new-chat', { 'csrfToken': req.csrfToken() }); | ||
31 | + else | ||
32 | + res.render('chat/new-chat', { 'csrfToken': '' }); | ||
33 | + } | ||
34 | + | ||
35 | + function recharge(req, res, next) { | ||
36 | + | ||
37 | + var params = JSON.parse(urlencode.decode(req.query.params)); | ||
38 | + logger.debug(params); | ||
39 | + if (req.csrfToken) | ||
40 | + res.render('recharge', { 'recharge': params, 'csrfToken': req.csrfToken() }); | ||
41 | + else | ||
42 | + res.render('recharge', { 'recharge': params, 'csrfToken': '' }); | ||
43 | + | ||
44 | + } | ||
45 | + | ||
46 | + function register(req, res, next) { | ||
47 | + if (req.csrfToken) | ||
48 | + res.render('newRegister', { 'csrfToken': req.csrfToken() }); | ||
49 | + else | ||
50 | + res.render('newRegister', { 'csrfToken': '' }); | ||
51 | + } | ||
52 | + | ||
53 | + function mobileRegister(req, res, next) { | ||
54 | + if (req.csrfToken) | ||
55 | + res.render('registerMobile', { 'csrfToken': req.csrfToken() }); | ||
56 | + else | ||
57 | + res.render('registerMobile', { 'csrfToken': '' }); | ||
58 | + } | ||
59 | + | ||
60 | + function mobileRegisterSuccess(req, res, next) { | ||
61 | + if (req.csrfToken) | ||
62 | + res.render('registerMobileSuccess', { 'csrfToken': req.csrfToken() }); | ||
63 | + else | ||
64 | + res.render('registerMobileSuccess', { 'csrfToken': '' }); | ||
65 | + } | ||
66 | + | ||
67 | + function signIn(req, res, next) { | ||
68 | + // console.log(req); | ||
69 | + if (req.csrfToken) | ||
70 | + res.render('newLogin', { 'csrfToken': req.csrfToken() }); | ||
71 | + else | ||
72 | + res.render('newLogin', { 'csrfToken': '' }); | ||
73 | + | ||
74 | + } | ||
75 | + | ||
76 | + function doLogin(req, res, next) { | ||
77 | + passport.authenticate('local', function (err, user, info) { | ||
78 | + logger.debug("doLogin:", err, user, info) | ||
79 | + if (err) { return next(err); } | ||
80 | + if (!user) { return res.send(info); } | ||
81 | + req.logIn(user, function (err) { | ||
82 | + if (err) { return next(err); } | ||
83 | + return res.send({ 'ok': '登录成功', user_info: req.session.passport.user.user_info }); | ||
84 | + }); | ||
85 | + })(req, res, next); | ||
86 | + } | ||
87 | + | ||
88 | + function refreshToken (req, res, next) { | ||
89 | + var timer = null; | ||
90 | + const count = req.session.refreshTokenCount||0; | ||
91 | + if(count>3){ | ||
92 | + res.send({ | ||
93 | + code:500, | ||
94 | + message:'失败' | ||
95 | + }) | ||
96 | + timer = setTimeout(()=>{ | ||
97 | + req.session.refreshTokenCount=0 | ||
98 | + clearTimeout(timer) | ||
99 | + },1000*60*5) | ||
100 | + return | ||
101 | + } | ||
102 | + var tempParams = { | ||
103 | + "grant_type": "refresh_token", | ||
104 | + "username": req.session.passport.user.user_info.user.mobile, | ||
105 | + refresh_token:req.session.passport.user.refreshToken, | ||
106 | + "scope": "global_access:tenant_admin", | ||
107 | + }; | ||
108 | + var url = rest.getBaseUrl('auth/tokens', 'uaa'); | ||
109 | + var headers = rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req); | ||
110 | + rest.restful.postJson(url, tempParams, { | ||
111 | + headers: headers | ||
112 | + }).on('success',function(data,response){ | ||
113 | + req.session.passport.user.token = data.access_token; | ||
114 | + req.session.refreshTokenCount = count+1; | ||
115 | + res.send({code:200,message:'成功'}) | ||
116 | + rest.proxyLog(data,response,req,{headers,'data':tempParams,url}) | ||
117 | + }) | ||
118 | + } | ||
119 | + | ||
120 | + function signOut(req, res, next) { | ||
121 | + if (req.session.passport && req.session.passport.user && req.session.passport.user.user_info && req.session.passport.user.user_info.user) | ||
122 | + logger.debug(req.session.passport.user.user_info.user, 'You have successfully logged out'); | ||
123 | + req.logout(); | ||
124 | + req.flash('success', 'You have successfully logged out'); | ||
125 | + res.redirect('/'); | ||
126 | + } | ||
127 | + | ||
128 | + function smsCodes(req, res, next) { | ||
129 | + rest.postJson({ | ||
130 | + 'baseUrl': 'url', | ||
131 | + 'url': 'auth/smscodes', | ||
132 | + 'params': req.body, | ||
133 | + 'callback': _cb, | ||
134 | + 'req': req, | ||
135 | + 'res': res, | ||
136 | + 'options': {}, | ||
137 | + 'excludeToken': true | ||
138 | + }) | ||
139 | + function _cb(data, response) { | ||
140 | + logger.debug("back data:", data); | ||
141 | + if (response.statusCode < 300) { | ||
142 | + res.send({ "code": 200, "message": "发送成功" }); | ||
143 | + } else { | ||
144 | + res.send(data); | ||
145 | + } | ||
146 | + }; | ||
147 | + } | ||
148 | + | ||
149 | + function tenants(req, res, next) { | ||
150 | + rest.register({ | ||
151 | + 'baseUrl': 'url', | ||
152 | + 'url': 'tenants', | ||
153 | + 'params': req.body, | ||
154 | + 'callback': _cb, | ||
155 | + 'req': req, | ||
156 | + 'res': res, | ||
157 | + 'options': {}, | ||
158 | + 'excludeToken': true | ||
159 | + }); | ||
160 | + function _cb(data, response) { | ||
161 | + logger.debug("back data:", data); | ||
162 | + res.send(data); | ||
163 | + }; | ||
164 | + } | ||
165 | + | ||
166 | + function resetPass(req, res) { | ||
167 | + rest.putJson({ | ||
168 | + 'baseUrl': 'url', | ||
169 | + 'url': 'auth/user', | ||
170 | + 'params': { | ||
171 | + 'user': req.body.user, | ||
172 | + 'password': req.body.password, | ||
173 | + 'again_password': req.body.again_password | ||
174 | + }, | ||
175 | + 'callback': _cb, | ||
176 | + 'req': req, | ||
177 | + 'res': res, | ||
178 | + 'options': {} | ||
179 | + }) | ||
180 | + function _cb(data, response) { | ||
181 | + logger.debug("back data:", data); | ||
182 | + res.send(data); | ||
183 | + }; | ||
184 | + } | ||
185 | + | ||
186 | + function updatePassword(req, res) { | ||
187 | + rest.patchJson({ | ||
188 | + 'baseUrl': 'url', | ||
189 | + 'url': 'users/' + req.body.userId, | ||
190 | + 'params': { | ||
191 | + 'password': req.body.password | ||
192 | + }, | ||
193 | + 'callback': _cb, | ||
194 | + 'req': req, | ||
195 | + 'res': res, | ||
196 | + 'options': {} | ||
197 | + }) | ||
198 | + function _cb(data, response) { | ||
199 | + logger.debug("back data:", data); | ||
200 | + res.send(data); | ||
201 | + }; | ||
202 | + } | ||
203 | + | ||
204 | + | ||
205 | + function loadUserInfo(req, res,next) { | ||
206 | + | ||
207 | + if (req.session.passport.user && req.session.passport.user.user_info) { | ||
208 | + logger.debug("loadUserInfo:", req.session.passport.user.user_info); | ||
209 | + if(req.body.id){ | ||
210 | + var params = { | ||
211 | + grant_type: 'refresh_token', | ||
212 | + scope: 'global_access:tenant_admin,tenant:' + req.body.id, | ||
213 | + refresh_token: req.session.passport.user.refreshToken | ||
214 | + } | ||
215 | + // req.session.passport.user.token = ''; | ||
216 | + rest.postJson({ | ||
217 | + 'baseUrl': 'url', | ||
218 | + 'url': settings.restful.url + 'uaa' + settings.restful.version + '/auth/tokens', | ||
219 | + 'useUrl': true, | ||
220 | + 'params': params, | ||
221 | + 'callback': _cb, | ||
222 | + 'req': req, | ||
223 | + 'res': res, | ||
224 | + 'options': {}, | ||
225 | + 'excludeToken': true | ||
226 | + }) | ||
227 | + function _cb(data, response) { | ||
228 | + logger.debug("changeTenant,tokens......:", data); | ||
229 | + if (response.statusCode < 300) { | ||
230 | + req.session.passport.user.token = data.access_token; | ||
231 | + req.session.passport.user.refreshToken = data.refresh_token; | ||
232 | + req.session.passport.user.user_info = { | ||
233 | + 'user': data.user, | ||
234 | + 'perms': req.session.passport.user.user_info.perms, | ||
235 | + 'tenant': data.tenant, | ||
236 | + 'scope': data.scope, | ||
237 | + 'oss': req.session.passport.user.user_info.oss, | ||
238 | + }; | ||
239 | + req.session.save(function (err) { | ||
240 | + rest.get({ | ||
241 | + 'baseUrl': 'url', | ||
242 | + 'url': settings.restful.url + 'uaa' + settings.restful.version + '/perms/detail', | ||
243 | + 'useUrl': true, | ||
244 | + 'params': {}, | ||
245 | + 'callback': _scb, | ||
246 | + 'req': req, | ||
247 | + 'res': res, | ||
248 | + 'options': {} | ||
249 | + }); | ||
250 | + }) | ||
251 | + } else { | ||
252 | + res.send({ "code": response.statusCode, "message": data.message, initialize_done: "n" }); | ||
253 | + } | ||
254 | + }; | ||
255 | + function _scb(data1, response) { | ||
256 | + if (response.statusCode < 300 && data1.items) { | ||
257 | + logger.debug("perms......:", data1.items); | ||
258 | + //判断是否存在优学乐业菜单 | ||
259 | + if (data1.items.length > 0) { | ||
260 | + let yxly_list = data1.items.filter((item, index) => { return item.module == 'yxly' }); | ||
261 | + if (yxly_list.length > 0) { | ||
262 | + loadYxlyToken(req, res); | ||
263 | + } | ||
264 | + } | ||
265 | + | ||
266 | + req.session.passport.user.user_info.perms = data1.items; | ||
267 | + req.session.save(function (err) { | ||
268 | + rest.get({ | ||
269 | + 'baseUrl': 'url', | ||
270 | + 'url': settings.restful.url + 'filemeta' + settings.restful.version + '/config', | ||
271 | + 'useUrl': true, | ||
272 | + 'params': {}, | ||
273 | + 'callback': _scb1, | ||
274 | + 'req': req, | ||
275 | + 'res': res, | ||
276 | + 'options': {} | ||
277 | + }); | ||
278 | + }) | ||
279 | + } else { | ||
280 | + res.send({ "code": response.statusCode, "message": data1.message }); | ||
281 | + } | ||
282 | + } | ||
283 | + function _scb1(data2, response) { | ||
284 | + if (response.statusCode < 300 && data2 && data2.bucket) { | ||
285 | + req.session.passport.user.user_info.oss = data2; | ||
286 | + req.session.save(function (err) { | ||
287 | + res.send({ user_info: req.session.passport.user.user_info, prefix: settings.prefix }); | ||
288 | + }); | ||
289 | + } else { | ||
290 | + res.send({ "code": 200, "message": "切换租户失败" }); | ||
291 | + } | ||
292 | + } | ||
293 | + }else { | ||
294 | + res.send({ user_info: req.session.passport.user.user_info, prefix: settings.prefix }); | ||
295 | + } | ||
296 | + } else { | ||
297 | + res.send({ user_info: null, prefix: settings.prefix }); | ||
298 | + } | ||
299 | + } | ||
300 | + | ||
301 | + function getUploaderToken(req, res) { | ||
302 | + rest.postJson({ | ||
303 | + 'baseUrl': 'ossUrl', | ||
304 | + 'url': 'inits', | ||
305 | + 'params': req.body, | ||
306 | + 'callback': _cb, | ||
307 | + 'req': req, | ||
308 | + 'res': res, | ||
309 | + 'options': {} | ||
310 | + }) | ||
311 | + function _cb(data, response) { | ||
312 | + logger.debug("back data:", data); | ||
313 | + res.send(data); | ||
314 | + }; | ||
315 | + } | ||
316 | + | ||
317 | + function getObjectTokenByID(req, res) { | ||
318 | + rest.get({ | ||
319 | + 'baseUrl': 'ossUrl', | ||
320 | + 'url': 'objects/' + req.body.file_id, | ||
321 | + 'params': {}, | ||
322 | + 'callback': _cb, | ||
323 | + 'req': req, | ||
324 | + 'res': res, | ||
325 | + 'options': {} | ||
326 | + }) | ||
327 | + function _cb(data, response) { | ||
328 | + logger.debug("back data:", data); | ||
329 | + res.send(data); | ||
330 | + }; | ||
331 | + } | ||
332 | + | ||
333 | + function delOSSObject(req, res) { | ||
334 | + rest.del({ | ||
335 | + 'baseUrl': 'ossUrl', | ||
336 | + 'url': 's3objects/' + req.body.request_id + '?bucket=' + req.body.bucket + '&file=' + req.body.name, | ||
337 | + 'params': {}, | ||
338 | + 'callback': _cb, | ||
339 | + 'req': req, | ||
340 | + 'res': res, | ||
341 | + 'options': {} | ||
342 | + }) | ||
343 | + function _cb(data, response) { | ||
344 | + logger.debug("back data:", data); | ||
345 | + logger.debug(response.statusCode) | ||
346 | + if (response.statusCode < 300) { | ||
347 | + res.send({ 'delete': 'ok' }); | ||
348 | + } | ||
349 | + }; | ||
350 | + } | ||
351 | + | ||
352 | + function smsVerification(req, res, next) { | ||
353 | + rest.postJson({ | ||
354 | + 'baseUrl': 'url', | ||
355 | + 'url': 'auth/sms_verification', | ||
356 | + 'params': req.body, | ||
357 | + 'callback': _cb, | ||
358 | + 'req': req, | ||
359 | + 'res': res, | ||
360 | + 'options': {}, | ||
361 | + 'excludeToken': true | ||
362 | + }) | ||
363 | + function _cb(data, response) { | ||
364 | + logger.debug("back data:", data); | ||
365 | + if (response.statusCode < 300) { | ||
366 | + res.send({ "code": 200, "message": "发送成功" }); | ||
367 | + } else { | ||
368 | + res.send({ "code": response.statusCode, "message": data.message, 'errors': data.errors }); | ||
369 | + } | ||
370 | + }; | ||
371 | + } | ||
372 | + | ||
373 | + function healthMonitor(req, res) { | ||
374 | + res.statusCode = 200; | ||
375 | + return res.send('status ok'); | ||
376 | + } | ||
377 | + | ||
378 | + | ||
379 | + function updateUserRoles(req, res) { | ||
380 | + rest.putJson({ | ||
381 | + 'baseUrl': 'url', | ||
382 | + 'url': 'user_roles/' + req.body.user_id, | ||
383 | + 'params': req.body.roles, | ||
384 | + 'callback': _cb, | ||
385 | + 'req': req, | ||
386 | + 'res': res, | ||
387 | + 'options': {} | ||
388 | + }) | ||
389 | + function _cb(data, response) { | ||
390 | + logger.debug("back data:", data); | ||
391 | + if (response.statusCode < 300) { | ||
392 | + res.send({ 'back': 'ok' }); | ||
393 | + } else { | ||
394 | + res.send(data); | ||
395 | + } | ||
396 | + }; | ||
397 | + } | ||
398 | + | ||
399 | + function getRoles(req, res, next) { | ||
400 | + rest.get({ | ||
401 | + 'baseUrl': 'url', | ||
402 | + 'url': 'roles', | ||
403 | + 'params': {}, | ||
404 | + 'callback': _cb, | ||
405 | + 'req': req, | ||
406 | + 'res': res, | ||
407 | + 'options': {} | ||
408 | + }) | ||
409 | + function _cb(data, response) { | ||
410 | + logger.debug("back data:", data); | ||
411 | + res.send(data); | ||
412 | + }; | ||
413 | + } | ||
414 | + | ||
415 | + | ||
416 | + function getUserRoles(req, res, next) { | ||
417 | + rest.get({ | ||
418 | + 'baseUrl': 'url', | ||
419 | + 'url': 'user_roles?user=' + urlencode(req.body.user) + '&limit=' + req.body.limit + '&offset=' + req.body.offset, | ||
420 | + 'params': {}, | ||
421 | + 'callback': _cb, | ||
422 | + 'req': req, | ||
423 | + 'res': res, | ||
424 | + 'options': {} | ||
425 | + }) | ||
426 | + function _cb(data, response) { | ||
427 | + logger.debug("back data:", data); | ||
428 | + res.send(data); | ||
429 | + }; | ||
430 | + } | ||
431 | + | ||
432 | + function getTenant(req, res) { | ||
433 | + rest.get({ | ||
434 | + 'baseUrl': 'url', | ||
435 | + 'url': 'tenants/' + req.body.tenant_id, | ||
436 | + 'params': {}, | ||
437 | + 'callback': _cb, | ||
438 | + 'req': req, | ||
439 | + 'res': res, | ||
440 | + 'options': {} | ||
441 | + }) | ||
442 | + function _cb(data, response) { | ||
443 | + logger.debug("back data:", data); | ||
444 | + res.send(data); | ||
445 | + }; | ||
446 | + } | ||
447 | + | ||
448 | + function updateTenant(req, res) { | ||
449 | + rest.putJson({ | ||
450 | + 'baseUrl': 'url', | ||
451 | + 'url': 'tenants/' + req.body.tenant_id, | ||
452 | + 'params': req.body.tenant, | ||
453 | + 'callback': _cb, | ||
454 | + 'req': req, | ||
455 | + 'res': res, | ||
456 | + 'options': {} | ||
457 | + }) | ||
458 | + function _cb(data, response) { | ||
459 | + logger.debug("back data:", data); | ||
460 | + res.send(data); | ||
461 | + }; | ||
462 | + } | ||
463 | + | ||
464 | + function offer(req, res) { | ||
465 | + rest.get({ | ||
466 | + 'baseUrl': 'hrUrl', | ||
467 | + 'url': 'offers/' + req.params.requestId + '?tenant_id=' + req.query.tenant_id, | ||
468 | + 'params': {}, | ||
469 | + 'callback': _cb, | ||
470 | + 'req': req, | ||
471 | + 'res': res, | ||
472 | + 'options': {}, | ||
473 | + 'excludeToken': true | ||
474 | + }) | ||
475 | + function _cb(data, response) { | ||
476 | + logger.debug(data); | ||
477 | + data['offerId'] = req.params.requestId; | ||
478 | + data['tenantId'] = req.query.tenant_id; | ||
479 | + res.render('offer', data); | ||
480 | + }; | ||
481 | + } | ||
482 | + | ||
483 | + function onboardStatus(req, res) { | ||
484 | + rest.get({ | ||
485 | + 'baseUrl': 'hrUrl', | ||
486 | + 'url': 'onboard-status', | ||
487 | + 'params': {}, | ||
488 | + 'callback': _cb, | ||
489 | + 'req': req, | ||
490 | + 'res': res, | ||
491 | + 'options': {}, | ||
492 | + 'useUrl': true | ||
493 | + }) | ||
494 | + function _cb(data, response) { | ||
495 | + logger.debug("back data:", data); | ||
496 | + res.send(data); | ||
497 | + }; | ||
498 | + } | ||
499 | + | ||
500 | + function dowloadApp(req, res) { | ||
501 | + var mobileAgent = req.headers['user-agent'].toLowerCase(); | ||
502 | + var agent = { | ||
503 | + android: mobileAgent.indexOf('android') > -1 || mobileAgent.indexOf('Adr') > -1, | ||
504 | + iPhone: mobileAgent.indexOf('iphone') > -1, | ||
505 | + iPad: mobileAgent.indexOf('ipad') > -1 | ||
506 | + } | ||
507 | + if (agent.iPhone || agent.iPad) { | ||
508 | + res.redirect(301, 'https://itunes.apple.com/cn/app/%E8%96%AA%E5%91%97/id1140779439?l=en&mt=8'); | ||
509 | + } else if (agent.android) { | ||
510 | + res.redirect(301, 'http://krhrimg.oss-cn-beijing.aliyuncs.com/appdownload/production/android/krhr-android.apk'); | ||
511 | + } else { | ||
512 | + res.redirect(301, 'http://krhrimg.oss-cn-beijing.aliyuncs.com/appdownload/production/android/krhr-android.apk'); | ||
513 | + } | ||
514 | + } | ||
515 | + | ||
516 | + function softwareLicense(req, res, next) { | ||
517 | + res.render('softwareLicense'); | ||
518 | + } | ||
519 | + | ||
520 | + function changePassForRegister(req, res, next) { | ||
521 | + var options = { | ||
522 | + 'baseUrl': 'url', | ||
523 | + 'url': 'users/' + req.body.user_id, | ||
524 | + 'params': { | ||
525 | + 'password': req.body.password | ||
526 | + }, | ||
527 | + 'callback': _cb, | ||
528 | + 'req': req, | ||
529 | + 'res': res, | ||
530 | + 'options': {} | ||
531 | + }; | ||
532 | + if (req.body.access_token) { | ||
533 | + options.options = { | ||
534 | + "accessToken": req.body.access_token | ||
535 | + }; | ||
536 | + options['excludeToken'] = true; | ||
537 | + } | ||
538 | + rest.patchJson(options) | ||
539 | + function _cb(data, response) { | ||
540 | + logger.debug("back data:", data); | ||
541 | + res.send(data); | ||
542 | + }; | ||
543 | + } | ||
544 | + | ||
545 | + function changeTenant(req, res, next) { | ||
546 | + var params = { | ||
547 | + grant_type: 'refresh_token', | ||
548 | + scope: 'global_access:tenant_admin,tenant:' + req.body.id, | ||
549 | + refresh_token: req.session.passport.user.refreshToken | ||
550 | + } | ||
551 | + req.session.passport.user.token = ''; | ||
552 | + rest.postJson({ | ||
553 | + 'baseUrl': 'url', | ||
554 | + 'url': settings.restful.url + 'uaa' + settings.restful.version + '/auth/tokens', | ||
555 | + 'useUrl': true, | ||
556 | + 'params': params, | ||
557 | + 'callback': _cb, | ||
558 | + 'req': req, | ||
559 | + 'res': res, | ||
560 | + 'options': {}, | ||
561 | + 'excludeToken': true | ||
562 | + }) | ||
563 | + function _cb(data, response) { | ||
564 | + logger.debug("changeTenant,tokens......:", data); | ||
565 | + if (response.statusCode < 300) { | ||
566 | + req.session.passport.user.token = data.access_token; | ||
567 | + req.session.passport.user.refreshToken = data.refresh_token; | ||
568 | + req.session.passport.user.user_info = { | ||
569 | + 'user': data.user, | ||
570 | + 'perms': [], | ||
571 | + 'tenant': data.tenant, | ||
572 | + 'scope': data.scope, | ||
573 | + 'oss': req.session.passport.user.user_info.oss, | ||
574 | + }; | ||
575 | + req.session.save(function (err) { | ||
576 | + rest.get({ | ||
577 | + 'baseUrl': 'url', | ||
578 | + 'url': settings.restful.url + 'uaa' + settings.restful.version + '/perms/detail', | ||
579 | + 'useUrl': true, | ||
580 | + 'params': {}, | ||
581 | + 'callback': _scb, | ||
582 | + 'req': req, | ||
583 | + 'res': res, | ||
584 | + 'options': {} | ||
585 | + }); | ||
586 | + }) | ||
587 | + } else { | ||
588 | + res.send({ "code": response.statusCode, "message": data.message, initialize_done: "n" }); | ||
589 | + } | ||
590 | + }; | ||
591 | + function _scb(data1, response) { | ||
592 | + if (response.statusCode < 300 && data1.items) { | ||
593 | + logger.debug("perms......:", data1.items); | ||
594 | + //判断是否存在优学乐业菜单 | ||
595 | + if (data1.items.length > 0) { | ||
596 | + let yxly_list = data1.items.filter((item, index) => { return item.module == 'yxly' }); | ||
597 | + if (yxly_list.length > 0) { | ||
598 | + loadYxlyToken(req, res); | ||
599 | + } | ||
600 | + } | ||
601 | + | ||
602 | + req.session.passport.user.user_info.perms = data1.items; | ||
603 | + req.session.save(function (err) { | ||
604 | + rest.get({ | ||
605 | + 'baseUrl': 'url', | ||
606 | + 'url': settings.restful.url + 'filemeta' + settings.restful.version + '/config', | ||
607 | + 'useUrl': true, | ||
608 | + 'params': {}, | ||
609 | + 'callback': _scb1, | ||
610 | + 'req': req, | ||
611 | + 'res': res, | ||
612 | + 'options': {} | ||
613 | + }); | ||
614 | + }) | ||
615 | + } else { | ||
616 | + res.send({ "code": response.statusCode, "message": data1.message }); | ||
617 | + } | ||
618 | + } | ||
619 | + function _scb1(data2, response) { | ||
620 | + if (response.statusCode < 300 && data2 && data2.bucket) { | ||
621 | + req.session.passport.user.user_info.oss = data2; | ||
622 | + req.session.save(function (err) { | ||
623 | + res.send({ "code": 200, "message": "切换租户成功" }); | ||
624 | + }); | ||
625 | + } else { | ||
626 | + res.send({ "code": 200, "message": "切换租户失败" }); | ||
627 | + } | ||
628 | + } | ||
629 | + } | ||
630 | + | ||
631 | + | ||
632 | + function sendRejectOffer(req, res) { | ||
633 | + rest.get({ | ||
634 | + 'baseUrl': 'hrUrl', | ||
635 | + 'url': req.body.url, //传一个参数 | ||
636 | + 'params': {}, | ||
637 | + 'callback': _cb, | ||
638 | + 'req': req, | ||
639 | + 'res': res, | ||
640 | + 'options': {}, | ||
641 | + 'excludeToken': true, | ||
642 | + 'useUrl': true | ||
643 | + }); | ||
644 | + function _cb(data, response) { | ||
645 | + logger.debug("back data:", data); | ||
646 | + if (response.statusCode < 300) { | ||
647 | + res.send({ 'action': 'ok' }); | ||
648 | + } else { | ||
649 | + res.send(data); | ||
650 | + } | ||
651 | + }; | ||
652 | + } | ||
653 | + | ||
654 | + function acceptOffer(req, res) { | ||
655 | + rest.get({ | ||
656 | + 'baseUrl': 'hrUrl', | ||
657 | + 'url': req.body.url, //传一个参数 | ||
658 | + 'params': {}, | ||
659 | + 'callback': _cb, | ||
660 | + 'req': req, | ||
661 | + 'res': res, | ||
662 | + 'options': {}, | ||
663 | + 'excludeToken': true, | ||
664 | + 'useUrl': true | ||
665 | + }); | ||
666 | + function _cb(data, response) { | ||
667 | + logger.debug("back data:", data); | ||
668 | + if (response.statusCode < 300) { | ||
669 | + res.send({ 'action': 'ok' }); | ||
670 | + } else { | ||
671 | + res.send(data); | ||
672 | + } | ||
673 | + }; | ||
674 | + } | ||
675 | + | ||
676 | + function imTokens(req, res) { | ||
677 | + rest.post({ | ||
678 | + 'url': 'auth/im_tokens', | ||
679 | + 'params': req.body, | ||
680 | + 'callback': _cb, | ||
681 | + 'req': req, | ||
682 | + 'res': res, | ||
683 | + 'options': {} | ||
684 | + }); | ||
685 | + function _cb(data, response) { | ||
686 | + logger.debug("back data:", data); | ||
687 | + res.send(data); | ||
688 | + }; | ||
689 | + } | ||
690 | + | ||
691 | + function listChannels(req, res, next) { | ||
692 | + rest.get({ | ||
693 | + 'baseUrl': 'chatUrl', | ||
694 | + 'url': 'channels?page_size=10&page=0&status=active', | ||
695 | + 'params': req.body, | ||
696 | + 'callback': _cb, | ||
697 | + 'req': req, | ||
698 | + 'res': res, | ||
699 | + 'options': {} | ||
700 | + }) | ||
701 | + function _cb(data, response) { | ||
702 | + logger.debug("back data:", data); | ||
703 | + res.send(data); | ||
704 | + }; | ||
705 | + } | ||
706 | + | ||
707 | + function filemeta(req, res, next) { | ||
708 | + var fullPath = settings.restful.url + 'filemeta' + settings.restful.version + '/object-redirect'; | ||
709 | + fullPath = fullPath + "?" + "bucket=" + req.query.bucket + "&object=" + encodeURIComponent(req.query.object); | ||
710 | + console.info('fullPath::::::', fullPath); | ||
711 | + var options = { | ||
712 | + 'service_catalog': '', | ||
713 | + 'url': fullPath, | ||
714 | + 'useUrl': true, | ||
715 | + 'params': req.body, | ||
716 | + 'callback': _cb, | ||
717 | + 'req': req, | ||
718 | + 'res': res, | ||
719 | + 'options': {} | ||
720 | + }; | ||
721 | + rest.get(options); | ||
722 | + function _cb(data, response) { | ||
723 | + if (data && data.download_url) { | ||
724 | + if (req.query.type && 'json' == req.query.type) { | ||
725 | + res.send(data); | ||
726 | + } else { | ||
727 | + var url = data.download_url; | ||
728 | + let path = url.split('?')[0]; | ||
729 | + let pathArray = path.split('/'); | ||
730 | + let result = []; | ||
731 | + for (var i = 0; i < pathArray.length; i++) { | ||
732 | + if (i == pathArray.length - 1) { | ||
733 | + result.push(encodeURIComponent(pathArray[i])); | ||
734 | + } else { | ||
735 | + result.push(pathArray[i]); | ||
736 | + } | ||
737 | + } | ||
738 | + let result1 = result.join('/'); | ||
739 | + if (url.indexOf('?') !== -1) { | ||
740 | + result1 += '?' + url.split('?')[1]; | ||
741 | + } | ||
742 | + if (req.query.result_callback) { | ||
743 | + res.send(data); | ||
744 | + } else { | ||
745 | + res.redirect(301, result1); | ||
746 | + } | ||
747 | + } | ||
748 | + } else { | ||
749 | + res.send(data); | ||
750 | + } | ||
751 | + } | ||
752 | + } | ||
753 | + | ||
754 | + | ||
755 | + function getCustomerQrcode(req, res, next) { | ||
756 | + var fullPath = settings.restful.url + 'crm' + settings.restful.version + '/customers/' + req.query.id + '/qrcode'; | ||
757 | + var options = { | ||
758 | + 'service_catalog': '', | ||
759 | + 'url': fullPath, | ||
760 | + 'useUrl': true, | ||
761 | + 'params': req.body, | ||
762 | + 'callback': _cb, | ||
763 | + 'req': req, | ||
764 | + 'res': res, | ||
765 | + 'options': {} | ||
766 | + }; | ||
767 | + rest.get(options); | ||
768 | + function _cb(data, response) { | ||
769 | + if (data && data.url_path) { | ||
770 | + res.redirect(301, data.url_path); | ||
771 | + } else { | ||
772 | + res.send(data); | ||
773 | + } | ||
774 | + } | ||
775 | + } | ||
776 | + | ||
777 | + function getPositionQrcode(req, res, next) { | ||
778 | + var fullPath = settings.restful.url + 'recruit' + settings.restful.version + '/positions/' + req.query.id + '/qrcode'; | ||
779 | + var options = { | ||
780 | + 'service_catalog': '', | ||
781 | + 'url': fullPath, | ||
782 | + 'useUrl': true, | ||
783 | + 'params': req.body, | ||
784 | + 'callback': _cb, | ||
785 | + 'req': req, | ||
786 | + 'res': res, | ||
787 | + 'options': {} | ||
788 | + }; | ||
789 | + rest.get(options); | ||
790 | + function _cb(data, response) { | ||
791 | + if (data && data.url_path) { | ||
792 | + res.redirect(301, data.url_path); | ||
793 | + } else { | ||
794 | + res.send(data); | ||
795 | + } | ||
796 | + } | ||
797 | + } | ||
798 | + | ||
799 | + function getOSSConfig(req, res, next) { | ||
800 | + var fullPath = settings.restful.url + 'filemeta' + settings.restful.version + '/config'; | ||
801 | + var options = { | ||
802 | + 'service_catalog': '', | ||
803 | + 'url': fullPath, | ||
804 | + 'useUrl': true, | ||
805 | + 'params': req.body, | ||
806 | + 'callback': _cb, | ||
807 | + 'req': req, | ||
808 | + 'res': res, | ||
809 | + 'options': {} | ||
810 | + }; | ||
811 | + rest.get(options); | ||
812 | + function _cb(data, response) { | ||
813 | + if (data && data.bucket) { | ||
814 | + req.session.passport.user.user_info.oss = data; | ||
815 | + req.session.save(function (err) { | ||
816 | + res.send({ "code": 200, "message": "oss配置加载成功" }); | ||
817 | + }); | ||
818 | + } else { | ||
819 | + res.send({ "code": 200, "message": "oss配置加载失败" }); | ||
820 | + } | ||
821 | + } | ||
822 | + } | ||
823 | + | ||
824 | + function weidianTempLate(req, res, next) { | ||
825 | + const { params } = req; | ||
826 | + var fullPath = settings.restful.url + 'socialwork/internal/minishop/' + params.id; | ||
827 | + var options = { | ||
828 | + 'service_catalog': '', | ||
829 | + 'url': fullPath, | ||
830 | + 'useUrl': true, | ||
831 | + 'params': req.body, | ||
832 | + 'callback': _cb, | ||
833 | + 'req': req, | ||
834 | + 'res': res, | ||
835 | + 'options': {}, | ||
836 | + 'excludeToken': true, | ||
837 | + }; | ||
838 | + rest.get(options); | ||
839 | + function _cb(data, response) { | ||
840 | + logger.debug("back data:", data); | ||
841 | + if (response.statusCode < 300) { | ||
842 | + const { shop_logo = [], shop_name = '', shop_comment = '' } = data; | ||
843 | + let imgUrl = ''; | ||
844 | + if (shop_logo.length > 0) { | ||
845 | + imgUrl = 'http://oss.workai.com.cn/public/' + shop_logo[0].object; | ||
846 | + } | ||
847 | + res.render('template/weiDian', { | ||
848 | + imgUrl: imgUrl, | ||
849 | + shop_name: shop_name, | ||
850 | + shop_comment: shop_comment, | ||
851 | + }) | ||
852 | + } else { | ||
853 | + res.render('template/weiDian') | ||
854 | + } | ||
855 | + }; | ||
856 | + | ||
857 | + } | ||
858 | + | ||
859 | + | ||
860 | + function workaiSecurityOAuth(req, res, next) { | ||
861 | + var params = req.query; | ||
862 | + if (params.authorization_code) { | ||
863 | + var passport = { | ||
864 | + user: { | ||
865 | + refreshToken: "", | ||
866 | + token: "", | ||
867 | + service_catalog: {}, | ||
868 | + user_info: {}, | ||
869 | + err: null | ||
870 | + } | ||
871 | + }; | ||
872 | + async.waterfall([ | ||
873 | + function (callback) {//第三方登录 | ||
874 | + var tempParams = { | ||
875 | + "grant_type": 'authorization_code_v1', | ||
876 | + "code": params.authorization_code | ||
877 | + }; | ||
878 | + // var tempParams={ | ||
879 | + // "grant_type":"password", | ||
880 | + // "username":"18510929499", | ||
881 | + // "scope":"global_access:tenant_admin", | ||
882 | + // "password":"a123456" | ||
883 | + // }; | ||
884 | + logger.debug("Third login", settings.restful.url + 'uaa/v1/auth/tokens', tempParams); | ||
885 | + rest.restful.postJson(settings.restful.url + 'uaa/v1/auth/tokens', tempParams, { | ||
886 | + headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req) | ||
887 | + }) | ||
888 | + .on('success', function (data, response) { | ||
889 | + logger.debug("Third login json data:", data); | ||
890 | + if (data.access_token) { | ||
891 | + var scopes = data.scope.split(","); | ||
892 | + passport.user.token = data.access_token; | ||
893 | + passport.user.refreshToken = data.refresh_token; | ||
894 | + passport.user.user_info = data.user || {}; | ||
895 | + passport.user.tenant_info = data.tenant; | ||
896 | + passport.user.customer_info = data.customer; | ||
897 | + passport.user.user_info.perms = data.perms; | ||
898 | + passport.user.type = data.user.type; | ||
899 | + passport.user.real_auth_status = data.user.real_auth_status; | ||
900 | + passport.user.credential_status = data.user.credential_status; | ||
901 | + passport.user.user_info.scope = scopes[0]; | ||
902 | + callback(null, data) | ||
903 | + } else { | ||
904 | + var err = new Error('Third login err'); | ||
905 | + passport.user.err = data.message; | ||
906 | + callback(err, data); | ||
907 | + } | ||
908 | + rest.proxyLog(data,response,req,{headers:rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':tempParams,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
909 | + }).on('error', function (err, response) { | ||
910 | + logger.debug("Third login error", err); | ||
911 | + var err = new Error('Third login err'); | ||
912 | + callback(err, response); | ||
913 | + rest.proxyLog(err,response,req,{headers:rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':tempParams,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
914 | + }).on('fail', function (data, response) { | ||
915 | + logger.debug("Third login fail", data); | ||
916 | + var err = new Error('Third login err'); | ||
917 | + callback(data, response); | ||
918 | + rest.proxyLog(data,response,req,{headers:rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':tempParams,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
919 | + }); | ||
920 | + }, function (data, callback) { //获取机构列表 | ||
921 | + var tempHead = {}; | ||
922 | + var ip = req.ip.match(/\d+\.\d+\.\d+\.\d+/)[0]; | ||
923 | + var user_agent = req.headers['user-agent'] || ''; | ||
924 | + tempHead['SXClientIP'] = ip; | ||
925 | + tempHead['User-Agent'] = user_agent; | ||
926 | + logger.debug("Third login tenants", settings.restful.url + 'uaa/v1/tenants?all=true', { accessToken: data.access_token, headers: tempHead }); | ||
927 | + rest.restful.get(settings.restful.url + 'uaa/v1/tenants?all=true', { accessToken: data.access_token, headers: rest.addHeaders(tempHead,req) }) | ||
928 | + .on('success', function (data1, response) { | ||
929 | + logger.debug("Third login tenants list:", data1); | ||
930 | + if (data1 && data1.items && data1.items.length > 0) { | ||
931 | + callback(null, data1.items) | ||
932 | + } else { | ||
933 | + var err = new Error('Third login tenants list err'); | ||
934 | + passport.user.err = data.message; | ||
935 | + callback(err, data); | ||
936 | + } | ||
937 | + rest.proxyLog(data1,response,req,{headers:rest.addHeaders(tempHead,req),'data':{},url:settings.restful.url + 'uaa/v1/tenants?all=true'}) | ||
938 | + }).on('error', function (err, response) { | ||
939 | + var err = new Error('Third login tenants list err'); | ||
940 | + callback(err, response); | ||
941 | + rest.proxyLog(err,response,req,{headers:rest.addHeaders(tempHead,req),'data':{},url:settings.restful.url + 'uaa/v1/tenants?all=true'}) | ||
942 | + }).on('fail', function (data, response) { | ||
943 | + var err = new Error('Third login tenants list fail'); | ||
944 | + callback(data, response); | ||
945 | + rest.proxyLog(data,response,req,{headers:rest.addHeaders(tempHead,req),'data':{},url:settings.restful.url + 'uaa/v1/tenants?all=true'}) | ||
946 | + }); | ||
947 | + }, function (data, callback) { //刷新token | ||
948 | + if (data && data.length == 1) { | ||
949 | + var params = { | ||
950 | + grant_type: 'refresh_token', | ||
951 | + scope: 'global_access:tenant_admin,tenant:' + data[0].id, | ||
952 | + refresh_token: passport.user.refreshToken | ||
953 | + } | ||
954 | + passport.user.token = ''; | ||
955 | + logger.debug("Third login tokens", settings.restful.url + 'uaa/v1/auth/tokens', params); | ||
956 | + rest.restful.postJson(settings.restful.url + 'uaa/v1/auth/tokens', params, { | ||
957 | + headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req) | ||
958 | + }) | ||
959 | + .on('success', function (data2, response) { | ||
960 | + logger.debug("Third login json data2:", data2); | ||
961 | + if (data2.access_token) { | ||
962 | + var scopes = data2.scope.split(","); | ||
963 | + passport.user.token = data2.access_token; | ||
964 | + passport.user.refreshToken = data2.refresh_token; | ||
965 | + passport.user.user_info = data2.user || {}; | ||
966 | + passport.user.tenant_info = data2.tenant; | ||
967 | + passport.user.customer_info = data2.customer; | ||
968 | + passport.user.user_info.perms = data2.perms; | ||
969 | + passport.user.type = data2.user.type; | ||
970 | + passport.user.real_auth_status = data2.user.real_auth_status; | ||
971 | + passport.user.credential_status = data2.user.credential_status; | ||
972 | + passport.user.user_info.scope = scopes[0]; | ||
973 | + passport.user.user_info.tenant = data2.tenant; | ||
974 | + passport.user.user_info.user = { | ||
975 | + credential_status: data2.credential_status, | ||
976 | + id: data2.id, | ||
977 | + is_root: data2.is_root, | ||
978 | + mobile: data2.mobile, | ||
979 | + name: data2.name, | ||
980 | + real_auth_status: data2.real_auth_status, | ||
981 | + status: data2.status, | ||
982 | + type: data2.type, | ||
983 | + wx_open_id: data2.wx_open_id | ||
984 | + }; | ||
985 | + callback(null, data2) | ||
986 | + } else { | ||
987 | + var err = new Error('Third login err'); | ||
988 | + passport.user.err = data2.message; | ||
989 | + callback(err, data2); | ||
990 | + } | ||
991 | + rest.proxyLog(data2,response,req,{headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':params,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
992 | + }).on('error', function (err, response) { | ||
993 | + logger.debug("Third login error", err); | ||
994 | + var err = new Error('Third login err'); | ||
995 | + callback(err, response); | ||
996 | + rest.proxyLog(err,response,req,{headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':params,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
997 | + }).on('fail', function (data2, response) { | ||
998 | + logger.debug("Third login fail", data2); | ||
999 | + var err = new Error('Third login err'); | ||
1000 | + callback(data2, response); | ||
1001 | + rest.proxyLog(data2,response,req,{headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':params,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
1002 | + }); | ||
1003 | + } else if (data && data.length > 1) {// #/login/choose-tenant | ||
1004 | + callback(null, data) | ||
1005 | + } else { | ||
1006 | + var err = new Error('Third login tenants list item error'); | ||
1007 | + callback(err, data); | ||
1008 | + } | ||
1009 | + }], function (err, result) { | ||
1010 | + if (err) {//登陆失败跳转失败页 | ||
1011 | + res.render('loginerr', { 'err': err }); | ||
1012 | + } else if (result instanceof Array && result.length > 1) {//登陆成功跳转选择机构页 | ||
1013 | + req.session.passport = passport; | ||
1014 | + req.session.save(function (err) { | ||
1015 | + res.redirect(301, settings.prefix + '#login/choose-tenant'); | ||
1016 | + }); | ||
1017 | + } else { | ||
1018 | + req.session.passport = passport; | ||
1019 | + req.session.save(function (err) { | ||
1020 | + rest.get({ | ||
1021 | + 'baseUrl': 'url', | ||
1022 | + 'url': settings.restful.url + 'uaa' + settings.restful.version + '/perms/detail', | ||
1023 | + 'useUrl': true, | ||
1024 | + 'params': {}, | ||
1025 | + 'callback': _scb, | ||
1026 | + 'req': req, | ||
1027 | + 'res': res, | ||
1028 | + 'options': {} | ||
1029 | + }); | ||
1030 | + }); | ||
1031 | + function _scb(data1, response) { | ||
1032 | + if (response.statusCode < 300 && data1.items) { | ||
1033 | + req.session.passport.user.user_info.perms = data1.items; | ||
1034 | + req.session.save(function (err) { | ||
1035 | + if (params.redirect_page) { | ||
1036 | + res.redirect(301, settings.prefix + '#' + params.redirect_page); //登陆成功跳转首页 | ||
1037 | + } else { | ||
1038 | + res.redirect(301, settings.prefix + '#container/home'); //登陆成功跳转首页 | ||
1039 | + } | ||
1040 | + }) | ||
1041 | + } else { | ||
1042 | + if (params.redirect_page) { | ||
1043 | + res.redirect(301, settings.prefix + '#' + params.redirect_page); //登陆成功跳转首页 | ||
1044 | + } else { | ||
1045 | + res.redirect(301, settings.prefix + '#container/home'); //登陆成功跳转首页 | ||
1046 | + } | ||
1047 | + } | ||
1048 | + } | ||
1049 | + } | ||
1050 | + }); | ||
1051 | + } | ||
1052 | + | ||
1053 | + } | ||
1054 | + | ||
1055 | + function getTastLink(req, res, next) { | ||
1056 | + var url = crypto.createHash('md5').update(req.body.id).digest('hex'); | ||
1057 | + if (settings.prefix && settings.prefix.length > 1) { | ||
1058 | + res.send(req.protocol + '://' + req.get('host') + settings.prefix.substring(0, settings.prefix.length - 1) + "/socialwork/freedom-jobs/emps/" + req.body.id + "/" + url); | ||
1059 | + } else { | ||
1060 | + res.send({ 'url': req.protocol + '://' + req.get('host') + "/socialwork/freedom-jobs/emps/" + req.body.id + "/" + url }); | ||
1061 | + } | ||
1062 | + } | ||
1063 | + | ||
1064 | + function freedomJobsEmp(req, res, next) { | ||
1065 | + var id = req.params.id; | ||
1066 | + var verification = req.params.verification; | ||
1067 | + // var url = crypto.createHash('md5').update(id).digest('hex'); | ||
1068 | + if (false) {//验证未通过verification != url | ||
1069 | + if (settings.prefix && settings.prefix.length > 1) { | ||
1070 | + res.redirect(settings.prefix.substring(0, settings.prefix.length - 1)); | ||
1071 | + } else { | ||
1072 | + res.redirect('/'); | ||
1073 | + } | ||
1074 | + } else {//验证通过跳转,获取token存到session里 | ||
1075 | + var passport = { | ||
1076 | + user: { | ||
1077 | + refreshToken: "", | ||
1078 | + token: "", | ||
1079 | + service_catalog: {}, | ||
1080 | + user_info: {}, | ||
1081 | + err: null | ||
1082 | + } | ||
1083 | + }; | ||
1084 | + var tempParams = { | ||
1085 | + "grant_type": "client_credential", | ||
1086 | + "client_id": "340161778618994688",//多宝鱼环境 | ||
1087 | + "client_secret": "0f8c30aa3d15332652f62c3eaf22fdea" | ||
1088 | + }; | ||
1089 | + rest.restful.postJson(settings.restful.url + 'uaa/v1/auth/tokens', tempParams, { | ||
1090 | + headers:rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req) | ||
1091 | + }).on('success', function (data, response) { | ||
1092 | + if (data.access_token) { | ||
1093 | + var scopes = data.scope.split(","); | ||
1094 | + passport.user.token = data.access_token; | ||
1095 | + passport.user.refreshToken = data.refresh_token; | ||
1096 | + passport.user.user_info = data.user; | ||
1097 | + passport.user.tenant_info = data.tenant; | ||
1098 | + passport.user.customer_info = data.customer; | ||
1099 | + passport.user.user_info.perms = data.perms; | ||
1100 | + passport.user.type = data.user.type; | ||
1101 | + passport.user.real_auth_status = data.user.real_auth_status; | ||
1102 | + passport.user.credential_status = data.user.credential_status; | ||
1103 | + passport.user.user_info.scope = scopes[0]; | ||
1104 | + req.session.passport = passport; | ||
1105 | + req.session.save(function (err) { | ||
1106 | + if (settings.prefix && settings.prefix.length > 1) { | ||
1107 | + res.redirect(301, settings.prefix.substring(0, settings.prefix.length - 1) + '/#task_assign/' + id); | ||
1108 | + } else { | ||
1109 | + res.redirect(301, '/#task_assign/' + id); | ||
1110 | + } | ||
1111 | + }); | ||
1112 | + } else { | ||
1113 | + var err = new Error('Third login err'); | ||
1114 | + passport.user.err = data.message; | ||
1115 | + } | ||
1116 | + rest.proxyLog(data,response,req,{headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':tempParams,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
1117 | + }).on('error', function (err, response) { | ||
1118 | + logger.debug("Third login error", err); | ||
1119 | + var err = new Error('Third login err'); | ||
1120 | + callback(err, response); | ||
1121 | + rest.proxyLog(err,response,req,{headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':tempParams,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
1122 | + }).on('fail', function (data, response) { | ||
1123 | + logger.debug("Third login fail", data); | ||
1124 | + var err = new Error('Third login err'); | ||
1125 | + rest.proxyLog(err,response,req,{headers: rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req),'data':tempParams,url:settings.restful.url + 'uaa/v1/auth/tokens'}) | ||
1126 | + }); | ||
1127 | + } | ||
1128 | + | ||
1129 | + } | ||
1130 | + | ||
1131 | + function getShortToken(req, res, next) { | ||
1132 | + var params = { | ||
1133 | + grant_type: 'refresh_token', | ||
1134 | + scope: req.session.passport.user.scope, | ||
1135 | + refresh_token: req.session.passport.user.refreshToken | ||
1136 | + } | ||
1137 | + logger.debug("getShortToken:", params); | ||
1138 | + rest.postJson({ | ||
1139 | + 'baseUrl': 'url', | ||
1140 | + 'url': settings.restful.url + 'uaa' + settings.restful.version + '/auth/tokens', | ||
1141 | + 'useUrl': true, | ||
1142 | + 'params': params, | ||
1143 | + 'callback': _cb, | ||
1144 | + 'req': req, | ||
1145 | + 'res': res, | ||
1146 | + 'options': {}, | ||
1147 | + 'excludeToken': true | ||
1148 | + }) | ||
1149 | + function _cb(data, response) { | ||
1150 | + logger.debug("back data:", data); | ||
1151 | + res.send({ "code": response.statusCode, "access_token": data.access_token }); | ||
1152 | + }; | ||
1153 | + } | ||
1154 | + | ||
1155 | + function loadYxlyToken(req, res) { | ||
1156 | + let hroToken = ''; | ||
1157 | + if (req.session.passport && req.session.passport.user && req.session.passport.user && req.session.passport.user.token) { | ||
1158 | + hroToken = req.session.passport.user.token; | ||
1159 | + } | ||
1160 | + let params = { | ||
1161 | + way: 'tenant', | ||
1162 | + tenantToken: hroToken, | ||
1163 | + }; | ||
1164 | + | ||
1165 | + rest.postJson({ | ||
1166 | + 'baseUrl': 'url', | ||
1167 | + 'url': settings.excellentRestful.url + 'auth' + settings.excellentRestful.version + '/login', | ||
1168 | + 'useUrl': true, | ||
1169 | + 'params': params, | ||
1170 | + 'callback': _cb, | ||
1171 | + 'req': req, | ||
1172 | + 'res': res, | ||
1173 | + 'options': {}, | ||
1174 | + 'headers': { | ||
1175 | + "Accept": "application/json", | ||
1176 | + "Content-Type": "application/json", | ||
1177 | + 'User-Agent': 'Request for Express', | ||
1178 | + 'Authorization': 'Basic d29ya2FpOjEyMzQ1Ng==' | ||
1179 | + }, | ||
1180 | + 'excludeToken': true | ||
1181 | + }); | ||
1182 | + | ||
1183 | + function _cb(result, response) { | ||
1184 | + | ||
1185 | + if (response.statusCode < 300 && result && result.data) { | ||
1186 | + let key = `${req.session.passport.user.user_info.user.id}_yxly_token`; | ||
1187 | + redis.set(key, result.data.access_token); | ||
1188 | + logger.debug("loadYxlyToken......", key, result.data.access_token); | ||
1189 | + } else { | ||
1190 | + // res.send({ "code": 200, "message": "切换租户失败" }); | ||
1191 | + } | ||
1192 | + } | ||
1193 | + } | ||
1194 | + | ||
1195 | + function redirectContract(req, res) { | ||
1196 | + logger.warn("00000000000......",req.path); | ||
1197 | + let deviceArray = ['android', 'Android', 'iPhone', 'windows phone']; | ||
1198 | + let userAgent = req.headers['user-agent']; | ||
1199 | + logger.warn("user-agent......", userAgent); | ||
1200 | + | ||
1201 | + let isMobile = false; | ||
1202 | + deviceArray.map((item, index) => { | ||
1203 | + if (userAgent.indexOf(item) > 0) { | ||
1204 | + isMobile = true; | ||
1205 | + } | ||
1206 | + }) | ||
1207 | + | ||
1208 | + logger.warn("isMobile......", isMobile); | ||
1209 | + logger.warn("req.session......", req.session); | ||
1210 | + | ||
1211 | + if (isMobile) { | ||
1212 | + logger.warn("44444444......", settings.restful); | ||
1213 | + logger.warn("req.query......", req.query); | ||
1214 | + | ||
1215 | + return res.redirect(301, `${settings.restful.redirectMobileUrl}?state=contracts&code=${req.query.code}&scope=${req.query.scope}`); | ||
1216 | + | ||
1217 | + | ||
1218 | + } else { | ||
1219 | + | ||
1220 | + // return res.redirect(`/#/main/labor-contract/manage`); | ||
1221 | + return res.redirect(`https://www.baidu.com`); | ||
1222 | + | ||
1223 | + // logger.warn("req.session......", req.session); | ||
1224 | + // if(req.session.passport && req.session.passport.user && req.session.passport.user.user_info && req.session.passport.user.user_info.user) { | ||
1225 | + // logger.warn("11111111......"); | ||
1226 | + // return res.redirect(`/#/main/labor-contract/manage`); | ||
1227 | + // } else { | ||
1228 | + // logger.warn("22222222......"); | ||
1229 | + // return res.redirect(`/#/`); | ||
1230 | + // } | ||
1231 | + } | ||
1232 | + } | ||
1233 | + | ||
1234 | + return { | ||
1235 | + refreshToken:refreshToken, | ||
1236 | + index: index, | ||
1237 | + indexPrefix, | ||
1238 | + register: register, | ||
1239 | + signIn: signIn, | ||
1240 | + doLogin: doLogin, | ||
1241 | + signOut: signOut, | ||
1242 | + smsCodes: smsCodes, | ||
1243 | + tenants: tenants, | ||
1244 | + productDes: productDes, | ||
1245 | + resetPass: resetPass, | ||
1246 | + updatePassword: updatePassword, | ||
1247 | + loadUserInfo: loadUserInfo, | ||
1248 | + getUploaderToken: getUploaderToken, | ||
1249 | + getObjectTokenByID, | ||
1250 | + delOSSObject: delOSSObject, | ||
1251 | + healthMonitor, | ||
1252 | + smsVerification, | ||
1253 | + updateUserRoles, | ||
1254 | + getRoles, | ||
1255 | + getUserRoles, | ||
1256 | + getTenant, | ||
1257 | + updateTenant, | ||
1258 | + offer, | ||
1259 | + onboardStatus, | ||
1260 | + dowloadApp, | ||
1261 | + mobileRegister, | ||
1262 | + mobileRegisterSuccess, | ||
1263 | + softwareLicense, | ||
1264 | + recharge, | ||
1265 | + changePassForRegister, | ||
1266 | + changeTenant, | ||
1267 | + sendRejectOffer, | ||
1268 | + acceptOffer, | ||
1269 | + imTokens, | ||
1270 | + listChannels, | ||
1271 | + filemeta, | ||
1272 | + getCustomerQrcode, | ||
1273 | + getPositionQrcode, | ||
1274 | + getOSSConfig, | ||
1275 | + weidianTempLate, | ||
1276 | + workaiSecurityOAuth, | ||
1277 | + getTastLink, | ||
1278 | + freedomJobsEmp, | ||
1279 | + getShortToken, | ||
1280 | + loadYxlyToken, | ||
1281 | + redirectContract, | ||
1282 | + }; | ||
1236 | }; | 1283 | }; |
1237 | 1284 | ||
1238 | -exports["@singleton"] = true; | ||
1239 | -exports["@require"] = ["igloo/logger", "utils/rest", "igloo/settings"]; | 1285 | +exports['@singleton'] = true; |
1286 | +exports['@require'] = ['igloo/logger', 'utils/rest', 'utils/redis', 'igloo/settings']; |
@@ -13,7 +13,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -13,7 +13,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
13 | var tempParam=param.split("=") | 13 | var tempParam=param.split("=") |
14 | tempParam[1]=urlencode.decode(tempParam[1], 'utf8'); | 14 | tempParam[1]=urlencode.decode(tempParam[1], 'utf8'); |
15 | tempParam[1]=tempParam[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | 15 | tempParam[1]=tempParam[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); |
16 | - console.log(tempParam[1]); | 16 | + logger.debug(tempParam[1]); |
17 | if(i<(params.length-1)){ | 17 | if(i<(params.length-1)){ |
18 | if(/[:&+/?%#=]/g.test(tempParam[1])){ | 18 | if(/[:&+/?%#=]/g.test(tempParam[1])){ |
19 | temp.push(tempParam[0]+"="+encodeUrl(tempParam[1])+"&"); | 19 | temp.push(tempParam[0]+"="+encodeUrl(tempParam[1])+"&"); |
@@ -65,7 +65,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -65,7 +65,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
65 | 65 | ||
66 | function searchService(services,name){ | 66 | function searchService(services,name){ |
67 | if(services[name]){ | 67 | if(services[name]){ |
68 | - console.log(services[name]); | 68 | + logger.debug(services[name]); |
69 | return false; | 69 | return false; |
70 | }else{ | 70 | }else{ |
71 | return true; | 71 | return true; |
@@ -124,7 +124,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -124,7 +124,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
124 | rest.get(options); | 124 | rest.get(options); |
125 | } | 125 | } |
126 | function _cb(data,response){ | 126 | function _cb(data,response){ |
127 | - logger.info('back data:',data); | 127 | + logger.debug('back data:',data); |
128 | if(response.statusCode<300&&!data){ | 128 | if(response.statusCode<300&&!data){ |
129 | res.send({ | 129 | res.send({ |
130 | code:200, | 130 | code:200, |
@@ -158,7 +158,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -158,7 +158,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
158 | } | 158 | } |
159 | } | 159 | } |
160 | function _cb(data,response){ | 160 | function _cb(data,response){ |
161 | - logger.info('back data:',data); | 161 | + logger.debug('back data:',data); |
162 | if(response.statusCode<300&&!data){ | 162 | if(response.statusCode<300&&!data){ |
163 | res.send({ | 163 | res.send({ |
164 | code:200, | 164 | code:200, |
@@ -192,7 +192,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -192,7 +192,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
192 | } | 192 | } |
193 | } | 193 | } |
194 | function _cb(data,response){ | 194 | function _cb(data,response){ |
195 | - logger.info('back data:',data); | 195 | + logger.debug('back data:',data); |
196 | if(response.statusCode<300&&!data){ | 196 | if(response.statusCode<300&&!data){ |
197 | res.send({ | 197 | res.send({ |
198 | code:200, | 198 | code:200, |
@@ -226,7 +226,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -226,7 +226,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
226 | } | 226 | } |
227 | } | 227 | } |
228 | function _cb(data,response){ | 228 | function _cb(data,response){ |
229 | - logger.info('back data:',data); | 229 | + logger.debug('back data:',data); |
230 | res.send(data); | 230 | res.send(data); |
231 | } | 231 | } |
232 | } | 232 | } |
@@ -249,7 +249,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -249,7 +249,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
249 | rest.get(options); | 249 | rest.get(options); |
250 | } | 250 | } |
251 | function _cb(data,response){ | 251 | function _cb(data,response){ |
252 | - logger.info('back data:',data); | 252 | + logger.debug('back data:',data); |
253 | res.send(data); | 253 | res.send(data); |
254 | } | 254 | } |
255 | } | 255 | } |
@@ -272,7 +272,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -272,7 +272,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
272 | rest.del(options); | 272 | rest.del(options); |
273 | } | 273 | } |
274 | function _cb(data,response){ | 274 | function _cb(data,response){ |
275 | - logger.info('back data:',data); | 275 | + logger.debug('back data:',data); |
276 | if(response.statusCode<300){ | 276 | if(response.statusCode<300){ |
277 | res.send({'action':'delete',"message":"删除成功"}); | 277 | res.send({'action':'delete',"message":"删除成功"}); |
278 | }else{ | 278 | }else{ |
controllers/config.js
0 → 100644
1 | +exports = module.exports = function (logger, settings) { | ||
2 | + function getHost(req, res, next) { | ||
3 | + logger.info('getHost'); | ||
4 | + const { hostConfig } = settings; | ||
5 | + return res.send({ | ||
6 | + data: hostConfig, | ||
7 | + }); | ||
8 | + } | ||
9 | + | ||
10 | + return { | ||
11 | + getHost, | ||
12 | + }; | ||
13 | + }; | ||
14 | + | ||
15 | + exports["@singleton"] = true; | ||
16 | + exports["@require"] = ["igloo/logger", "igloo/settings"]; | ||
17 | + |
controllers/excellent.js
0 → 100644
1 | +var urlencode = require('urlencode'); | ||
2 | + | ||
3 | +exports = module.exports = function (logger, rest, redis, settings) { | ||
4 | + function getOptions(url, type) { | ||
5 | + var catalog = url.substring(1, url.indexOf('/', 1)); | ||
6 | + var pathUrl = url.substring(url.indexOf('/', 1)); | ||
7 | + var fullPath = '/' + catalog + settings.excellentRestful.version + pathUrl; | ||
8 | + return { | ||
9 | + 'host': settings.excellentRestful.host, //后台请求地址 | ||
10 | + 'port': settings.excellentRestful.port, | ||
11 | + 'path': fullPath, | ||
12 | + 'method': type, | ||
13 | + 'agent': false, | ||
14 | + 'headers': { | ||
15 | + "Accept": "application/json", | ||
16 | + "Content-Type": "application/json", | ||
17 | + 'Proxy-User-Agent': 'Request for Express' | ||
18 | + } | ||
19 | + }; | ||
20 | + } | ||
21 | + | ||
22 | + async function addToken(options, req) { | ||
23 | + if (req.session.passport && req.session.passport.user && req.session.passport.user && req.session.passport.user.user_info) { | ||
24 | + const yxly_token = await redis.get(`${req.session.passport.user.user_info.user.id}_yxly_token`) | ||
25 | + if (yxly_token) { | ||
26 | + options.headers['Authorization'] = yxly_token ? `Bearer ${yxly_token}` : ''; | ||
27 | + } | ||
28 | + } | ||
29 | + | ||
30 | + if (req.headers['device-id']) { | ||
31 | + options.headers['Device-Id'] = req.headers['device-id'] | ||
32 | + } | ||
33 | + if (req.ip) { | ||
34 | + options.headers['Client-Ip'] = req.ip | ||
35 | + } | ||
36 | + if (req.headers['x-request-id']) { | ||
37 | + options.headers['X-Request-Id'] = req.headers['x-request-id'] | ||
38 | + } | ||
39 | + if(req.headers['user-agent'] ){ | ||
40 | + options.headers['User-Agent'] = req.headers['user-agent'] | ||
41 | + } | ||
42 | + | ||
43 | + return options; | ||
44 | + } | ||
45 | + | ||
46 | + function addReqResOptions(options, req,res){ | ||
47 | + options['req']=req; | ||
48 | + options['res']=res; | ||
49 | + return options; | ||
50 | + } | ||
51 | + | ||
52 | + function addParams(options, req) { | ||
53 | + var postData = !req.body ? '' : JSON.stringify(req.body || {}); | ||
54 | + // options.headers['Content-Length'] = postData.length; | ||
55 | + options.params = postData; | ||
56 | + } | ||
57 | + | ||
58 | + function addContentLength(options) { | ||
59 | + if (options.params) { | ||
60 | + options.headers['Content-Length'] = options.params.length; | ||
61 | + } | ||
62 | + } | ||
63 | + | ||
64 | + function encodeUrl(url) { | ||
65 | + return urlencode(url); | ||
66 | + } | ||
67 | + | ||
68 | + function encodePamars(params) { | ||
69 | + var temp = []; | ||
70 | + for (var i = 0; i < params.length; i++) { | ||
71 | + var param = params[i]; | ||
72 | + var tempParam = param.split("=") | ||
73 | + tempParam[1] = urlencode.decode(tempParam[1], 'utf8'); | ||
74 | + tempParam[1] = tempParam[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | ||
75 | + | ||
76 | + if (i < (params.length - 1)) { | ||
77 | + if (/[:&+/?%#=]/g.test(tempParam[1])) { | ||
78 | + temp.push(tempParam[0] + "=" + encodeUrl(tempParam[1]) + "&"); | ||
79 | + } else { | ||
80 | + temp.push(tempParam[0] + "=" + tempParam[1] + "&"); | ||
81 | + } | ||
82 | + } else { | ||
83 | + if (/[:&+/?%#=]/g.test(tempParam[1])) { | ||
84 | + temp.push(tempParam[0] + "=" + encodeUrl(tempParam[1])); | ||
85 | + } else { | ||
86 | + temp.push(tempParam[0] + "=" + tempParam[1]); | ||
87 | + } | ||
88 | + } | ||
89 | + } | ||
90 | + return temp.join(""); | ||
91 | + } | ||
92 | + | ||
93 | + function handlePamars(url) { | ||
94 | + var tempUrl = url; | ||
95 | + // if(url.indexOf("?")!=-1){ | ||
96 | + // var temp=url.split("?"); | ||
97 | + // var params=""; | ||
98 | + // if(temp[1]&&temp[1].indexOf("&")!=-1){ | ||
99 | + // params=encodePamars(temp[1].split("&")); | ||
100 | + // }else{ | ||
101 | + // params=encodePamars([temp[1]]); | ||
102 | + // } | ||
103 | + // return temp[0]+"?"+params; | ||
104 | + // }else { | ||
105 | + // return tempUrl; | ||
106 | + // } | ||
107 | + return tempUrl; | ||
108 | + } | ||
109 | + | ||
110 | + function splitServiceFromUrl(url) { | ||
111 | + var catalog = url.substring(1, url.indexOf('/', 1)); | ||
112 | + var pathUrl = url.substring(url.indexOf('/', 1)); | ||
113 | + var fullPath = settings.restful.url + catalog + settings.restful.version + pathUrl; | ||
114 | + return fullPath | ||
115 | + } | ||
116 | + | ||
117 | + function splitUrl(fullUrl) { | ||
118 | + if (settings.prefix && settings.prefix.length > 1) { | ||
119 | + fullUrl = fullUrl.substring(settings.prefix.length - 1); | ||
120 | + } | ||
121 | + var url = fullUrl.substring(fullUrl.indexOf('/', 1)); | ||
122 | + return url; | ||
123 | + } | ||
124 | + | ||
125 | + function searchService(services, name) { | ||
126 | + if (services[name]) { | ||
127 | + | ||
128 | + return false; | ||
129 | + } else { | ||
130 | + return true; | ||
131 | + } | ||
132 | + } | ||
133 | + | ||
134 | + function checkReq(req, res) { | ||
135 | + var flag = true; | ||
136 | + // if(flag&&req.headers&&!req.headers['service-catalog']){ | ||
137 | + // res.status(400); | ||
138 | + // res.send({"errors":{},"message":"缺少必要请求参数,服务目录名称是必填项"}); | ||
139 | + // flag=false; | ||
140 | + // } | ||
141 | + // if(flag&&req.session.passport&&req.session.passport.user&&!req.session.passport.user.service_catalog){ | ||
142 | + // res.status(404); | ||
143 | + // res.send({"errors":{},"message":"服务目录未加载,请重新登录"}); | ||
144 | + // flag=false; | ||
145 | + // } | ||
146 | + // if(flag&&searchService(req.session.passport.user.service_catalog,req.headers['service-catalog'])){ | ||
147 | + // res.status(404); | ||
148 | + // res.send({"errors":{},"message":"服务目录未查询到请求服务,请确认参数正确"}); | ||
149 | + // flag=false; | ||
150 | + // } | ||
151 | + return flag; | ||
152 | + } | ||
153 | + | ||
154 | + function checkJson(req) { | ||
155 | + if (req.headers && req.headers['content-type'] == 'application/json') { | ||
156 | + return true; | ||
157 | + } else { | ||
158 | + return false; | ||
159 | + } | ||
160 | + } | ||
161 | + | ||
162 | + async function get(req, res, next) { | ||
163 | + var url = splitUrl(req.originalUrl); | ||
164 | + var options = getOptions(url, 'GET'); | ||
165 | + await addToken(options, req); | ||
166 | + addReqResOptions(options, req,res); | ||
167 | + function _success(data, response) { | ||
168 | + if (response.statusCode >= 400 || !data) { | ||
169 | + logger.debug(options, data); | ||
170 | + res.status(response.statusCode); | ||
171 | + res.send(data); | ||
172 | + } else { | ||
173 | + res.send(data); | ||
174 | + } | ||
175 | + } | ||
176 | + function _fail(err) { | ||
177 | + logger.debug(options, err); | ||
178 | + res.send(err); | ||
179 | + } | ||
180 | + rest.restClient(options, _success, _fail); | ||
181 | + } | ||
182 | + | ||
183 | + async function post(req, res, next) { | ||
184 | + var url = splitUrl(req.originalUrl); | ||
185 | + var options = getOptions(url, 'POST'); | ||
186 | + await addToken(options, req); | ||
187 | + addReqResOptions(options, req,res); | ||
188 | + addParams(options, req); | ||
189 | + function _success(data, response) { | ||
190 | + if (response.statusCode >= 400) { | ||
191 | + logger.debug(options, data); | ||
192 | + res.status(response.statusCode); | ||
193 | + res.send(data); | ||
194 | + } else if (!data || 'null' == data || "null\n" == data || '{}' == data) { | ||
195 | + res.send({ | ||
196 | + code: 200, | ||
197 | + message: '操作成功!' | ||
198 | + }); | ||
199 | + } else { | ||
200 | + res.send(data); | ||
201 | + } | ||
202 | + } | ||
203 | + function _fail(err) { | ||
204 | + logger.debug(options, err); | ||
205 | + res.send(err); | ||
206 | + } | ||
207 | + rest.restClient(options, _success, _fail); | ||
208 | + } | ||
209 | + | ||
210 | + async function put(req, res, next) { | ||
211 | + var url = splitUrl(req.originalUrl); | ||
212 | + var options = getOptions(url, 'PUT'); | ||
213 | + await addToken(options, req); | ||
214 | + addReqResOptions(options, req,res); | ||
215 | + addParams(options, req); | ||
216 | + function _success(data, response) { | ||
217 | + if (response.statusCode >= 400) { | ||
218 | + logger.debug(options, data); | ||
219 | + res.status(response.statusCode); | ||
220 | + res.send(data); | ||
221 | + } else if (!data || 'null' == data || "null\n" == data || '{}' == data) { | ||
222 | + res.send({ | ||
223 | + code: 200, | ||
224 | + message: '操作成功!' | ||
225 | + }); | ||
226 | + } else { | ||
227 | + res.send(data); | ||
228 | + } | ||
229 | + } | ||
230 | + function _fail(err) { | ||
231 | + logger.debug(options, err); | ||
232 | + res.send(err); | ||
233 | + } | ||
234 | + rest.restClient(options, _success, _fail); | ||
235 | + } | ||
236 | + | ||
237 | + async function patch(req, res, next) { | ||
238 | + var url = splitUrl(req.originalUrl); | ||
239 | + var options = getOptions(url, 'PATCH'); | ||
240 | + await addToken(options, req); | ||
241 | + addReqResOptions(options, req,res); | ||
242 | + addParams(options, req); | ||
243 | + function _success(data, response) { | ||
244 | + if (response.statusCode >= 400) { | ||
245 | + logger.debug(options, data); | ||
246 | + res.send(data); | ||
247 | + } else if (!data) { | ||
248 | + res.send({ | ||
249 | + code: 200, | ||
250 | + message: '操作成功!' | ||
251 | + }); | ||
252 | + } else { | ||
253 | + res.send(data); | ||
254 | + } | ||
255 | + } | ||
256 | + function _fail(err) { | ||
257 | + logger.debug(options, err); | ||
258 | + res.send(err); | ||
259 | + } | ||
260 | + rest.restClient(options, _success, _fail); | ||
261 | + } | ||
262 | + | ||
263 | + async function head(req, res, next) { | ||
264 | + var url = splitUrl(req.originalUrl); | ||
265 | + var options = getOptions(url, 'HEAD'); | ||
266 | + await addToken(options, req); | ||
267 | + addReqResOptions(options, req,res); | ||
268 | + addParams(options, req); | ||
269 | + function _success(data, response) { | ||
270 | + if (response.statusCode >= 400) { | ||
271 | + logger.debug(options, data); | ||
272 | + res.send(data); | ||
273 | + } else if (!data) { | ||
274 | + res.send({ | ||
275 | + code: 200, | ||
276 | + message: '操作成功!' | ||
277 | + }); | ||
278 | + } else { | ||
279 | + res.send(data); | ||
280 | + } | ||
281 | + } | ||
282 | + function _fail(err) { | ||
283 | + logger.debug(options, err); | ||
284 | + res.send(err); | ||
285 | + } | ||
286 | + rest.restClient(options, _success, _fail); | ||
287 | + } | ||
288 | + | ||
289 | + async function del(req, res, next) { | ||
290 | + var url = splitUrl(req.originalUrl); | ||
291 | + var options = getOptions(url, 'DELETE'); | ||
292 | + await addToken(options, req); | ||
293 | + addReqResOptions(options, req,res); | ||
294 | + addParams(options, req); | ||
295 | + addContentLength(options); | ||
296 | + function _success(data, response) { | ||
297 | + if (response.statusCode >= 400) { | ||
298 | + logger.debug(options, data); | ||
299 | + res.status(response.statusCode); | ||
300 | + res.send(data); | ||
301 | + } else if (!data || (data && !data.message)) { | ||
302 | + res.send({ | ||
303 | + code: 200, | ||
304 | + action: "delete", | ||
305 | + message: '删除成功' | ||
306 | + }); | ||
307 | + } else { | ||
308 | + res.send(data); | ||
309 | + } | ||
310 | + } | ||
311 | + function _fail(err) { | ||
312 | + logger.debug(options, err); | ||
313 | + res.send(err); | ||
314 | + } | ||
315 | + rest.restClient(options, _success, _fail); | ||
316 | + } | ||
317 | + | ||
318 | + return { | ||
319 | + 'get': get, | ||
320 | + 'post': post, | ||
321 | + 'put': put, | ||
322 | + 'patch': patch, | ||
323 | + 'head': head, | ||
324 | + 'delete': del | ||
325 | + }; | ||
326 | +}; | ||
327 | + | ||
328 | +exports['@singleton'] = true; | ||
329 | +exports['@require'] = ['igloo/logger', 'utils/rest', 'utils/redis', 'igloo/settings']; |
@@ -11,7 +11,6 @@ exports=module.exports=function(logger,rest,settings){ | @@ -11,7 +11,6 @@ exports=module.exports=function(logger,rest,settings){ | ||
11 | var tempParam=param.split("=") | 11 | var tempParam=param.split("=") |
12 | tempParam[1]=urlencode.decode(tempParam[1], 'utf8'); | 12 | tempParam[1]=urlencode.decode(tempParam[1], 'utf8'); |
13 | tempParam[1]=tempParam[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | 13 | tempParam[1]=tempParam[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); |
14 | - console.log(tempParam[1]); | ||
15 | if(i<(params.length-1)){ | 14 | if(i<(params.length-1)){ |
16 | if(/[:&+/?%#=]/g.test(tempParam[1])){ | 15 | if(/[:&+/?%#=]/g.test(tempParam[1])){ |
17 | temp.push(tempParam[0]+"="+encodeUrl(tempParam[1])+"&"); | 16 | temp.push(tempParam[0]+"="+encodeUrl(tempParam[1])+"&"); |
@@ -66,7 +65,6 @@ exports=module.exports=function(logger,rest,settings){ | @@ -66,7 +65,6 @@ exports=module.exports=function(logger,rest,settings){ | ||
66 | 65 | ||
67 | function searchService(services,name){ | 66 | function searchService(services,name){ |
68 | if(services[name]){ | 67 | if(services[name]){ |
69 | - console.log(services[name]); | ||
70 | return false; | 68 | return false; |
71 | }else{ | 69 | }else{ |
72 | return true; | 70 | return true; |
@@ -119,7 +117,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -119,7 +117,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
119 | rest.get(options); | 117 | rest.get(options); |
120 | } | 118 | } |
121 | function _cb(data,response){ | 119 | function _cb(data,response){ |
122 | - logger.info('back data:',data); | 120 | + logger.debug('back data:',data); |
123 | if(response.statusCode<300&&!data){ | 121 | if(response.statusCode<300&&!data){ |
124 | res.send({ | 122 | res.send({ |
125 | code:200, | 123 | code:200, |
@@ -152,7 +150,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -152,7 +150,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
152 | } | 150 | } |
153 | } | 151 | } |
154 | function _cb(data,response){ | 152 | function _cb(data,response){ |
155 | - logger.info('back data:',data); | 153 | + logger.debug('back data:',data); |
156 | if(response.statusCode<300&&!data){ | 154 | if(response.statusCode<300&&!data){ |
157 | res.send({ | 155 | res.send({ |
158 | code:200, | 156 | code:200, |
@@ -185,7 +183,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -185,7 +183,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
185 | } | 183 | } |
186 | } | 184 | } |
187 | function _cb(data,response){ | 185 | function _cb(data,response){ |
188 | - logger.info('back data:',data); | 186 | + logger.debug('back data:',data); |
189 | if(response.statusCode<300&&!data){ | 187 | if(response.statusCode<300&&!data){ |
190 | res.send({ | 188 | res.send({ |
191 | code:200, | 189 | code:200, |
@@ -218,7 +216,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -218,7 +216,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
218 | } | 216 | } |
219 | } | 217 | } |
220 | function _cb(data,response){ | 218 | function _cb(data,response){ |
221 | - logger.info('back data:',data); | 219 | + logger.debug('back data:',data); |
222 | res.send(data); | 220 | res.send(data); |
223 | } | 221 | } |
224 | } | 222 | } |
@@ -240,7 +238,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -240,7 +238,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
240 | rest.get(options); | 238 | rest.get(options); |
241 | } | 239 | } |
242 | function _cb(data,response){ | 240 | function _cb(data,response){ |
243 | - logger.info('back data:',data); | 241 | + logger.debug('back data:',data); |
244 | res.send(data); | 242 | res.send(data); |
245 | } | 243 | } |
246 | } | 244 | } |
@@ -262,7 +260,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -262,7 +260,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
262 | rest.del(options); | 260 | rest.del(options); |
263 | } | 261 | } |
264 | function _cb(data,response){ | 262 | function _cb(data,response){ |
265 | - logger.info('back data:',data); | 263 | + logger.debug('back data:',data); |
266 | if(response.statusCode<300){ | 264 | if(response.statusCode<300){ |
267 | res.send({'action':'delete',"message":"删除成功"}); | 265 | res.send({'action':'delete',"message":"删除成功"}); |
268 | }else{ | 266 | }else{ |
@@ -15,32 +15,26 @@ exports=module.exports=function(logger,rest,settings){ | @@ -15,32 +15,26 @@ exports=module.exports=function(logger,rest,settings){ | ||
15 | } | 15 | } |
16 | 16 | ||
17 | function get(req,res,next){ | 17 | function get(req,res,next){ |
18 | - console.log(req.path); | ||
19 | res.send(getJson(req.path,'get')); | 18 | res.send(getJson(req.path,'get')); |
20 | } | 19 | } |
21 | 20 | ||
22 | function post(req,res,next){ | 21 | function post(req,res,next){ |
23 | - console.log(req.path); | ||
24 | res.send(getJson(req.path,'post')); | 22 | res.send(getJson(req.path,'post')); |
25 | } | 23 | } |
26 | 24 | ||
27 | function put(req,res,next){ | 25 | function put(req,res,next){ |
28 | - console.log(req.path); | ||
29 | res.send(getJson(req.path,'put')); | 26 | res.send(getJson(req.path,'put')); |
30 | } | 27 | } |
31 | 28 | ||
32 | function patch(req,res,next){ | 29 | function patch(req,res,next){ |
33 | - console.log(req.path); | ||
34 | res.send(getJson(req.path,'patch')); | 30 | res.send(getJson(req.path,'patch')); |
35 | } | 31 | } |
36 | 32 | ||
37 | function head(req,res,next){ | 33 | function head(req,res,next){ |
38 | - console.log(req.path); | ||
39 | res.send(getJson(req.path,'head')); | 34 | res.send(getJson(req.path,'head')); |
40 | } | 35 | } |
41 | 36 | ||
42 | function del(req,res,next){ | 37 | function del(req,res,next){ |
43 | - console.log(req.path); | ||
44 | res.send(getJson(req.path,'del')); | 38 | res.send(getJson(req.path,'del')); |
45 | } | 39 | } |
46 | 40 |
@@ -4,7 +4,7 @@ exports=module.exports=function(logger,rest,settings){ | @@ -4,7 +4,7 @@ exports=module.exports=function(logger,rest,settings){ | ||
4 | var api_service_endpoint = 'http://47.98.198.227:59000/v1'; | 4 | var api_service_endpoint = 'http://47.98.198.227:59000/v1'; |
5 | 5 | ||
6 | function index(req,res,next){ | 6 | function index(req,res,next){ |
7 | - logger.info(req.user); | 7 | + logger.debug(req.user); |
8 | res.render('robotMobile',{title:'外呼机器人'}); | 8 | res.render('robotMobile',{title:'外呼机器人'}); |
9 | } | 9 | } |
10 | 10 | ||
@@ -30,7 +30,6 @@ exports=module.exports=function(logger,rest,settings){ | @@ -30,7 +30,6 @@ exports=module.exports=function(logger,rest,settings){ | ||
30 | 'excludeToken':true | 30 | 'excludeToken':true |
31 | }); | 31 | }); |
32 | function _cb(data,response){ | 32 | function _cb(data,response){ |
33 | - console.log(data); | ||
34 | res.send(data); | 33 | res.send(data); |
35 | } | 34 | } |
36 | // res.send({ | 35 | // res.send({ |
@@ -59,7 +58,6 @@ exports=module.exports=function(logger,rest,settings){ | @@ -59,7 +58,6 @@ exports=module.exports=function(logger,rest,settings){ | ||
59 | 'excludeToken':true | 58 | 'excludeToken':true |
60 | }); | 59 | }); |
61 | function _cb(data,response){ | 60 | function _cb(data,response){ |
62 | - console.log(data); | ||
63 | res.send(data); | 61 | res.send(data); |
64 | } | 62 | } |
65 | } | 63 | } |
@@ -13,10 +13,10 @@ exports = module.exports = function(IoC, settings) { | @@ -13,10 +13,10 @@ exports = module.exports = function(IoC, settings) { | ||
13 | app.set('env', settings.server.env); | 13 | app.set('env', settings.server.env); |
14 | 14 | ||
15 | // set the default views directory | 15 | // set the default views directory |
16 | - // app.set('views', settings.views.dir); | 16 | + app.set('views', settings.views.dir); |
17 | 17 | ||
18 | // set the default view engine | 18 | // set the default view engine |
19 | - // app.set('view engine', settings.views.engine); | 19 | + app.set('view engine', settings.views.engine); |
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
@@ -30,7 +30,7 @@ exports = module.exports = function(IoC, settings) { | @@ -30,7 +30,7 @@ exports = module.exports = function(IoC, settings) { | ||
30 | if (settings.server.env === 'production') { | 30 | if (settings.server.env === 'production') { |
31 | 31 | ||
32 | // enable view caching | 32 | // enable view caching |
33 | - // app.enable('view cache'); | 33 | + app.enable('view cache'); |
34 | 34 | ||
35 | // compress response data with gzip/deflate | 35 | // compress response data with gzip/deflate |
36 | // this overwrites res.write and res.end functions | 36 | // this overwrites res.write and res.end functions |
@@ -4,11 +4,12 @@ | @@ -4,11 +4,12 @@ | ||
4 | 4 | ||
5 | var serveFavicon = require('serve-favicon'); | 5 | var serveFavicon = require('serve-favicon'); |
6 | var path = require('path'); | 6 | var path = require('path'); |
7 | -var winstonRequestLogger = require('winston-request-logger'); | 7 | +var serveStatic = require('serve-static'); |
8 | +// var winstonRequestLogger = require('winston-request-logger'); | ||
9 | +var requestLogger = require('../../utils/requestLogger'); | ||
8 | var methodOverride = require('method-override'); | 10 | var methodOverride = require('method-override'); |
9 | var bodyParser = require('body-parser'); | 11 | var bodyParser = require('body-parser'); |
10 | var responseTime = require('response-time'); | 12 | var responseTime = require('response-time'); |
11 | -const express = require('express') | ||
12 | // var busboy = require('connect-busboy'); | 13 | // var busboy = require('connect-busboy'); |
13 | 14 | ||
14 | 15 | ||
@@ -25,7 +26,8 @@ exports = module.exports = function (IoC, logger, settings, policies) { | @@ -25,7 +26,8 @@ exports = module.exports = function (IoC, logger, settings, policies) { | ||
25 | 26 | ||
26 | // static server (always keep this first) | 27 | // static server (always keep this first) |
27 | // <http://goo.gl/j2BEl5> | 28 | // <http://goo.gl/j2BEl5> |
28 | - app.use('/', express.static('public')); | 29 | + app.use(serveStatic(settings.publicDir, settings.staticServer)); |
30 | + | ||
29 | // adds X-Response-Time header | 31 | // adds X-Response-Time header |
30 | app.use(responseTime({ | 32 | app.use(responseTime({ |
31 | digits: 5 | 33 | digits: 5 |
@@ -111,10 +113,12 @@ exports = module.exports = function (IoC, logger, settings, policies) { | @@ -111,10 +113,12 @@ exports = module.exports = function (IoC, logger, settings, policies) { | ||
111 | 113 | ||
112 | // winston request logger before everything else | 114 | // winston request logger before everything else |
113 | // but only if it was enabled in settings | 115 | // but only if it was enabled in settings |
114 | - if (settings.logger.requests) { | ||
115 | - app.use(winstonRequestLogger.create(logger)); | ||
116 | - } | 116 | + // if (settings.logger.requests) { |
117 | + // app.use(winstonRequestLogger.create(logger)); | ||
118 | + // } | ||
117 | 119 | ||
120 | + // app.use(requestLogger(logger,settings)); | ||
121 | + | ||
118 | // parse request bodies | 122 | // parse request bodies |
119 | // support _method (PUT in forms etc) | 123 | // support _method (PUT in forms etc) |
120 | app.use( | 124 | app.use( |
@@ -33,7 +33,8 @@ | @@ -33,7 +33,8 @@ | ||
33 | "urlencode": "^1.1.0", | 33 | "urlencode": "^1.1.0", |
34 | "uuid": "^7.0.1", | 34 | "uuid": "^7.0.1", |
35 | "validator": "^5.1.0", | 35 | "validator": "^5.1.0", |
36 | - "winston-request-logger": "^1.0.7" | 36 | + "winston-request-logger": "^1.0.7", |
37 | + "redis": "^4.0.3" | ||
37 | }, | 38 | }, |
38 | "dependencies": {} | 39 | "dependencies": {} |
39 | } | 40 | } |
此 diff 太大无法显示。
1 | +/* | ||
2 | + * @Descripttion: | ||
3 | + * @version: 0.0.0 | ||
4 | + * @Author: genglw | ||
5 | + * @Date: 2022-01-21 15:31:14 | ||
6 | + * @LastEditors: genglw | ||
7 | + * @LastEditTime: 2022-02-10 20:37:04 | ||
8 | + */ | ||
1 | var express = require('express'); | 9 | var express = require('express'); |
2 | 10 | ||
3 | exports = module.exports = function (IoC, policies, settings) { | 11 | exports = module.exports = function (IoC, policies, settings) { |
@@ -42,6 +50,7 @@ exports = module.exports = function (IoC, policies, settings) { | @@ -42,6 +50,7 @@ exports = module.exports = function (IoC, policies, settings) { | ||
42 | ); | 50 | ); |
43 | 51 | ||
44 | app.use(settings.prefix + 'api', router); | 52 | app.use(settings.prefix + 'api', router); |
53 | + | ||
45 | }; | 54 | }; |
46 | 55 | ||
47 | exports['@require'] = ['$container', 'policies', 'igloo/settings']; | 56 | exports['@require'] = ['$container', 'policies', 'igloo/settings']; |
1 | -var express = require("express"); | ||
2 | -var payRoll = require("../json/payRoll.json"); | 1 | +var express = require('express'); |
2 | +var payRoll = require('../json/payRoll.json'); | ||
3 | 3 | ||
4 | exports = module.exports = function (IoC, policies, settings) { | 4 | exports = module.exports = function (IoC, policies, settings) { |
5 | - var app = this; | ||
6 | - var router = express.Router(); | ||
7 | - var router2 = express.Router(); | ||
8 | - var controller = IoC.create("controllers/auth"); | ||
9 | - | ||
10 | - if (settings.prefix.length > 0) { | ||
11 | - // router.get("/index", controller.index); | ||
12 | - router.get("/signOut", controller.signOut); | ||
13 | - } | ||
14 | - | ||
15 | - router.get("/img/*", controller.getImg); | ||
16 | - | ||
17 | - router2.get("/", controller.indexPrefix); | ||
18 | - | ||
19 | - router.get("/productDes", controller.productDes); | ||
20 | - | ||
21 | - router.get("/register", controller.register); | ||
22 | - | ||
23 | - router.get("/mobileRegister", controller.mobileRegister); | ||
24 | - | ||
25 | - router.get("/mobileRegisterSuccess", controller.mobileRegisterSuccess); | ||
26 | - | ||
27 | - router.get("/signIn", controller.signIn); | ||
28 | - | ||
29 | - router.post("/doLogin", controller.doLogin); | ||
30 | - | ||
31 | - router2.get("/signOut", controller.signOut); | ||
32 | - | ||
33 | - router.post("/smsCodes", controller.smsCodes); | ||
34 | - | ||
35 | - router.post("/tenants", controller.tenants); | ||
36 | - | ||
37 | - router.post("/resetPass", policies.ensureLoggedOut(), controller.resetPass); | ||
38 | - | ||
39 | - router.post( | ||
40 | - "/updatePassword", | ||
41 | - policies.ensureLoggedOut(), | ||
42 | - controller.updatePassword | ||
43 | - ); | ||
44 | - | ||
45 | - router.post( | ||
46 | - "/loadUserInfo", | ||
47 | - policies.ensureLoggedOut(), | ||
48 | - controller.loadUserInfo | ||
49 | - ); | ||
50 | - | ||
51 | - router.post( | ||
52 | - "/getUploaderToken", | ||
53 | - policies.ensureLoggedOut(), | ||
54 | - controller.getUploaderToken | ||
55 | - ); | ||
56 | - | ||
57 | - router.post( | ||
58 | - "/delOSSObject", | ||
59 | - policies.ensureLoggedOut(), | ||
60 | - controller.delOSSObject | ||
61 | - ); | ||
62 | - | ||
63 | - router.post("/smsVerification", controller.smsVerification); | ||
64 | - | ||
65 | - router.post("/getObjectTokenByID", controller.getObjectTokenByID); | ||
66 | - | ||
67 | - // router.get( | ||
68 | - // '/healthMonitor', | ||
69 | - // controller.healthMonitor | ||
70 | - // ) | ||
71 | - | ||
72 | - // router.head( | ||
73 | - // '/healthMonitor', | ||
74 | - // controller.healthMonitor | ||
75 | - // ) | ||
76 | - | ||
77 | - router.post( | ||
78 | - "/getUserRoles", | ||
79 | - policies.ensureLoggedOut(), | ||
80 | - controller.getUserRoles | ||
81 | - ); | ||
82 | - | ||
83 | - router.post("/getRoles", policies.ensureLoggedOut(), controller.getRoles); | ||
84 | - | ||
85 | - router.post( | ||
86 | - "/updateUserRoles", | ||
87 | - policies.ensureLoggedOut(), | ||
88 | - controller.updateUserRoles | ||
89 | - ); | ||
90 | - | ||
91 | - router.post("/getTenant", policies.ensureLoggedOut(), controller.getTenant); | ||
92 | - | ||
93 | - router.post( | ||
94 | - "/updateTenant", | ||
95 | - policies.ensureLoggedOut(), | ||
96 | - controller.updateTenant | ||
97 | - ); | ||
98 | - | ||
99 | - router.get("/offer/:requestId", controller.offer); | ||
100 | - | ||
101 | - router.post( | ||
102 | - "/onboardStatus", | ||
103 | - policies.ensureLoggedOut(), | ||
104 | - controller.onboardStatus | ||
105 | - ); | ||
106 | - | ||
107 | - router.get("/downloadApp", controller.dowloadApp); | ||
108 | - | ||
109 | - router.get("/info/policy", controller.softwareLicense); | ||
110 | - | ||
111 | - router.get("/payRoll", function (req, res, next) { | ||
112 | - res.send(payRoll); | ||
113 | - }); | ||
114 | - | ||
115 | - router.get("/recharge", controller.recharge); | ||
116 | - | ||
117 | - router.post("/changePassForRegister", controller.changePassForRegister); | ||
118 | - | ||
119 | - router.post( | ||
120 | - "/changeTenant", | ||
121 | - policies.ensureLoggedOut(), | ||
122 | - controller.changeTenant | ||
123 | - ); | ||
124 | - | ||
125 | - router.post("/hr/sendRejectOffer", controller.sendRejectOffer); | ||
126 | - | ||
127 | - router.post("/hr/acceptOffer", controller.acceptOffer); | ||
128 | - | ||
129 | - router.post("/imTokens", policies.ensureLoggedOut(), controller.imTokens); | ||
130 | - | ||
131 | - router.post( | ||
132 | - "/listChannels", | ||
133 | - policies.ensureLoggedOut(), | ||
134 | - controller.listChannels | ||
135 | - ); | ||
136 | - | ||
137 | - router.post( | ||
138 | - "/getTastLink", | ||
139 | - policies.ensureLoggedOut(), | ||
140 | - controller.getTastLink | ||
141 | - ); | ||
142 | - | ||
143 | - router.get("/filemeta", policies.ensureLoggedOut(), controller.filemeta); | ||
144 | - | ||
145 | - router.get( | ||
146 | - "/getCustomerQrcode", | ||
147 | - policies.ensureLoggedOut(), | ||
148 | - controller.getCustomerQrcode | ||
149 | - ); | ||
150 | - | ||
151 | - router.get( | ||
152 | - "/getPositionQrcode", | ||
153 | - policies.ensureLoggedOut(), | ||
154 | - controller.getPositionQrcode | ||
155 | - ); | ||
156 | - router.get( | ||
157 | - //微店模板路由 | ||
158 | - "/minishop/:id", | ||
159 | - controller.weidianTempLate | ||
160 | - ); | ||
161 | - | ||
162 | - router.get("/wso-workai", controller.workaiSecurityOAuth); | ||
163 | - | ||
164 | - router.get( | ||
165 | - "/socialwork/freedom-jobs/emps/:id/:verification", | ||
166 | - controller.freedomJobsEmp | ||
167 | - ); | ||
168 | - | ||
169 | - router.get("/socialwork/freedom-jobs/emps/:id", controller.freedomJobsEmp); | ||
170 | - | ||
171 | - router.get("/getShortToken", controller.getShortToken); | ||
172 | - | ||
173 | - router.get("/gainianrenli/*",controller.getImg) | ||
174 | - router.get("/waifu_img/*",controller.getImg) | ||
175 | - router.get("/my_img/*",controller.getImg) | ||
176 | - router.get("/invoice_file_icon/*",controller.getImg) | ||
177 | - router.get("/gainianrenli/*",controller.getImg) | ||
178 | - router.get("/claim_icons/*",controller.getImg) | ||
179 | - | ||
180 | - app.use("/", router); | ||
181 | - | ||
182 | - app.use("/index", router2); | 5 | + var app = this; |
6 | + var router = express.Router(); | ||
7 | + var router2 = express.Router(); | ||
8 | + var controller = IoC.create('controllers/auth'); | ||
9 | + if (settings.prefix.length > 0) { | ||
10 | + router.get( | ||
11 | + '/', | ||
12 | + controller.index | ||
13 | + ); | ||
14 | + router.get( | ||
15 | + '/signOut', | ||
16 | + controller.signOut | ||
17 | + ); | ||
18 | + } | ||
19 | + | ||
20 | + router2.get( | ||
21 | + '/', | ||
22 | + controller.indexPrefix | ||
23 | + ); | ||
24 | + | ||
25 | + router.get( | ||
26 | + '/productDes', | ||
27 | + controller.productDes | ||
28 | + ); | ||
29 | + | ||
30 | + router.get( | ||
31 | + '/register', | ||
32 | + controller.register | ||
33 | + ); | ||
34 | + | ||
35 | + router.get( | ||
36 | + '/mobileRegister', | ||
37 | + controller.mobileRegister | ||
38 | + ); | ||
39 | + | ||
40 | + router.get( | ||
41 | + '/mobileRegisterSuccess', | ||
42 | + controller.mobileRegisterSuccess | ||
43 | + ); | ||
44 | + | ||
45 | + router.get( | ||
46 | + '/signIn', | ||
47 | + controller.signIn | ||
48 | + ); | ||
49 | + | ||
50 | + router.post( | ||
51 | + '/doLogin', | ||
52 | + controller.doLogin | ||
53 | + ); | ||
54 | + | ||
55 | + router.get( | ||
56 | + '/refreshToken', | ||
57 | + controller.refreshToken | ||
58 | + ); | ||
59 | + | ||
60 | + | ||
61 | + router2.get( | ||
62 | + '/signOut', | ||
63 | + controller.signOut | ||
64 | + ); | ||
65 | + | ||
66 | + router.post( | ||
67 | + '/smsCodes', | ||
68 | + controller.smsCodes | ||
69 | + ); | ||
70 | + | ||
71 | + router.post( | ||
72 | + '/tenants', | ||
73 | + controller.tenants | ||
74 | + ); | ||
75 | + | ||
76 | + router.post( | ||
77 | + '/resetPass', | ||
78 | + policies.ensureLoggedOut(), | ||
79 | + controller.resetPass | ||
80 | + ); | ||
81 | + | ||
82 | + router.post( | ||
83 | + '/updatePassword', | ||
84 | + policies.ensureLoggedOut(), | ||
85 | + controller.updatePassword | ||
86 | + ); | ||
87 | + | ||
88 | + | ||
89 | + router.post( | ||
90 | + '/loadUserInfo', | ||
91 | + policies.ensureLoggedOut(), | ||
92 | + controller.loadUserInfo | ||
93 | + ); | ||
94 | + | ||
95 | + router.post( | ||
96 | + '/getUploaderToken', | ||
97 | + policies.ensureLoggedOut(), | ||
98 | + controller.getUploaderToken | ||
99 | + ); | ||
100 | + | ||
101 | + router.post( | ||
102 | + '/delOSSObject', | ||
103 | + policies.ensureLoggedOut(), | ||
104 | + controller.delOSSObject | ||
105 | + ); | ||
106 | + | ||
107 | + router.post( | ||
108 | + '/smsVerification', | ||
109 | + controller.smsVerification | ||
110 | + ) | ||
111 | + | ||
112 | + router.post( | ||
113 | + '/getObjectTokenByID', | ||
114 | + controller.getObjectTokenByID | ||
115 | + ) | ||
116 | + | ||
117 | + // router.get( | ||
118 | + // '/healthMonitor', | ||
119 | + // controller.healthMonitor | ||
120 | + // ) | ||
121 | + | ||
122 | + // router.head( | ||
123 | + // '/healthMonitor', | ||
124 | + // controller.healthMonitor | ||
125 | + // ) | ||
126 | + | ||
127 | + router.post( | ||
128 | + '/getUserRoles', | ||
129 | + policies.ensureLoggedOut(), | ||
130 | + controller.getUserRoles | ||
131 | + ); | ||
132 | + | ||
133 | + router.post( | ||
134 | + '/getRoles', | ||
135 | + policies.ensureLoggedOut(), | ||
136 | + controller.getRoles | ||
137 | + ); | ||
138 | + | ||
139 | + router.post( | ||
140 | + '/updateUserRoles', | ||
141 | + policies.ensureLoggedOut(), | ||
142 | + controller.updateUserRoles | ||
143 | + ); | ||
144 | + | ||
145 | + router.post( | ||
146 | + '/getTenant', | ||
147 | + policies.ensureLoggedOut(), | ||
148 | + controller.getTenant | ||
149 | + ); | ||
150 | + | ||
151 | + router.post( | ||
152 | + '/updateTenant', | ||
153 | + policies.ensureLoggedOut(), | ||
154 | + controller.updateTenant | ||
155 | + ); | ||
156 | + | ||
157 | + router.get( | ||
158 | + '/offer/:requestId', | ||
159 | + controller.offer | ||
160 | + ); | ||
161 | + | ||
162 | + router.post( | ||
163 | + '/onboardStatus', | ||
164 | + policies.ensureLoggedOut(), | ||
165 | + controller.onboardStatus | ||
166 | + ); | ||
167 | + | ||
168 | + router.get( | ||
169 | + '/downloadApp', | ||
170 | + controller.dowloadApp | ||
171 | + ); | ||
172 | + | ||
173 | + router.get( | ||
174 | + '/info/policy', | ||
175 | + controller.softwareLicense | ||
176 | + ); | ||
177 | + | ||
178 | + router.get('/payRoll', function (req, res, next) { | ||
179 | + res.send(payRoll); | ||
180 | + }); | ||
181 | + | ||
182 | + router.get( | ||
183 | + '/recharge', | ||
184 | + controller.recharge | ||
185 | + ); | ||
186 | + | ||
187 | + router.post( | ||
188 | + '/changePassForRegister', | ||
189 | + controller.changePassForRegister | ||
190 | + ); | ||
191 | + | ||
192 | + router.post( | ||
193 | + '/changeTenant', | ||
194 | + policies.ensureLoggedOut(), | ||
195 | + controller.changeTenant | ||
196 | + ); | ||
197 | + | ||
198 | + router.post( | ||
199 | + '/hr/sendRejectOffer', | ||
200 | + controller.sendRejectOffer | ||
201 | + ); | ||
202 | + | ||
203 | + router.post( | ||
204 | + '/hr/acceptOffer', | ||
205 | + controller.acceptOffer | ||
206 | + ); | ||
207 | + | ||
208 | + router.post( | ||
209 | + '/imTokens', | ||
210 | + policies.ensureLoggedOut(), | ||
211 | + controller.imTokens | ||
212 | + ); | ||
213 | + | ||
214 | + router.post( | ||
215 | + '/listChannels', | ||
216 | + policies.ensureLoggedOut(), | ||
217 | + controller.listChannels | ||
218 | + ); | ||
219 | + | ||
220 | + router.post( | ||
221 | + '/getTastLink', | ||
222 | + policies.ensureLoggedOut(), | ||
223 | + controller.getTastLink | ||
224 | + ); | ||
225 | + | ||
226 | + router.get( | ||
227 | + '/filemeta', | ||
228 | + policies.ensureLoggedOut(), | ||
229 | + controller.filemeta | ||
230 | + ); | ||
231 | + | ||
232 | + router.get( | ||
233 | + '/getCustomerQrcode', | ||
234 | + policies.ensureLoggedOut(), | ||
235 | + controller.getCustomerQrcode | ||
236 | + ); | ||
237 | + | ||
238 | + router.get( | ||
239 | + '/getPositionQrcode', | ||
240 | + policies.ensureLoggedOut(), | ||
241 | + controller.getPositionQrcode | ||
242 | + ); | ||
243 | + router.get( //微店模板路由 | ||
244 | + '/minishop/:id', | ||
245 | + controller.weidianTempLate | ||
246 | + ); | ||
247 | + | ||
248 | + router.get( | ||
249 | + '/wso-workai', | ||
250 | + controller.workaiSecurityOAuth | ||
251 | + ); | ||
252 | + | ||
253 | + router.get( | ||
254 | + '/socialwork/freedom-jobs/emps/:id/:verification', | ||
255 | + controller.freedomJobsEmp | ||
256 | + ); | ||
257 | + | ||
258 | + router.get( | ||
259 | + '/socialwork/freedom-jobs/emps/:id', | ||
260 | + controller.freedomJobsEmp | ||
261 | + ); | ||
262 | + | ||
263 | + router.get( | ||
264 | + '/getShortToken', | ||
265 | + controller.getShortToken | ||
266 | + ); | ||
267 | + | ||
268 | + router.post( | ||
269 | + '/loadYxlyToken', | ||
270 | + policies.ensureLoggedOut(), | ||
271 | + controller.loadYxlyToken | ||
272 | + ); | ||
273 | + | ||
274 | + router.get( | ||
275 | + '/redirectContract', | ||
276 | + controller.redirectContract | ||
277 | + ) | ||
278 | + | ||
279 | + settings.prefix.length > 1 ? | ||
280 | + app.use(settings.prefix.substring(0, settings.prefix.length - 1), router) : | ||
281 | + app.use('/', router); | ||
282 | + | ||
283 | + | ||
284 | + app.use('/', router2); | ||
183 | }; | 285 | }; |
184 | 286 | ||
185 | -exports["@require"] = ["$container", "policies", "igloo/settings"]; | ||
186 | -exports["@singleton"] = true; | 287 | +exports['@require'] = ['$container', 'policies', 'igloo/settings']; |
288 | +exports['@singleton'] = true; |
1 | +/* | ||
2 | + * @Descripttion: | ||
3 | + * @version: 0.0.0 | ||
4 | + * @Author: genglw | ||
5 | + * @Date: 2022-01-21 15:31:14 | ||
6 | + * @LastEditors: genglw | ||
7 | + * @LastEditTime: 2022-02-10 20:46:00 | ||
8 | + */ | ||
1 | 9 | ||
2 | // app - routes | 10 | // app - routes |
3 | 11 | ||
@@ -25,6 +33,12 @@ exports = module.exports = function(IoC, settings) { | @@ -25,6 +33,12 @@ exports = module.exports = function(IoC, settings) { | ||
25 | //robot | 33 | //robot |
26 | app.phase(bootable.di.routes('./routes/robot.js')); | 34 | app.phase(bootable.di.routes('./routes/robot.js')); |
27 | 35 | ||
36 | + //excellent | ||
37 | + app.phase(bootable.di.routes('./routes/excellent.js')); | ||
38 | + | ||
39 | + app.phase(bootable.di.routes('./routes/config.js')); | ||
40 | + | ||
41 | + | ||
28 | // error handler (always keep this last) | 42 | // error handler (always keep this last) |
29 | app.phase(function() { | 43 | app.phase(function() { |
30 | var errorHandler = IoC.create('igloo/error-handler'); | 44 | var errorHandler = IoC.create('igloo/error-handler'); |
routes/config.js
0 → 100644
1 | +var express = require('express'); | ||
2 | +var payRoll = require('../json/payRoll.json'); | ||
3 | + | ||
4 | +exports = module.exports = function (IoC, policies, settings) { | ||
5 | + var app = this; | ||
6 | + var router = express.Router(); | ||
7 | + var controller = IoC.create('controllers/config'); | ||
8 | + router.get( | ||
9 | + '/getHost', | ||
10 | + controller.getHost | ||
11 | + ); | ||
12 | + app.use(settings.prefix + 'config', router); | ||
13 | + | ||
14 | +} | ||
15 | + | ||
16 | +exports['@require'] = ['$container', 'policies', 'igloo/settings']; | ||
17 | +exports['@singleton'] = true; |
routes/excellent.js
0 → 100644
1 | +/* | ||
2 | + * @Descripttion: | ||
3 | + * @version: 0.0.0 | ||
4 | + * @Author: genglw | ||
5 | + * @Date: 2022-01-21 15:31:14 | ||
6 | + * @LastEditors: genglw | ||
7 | + * @LastEditTime: 2022-02-10 20:34:55 | ||
8 | + */ | ||
9 | +var express = require('express'); | ||
10 | + | ||
11 | +exports = module.exports = function (IoC, policies, settings) { | ||
12 | + var app = this; | ||
13 | + var router = express.Router(); | ||
14 | + var controller = IoC.create('controllers/excellent'); | ||
15 | + | ||
16 | + router.get( | ||
17 | + '/*', | ||
18 | + policies.ensureLoggedOut(), | ||
19 | + controller.get | ||
20 | + ); | ||
21 | + | ||
22 | + router.post( | ||
23 | + '/*', | ||
24 | + policies.ensureLoggedOut(), | ||
25 | + controller.post | ||
26 | + ); | ||
27 | + | ||
28 | + router.put( | ||
29 | + '/*', | ||
30 | + policies.ensureLoggedOut(), | ||
31 | + controller.put | ||
32 | + ); | ||
33 | + | ||
34 | + router.patch( | ||
35 | + '/*', | ||
36 | + policies.ensureLoggedOut(), | ||
37 | + controller.patch | ||
38 | + ); | ||
39 | + | ||
40 | + router.head( | ||
41 | + '/*', | ||
42 | + policies.ensureLoggedOut(), | ||
43 | + controller.head | ||
44 | + ); | ||
45 | + | ||
46 | + router.delete( | ||
47 | + '/*', | ||
48 | + policies.ensureLoggedOut(), | ||
49 | + controller.delete | ||
50 | + ); | ||
51 | + | ||
52 | + app.use(settings.prefix + 'excellent', router); | ||
53 | + | ||
54 | +}; | ||
55 | + | ||
56 | +exports['@require'] = ['$container', 'policies', 'igloo/settings']; | ||
57 | +exports['@singleton'] = true; |
1 | +/* | ||
2 | + * @Descripttion: | ||
3 | + * @version: 0.0.0 | ||
4 | + * @Author: genglw | ||
5 | + * @Date: 2022-01-21 15:31:14 | ||
6 | + * @LastEditors: genglw | ||
7 | + * @LastEditTime: 2022-02-12 16:57:36 | ||
8 | + */ | ||
1 | var async = require('async'); | 9 | var async = require('async'); |
2 | 10 | ||
3 | exports = module.exports = function (logger, rest) { | 11 | exports = module.exports = function (logger, rest) { |
@@ -6,13 +14,14 @@ exports = module.exports = function (logger, rest) { | @@ -6,13 +14,14 @@ exports = module.exports = function (logger, rest) { | ||
6 | var user = { | 14 | var user = { |
7 | refreshToken: "", | 15 | refreshToken: "", |
8 | token: "", | 16 | token: "", |
17 | + yxly_token: "", | ||
9 | service_catalog: {}, | 18 | service_catalog: {}, |
10 | user_info: {}, | 19 | user_info: {}, |
11 | err: null | 20 | err: null |
12 | }; | 21 | }; |
13 | async.waterfall([ | 22 | async.waterfall([ |
14 | function (callback) {//get temp token | 23 | function (callback) {//get temp token |
15 | - logger.info("get temp token"); | 24 | + logger.debug("get temp token"); |
16 | var tempParams = { | 25 | var tempParams = { |
17 | "grant_type": req.body.grant_type, | 26 | "grant_type": req.body.grant_type, |
18 | "username": req.body.username, | 27 | "username": req.body.username, |
@@ -23,14 +32,15 @@ exports = module.exports = function (logger, rest) { | @@ -23,14 +32,15 @@ exports = module.exports = function (logger, rest) { | ||
23 | if (req.body.smscode) | 32 | if (req.body.smscode) |
24 | tempParams['sms_code'] = req.body.smscode; | 33 | tempParams['sms_code'] = req.body.smscode; |
25 | 34 | ||
26 | - logger.info("url:" + rest.getBaseUrl('auth/tokens', 'uaa')); | ||
27 | - logger.info("params", tempParams); | ||
28 | - console.log(tempParams) | ||
29 | - rest.restful.postJson(rest.getBaseUrl('auth/tokens', 'uaa'), tempParams, { | ||
30 | - headers: { 'Content-Type': 'application/json', "Accept": "application/json" } | 35 | + logger.debug("url:" + rest.getBaseUrl('auth/tokens', 'uaa')); |
36 | + logger.debug("params", tempParams); | ||
37 | + var url = rest.getBaseUrl('auth/tokens', 'uaa'); | ||
38 | + var headers = rest.addHeaders({ 'Content-Type': 'application/json', "Accept": "application/json" },req); | ||
39 | + rest.restful.postJson(url, tempParams, { | ||
40 | + headers: headers | ||
31 | }) | 41 | }) |
32 | .on('success', function (data, response) { | 42 | .on('success', function (data, response) { |
33 | - logger.info("tokens-success", data); | 43 | + logger.debug("tokens-success", data); |
34 | if (data.access_token) { | 44 | if (data.access_token) { |
35 | user.token = data.access_token; | 45 | user.token = data.access_token; |
36 | user.refreshToken = data.refresh_token; | 46 | user.refreshToken = data.refresh_token; |
@@ -48,17 +58,19 @@ exports = module.exports = function (logger, rest) { | @@ -48,17 +58,19 @@ exports = module.exports = function (logger, rest) { | ||
48 | user.err = data.message; | 58 | user.err = data.message; |
49 | callback(err, data); | 59 | callback(err, data); |
50 | } | 60 | } |
61 | + rest.proxyLog(data,response,req,{headers,'data':tempParams,url}) | ||
51 | }).on('error', function (err, response) { | 62 | }).on('error', function (err, response) { |
52 | - // logger.info("tokens-error",data); | 63 | + // logger.debug("tokens-error",data); |
53 | var err = new Error('name or pass err'); | 64 | var err = new Error('name or pass err'); |
65 | + rest.proxyLog(err,response,req,{headers,'data':tempParams,url}) | ||
54 | callback(err, response); | 66 | callback(err, response); |
55 | }).on('fail', function (data, response) { | 67 | }).on('fail', function (data, response) { |
56 | - logger.info("tokens-fail", data); | 68 | + logger.debug("tokens-fail", data); |
57 | var err = new Error('name or pass err'); | 69 | var err = new Error('name or pass err'); |
70 | + rest.proxyLog(data,response,req,{headers,'data':tempParams,url}) | ||
58 | callback(data, response); | 71 | callback(data, response); |
59 | }); | 72 | }); |
60 | }], function (err, result) { | 73 | }], function (err, result) { |
61 | - logger.info(err); | ||
62 | if (err) { | 74 | if (err) { |
63 | return done(null, false, err); | 75 | return done(null, false, err); |
64 | } else { | 76 | } else { |
@@ -68,7 +80,7 @@ exports = module.exports = function (logger, rest) { | @@ -68,7 +80,7 @@ exports = module.exports = function (logger, rest) { | ||
68 | } | 80 | } |
69 | 81 | ||
70 | function serializeUser(user, done) { | 82 | function serializeUser(user, done) { |
71 | - logger.info("passport.serializeUser"); | 83 | + logger.debug("passport.serializeUser"); |
72 | done(null, user); | 84 | done(null, user); |
73 | } | 85 | } |
74 | 86 | ||
@@ -79,7 +91,7 @@ exports = module.exports = function (logger, rest) { | @@ -79,7 +91,7 @@ exports = module.exports = function (logger, rest) { | ||
79 | info: {}, | 91 | info: {}, |
80 | err: null | 92 | err: null |
81 | }; | 93 | }; |
82 | - console.info("passport.deserializeUser"); | 94 | + logger.debug("passport.deserializeUser"); |
83 | done(null, user); | 95 | done(null, user); |
84 | } | 96 | } |
85 | 97 |
utils/redis.js
0 → 100644
1 | +/* | ||
2 | + * @Descripttion: | ||
3 | + * @version: 0.0.0 | ||
4 | + * @Author: genglw | ||
5 | + * @Date: 2022-02-12 20:34:11 | ||
6 | + * @LastEditors: genglw | ||
7 | + * @LastEditTime: 2022-02-15 11:09:45 | ||
8 | + */ | ||
9 | +var redis = require('redis'); | ||
10 | + | ||
11 | +exports = module.exports = function (logger, settings) { | ||
12 | + | ||
13 | + async function set(key, value) { | ||
14 | + const client = redis.createClient({ | ||
15 | + url: `redis://${settings.redis.host}:${settings.redis.port}`, | ||
16 | + password: settings.redis.pass, | ||
17 | + }); | ||
18 | + | ||
19 | + client.on('error', (err) => logger.info('Redis Client Error', err)); | ||
20 | + | ||
21 | + await client.connect(); | ||
22 | + await client.set(key, value); | ||
23 | + await client.quit(); | ||
24 | + } | ||
25 | + | ||
26 | + async function get(key) { | ||
27 | + const client = redis.createClient({ | ||
28 | + url: `redis://${settings.redis.host}:${settings.redis.port}`, | ||
29 | + password: settings.redis.pass, | ||
30 | + }); | ||
31 | + | ||
32 | + client.on('error', (err) => logger.info('Redis Client Error', err)); | ||
33 | + | ||
34 | + await client.connect(); | ||
35 | + const value = await client.get(key); | ||
36 | + await client.quit(); | ||
37 | + | ||
38 | + return value; | ||
39 | + } | ||
40 | + | ||
41 | + return { | ||
42 | + set: set, | ||
43 | + get: get, | ||
44 | + }; | ||
45 | +}; | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | +exports['@singleton'] = true; | ||
51 | +exports['@require'] = ['igloo/logger', 'igloo/settings']; |
utils/requestLogger.js
0 → 100644
1 | +var moment = require('moment'); | ||
2 | + | ||
3 | + | ||
4 | +exports = module.exports = function (logger,settings) { | ||
5 | + | ||
6 | + | ||
7 | + return function (req, res, next) { | ||
8 | + var requestEnd = res.end | ||
9 | + , requestedUrl = req.originalUrl | ||
10 | + , startTime = new Date(); | ||
11 | + var level = 'error'; | ||
12 | + if(settings&&settings.output&&settings.output.level){ | ||
13 | + level=settings.output.level; | ||
14 | + } | ||
15 | + | ||
16 | + // Proxy the real end function | ||
17 | + res.end = function (chunk, encoding) { | ||
18 | + | ||
19 | + var data = { | ||
20 | + 'date': moment(startTime).format(), | ||
21 | + 'statusCode': res.statusCode, | ||
22 | + 'method': req.method, | ||
23 | + 'responseTime': (new Date() - startTime), | ||
24 | + 'deviceId':req.headers['device-id']||'', | ||
25 | + 'xRequestId':req.headers['x-request-id']||'', | ||
26 | + 'url': requestedUrl, | ||
27 | + 'ip': req.headers['client-ip'] || req.ip || req.connection.remoteAddress, | ||
28 | + 'userAgent': req.headers['user-agent'] | ||
29 | + }; | ||
30 | + | ||
31 | + // Do the work expected | ||
32 | + res.end = requestEnd; | ||
33 | + res.end(chunk, encoding); | ||
34 | + | ||
35 | + if(res.statusCode>=400){//响应错误 | ||
36 | + logger.error(data); | ||
37 | + }else if('debug'==level){ | ||
38 | + logger.debug(data); | ||
39 | + }else{ | ||
40 | + logger.info(data); | ||
41 | + } | ||
42 | + }; | ||
43 | + | ||
44 | + next(); | ||
45 | + }; | ||
46 | +}; |
请
注册
或
登录
后发表评论