diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index af3d0a471..f91c01f76 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -25,8 +25,8 @@ export default (app: Application) => { router.post('/api/users/getuserlist',tokenParser, controller.users.getuserlist); - router.post('/api/users/createrole',tokenParser, controller.users.createRole); - router.post('/api/users/addauth', tokenParser, controller.users.addAuth); + // router.post('/api/users/createrole',tokenParser, controller.users.createRole); + // router.post('/api/users/addauth', tokenParser, controller.users.addAuth); router.post('/api/users/fixsms', tokenParser, controller.users.fixSms); router.post('/api/users/deleterole',tokenParser, controller.users.deleteRole); router.post('/api/users/getrolelist',tokenParser, controller.users.getrolelist); diff --git a/gm-server/config/config.default.ts b/gm-server/config/config.default.ts index 83153c182..0c8eedbd6 100644 --- a/gm-server/config/config.default.ts +++ b/gm-server/config/config.default.ts @@ -90,6 +90,7 @@ export default (appInfo: EggAppInfo) => { } } } + config.proxy = httpProxy; // the return config will combines to EggAppConfig return { diff --git a/shared/db/Notice.ts b/shared/db/Notice.ts index 7aca704a1..683e9643b 100644 --- a/shared/db/Notice.ts +++ b/shared/db/Notice.ts @@ -22,10 +22,7 @@ export default class Notice extends BaseModel { content: string; // 公告内容 @prop({ required: true }) - timeStr: string; // 时间显示 - public get time() { - return this.timeStr; - } + time: string; // 时间显示 @prop({ required: true, select: false }) sort: number; diff --git a/web-server/app.ts b/web-server/app.ts index 48c6d8a18..98722b94e 100644 --- a/web-server/app.ts +++ b/web-server/app.ts @@ -2,6 +2,7 @@ import 'reflect-metadata' import * as mongoose from 'mongoose'; import { Application, IBoot } from 'egg'; import { connectRedis } from './app/pubUtils/redis'; +import { loadGmDb } from '@db/index'; export default class FooBoot implements IBoot { private readonly app: Application; @@ -15,6 +16,7 @@ export default class FooBoot implements IBoot { // Config, plugin files are referred,` // this is the last chance to modify the config. await this.connectDB(this.app); + await this.connectGMDB(this.app); await this.connectRedis(this.app); } @@ -51,9 +53,28 @@ export default class FooBoot implements IBoot { public async connectDB(app: Application) { const { url, options } = app.config.mongoose - if (url) { - const connection = await mongoose.connect(url, options) - app.context.connection = connection + try { + if (url) { + const connection = await mongoose.connect(url, options) + console.log('******connectDB suc', url, options) + app.context.connection = connection + } + } catch(e) { + console.log(e) + } + } + + public async connectGMDB(app: Application) { + const { url, options } = app.config.gmmongoose + try { + if (url) { + const connection = await mongoose.createConnection(url, options) + app.context.connectionGM = connection; + loadGmDb(connection); + console.log('******connectGMDB suc', url, options) + } + } catch(e) { + console.log(e) } } diff --git a/web-server/config/config.alpha.ts b/web-server/config/config.alpha.ts index 094ef0024..cc1df7dfc 100644 --- a/web-server/config/config.alpha.ts +++ b/web-server/config/config.alpha.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-506991391', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,51 +13,10 @@ export default (appInfo: EggAppInfo) => { url: 'r-8vbl8okinxn1zhkwh2.redis.zhangbei.rds.aliyuncs.com', // 内网 pw: 'zyz_alpha_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.default.ts b/web-server/config/config.default.ts index e91a9fa16..abbd7cb13 100644 --- a/web-server/config/config.default.ts +++ b/web-server/config/config.default.ts @@ -24,6 +24,10 @@ export default (appInfo: EggAppInfo) => { url: 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.gmmongoose = { + url: 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', // 内网 + options: { useNewUrlParser: true, useUnifiedTopology: true }, + }; config.redis = { url: 'r-8vb130185rp2ir3lqn.redis.zhangbei.rds.aliyuncs.com', // 内网 pw: 'zyz_monitor_2021' @@ -44,12 +48,6 @@ export default (appInfo: EggAppInfo) => { }, }; - exports.xtransit = { - server: 'ws://127.0.0.1:9092', - appId: 3, - appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101' - }; - config.decodeParm = true; config.static = { diff --git a/web-server/config/config.dev.ts b/web-server/config/config.dev.ts index 0a37904b9..b6249fff4 100644 --- a/web-server/config/config.dev.ts +++ b/web-server/config/config.dev.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-506991391', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,51 +13,9 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_dev_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; - // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.isbn.ts b/web-server/config/config.isbn.ts index 61caba350..d85aa736c 100644 --- a/web-server/config/config.isbn.ts +++ b/web-server/config/config.isbn.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://root:Bantus123@dds-8vb74337eab84d641.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb74337eab84d642.mongodb.zhangbei.rds.aliyuncs.com:3717/admin?replicaSet=mgset-504694158', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,51 +13,9 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_isbn_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; - // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.local.ts b/web-server/config/config.local.ts index da66bfc4a..9aee1e9fe 100644 --- a/web-server/config/config.local.ts +++ b/web-server/config/config.local.ts @@ -1,80 +1,27 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://127.0.0.1/zyz', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.gmmongoose = { + url: 'mongodb://127.0.0.1:27017/zyzgm', // 内网 + options: { useNewUrlParser: true, useUnifiedTopology: true }, + }; config.redis = { url: '127.0.0.1', // 内网 pw: '' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '${appInfo.root}/logs/${appInfo.name}/zyz-web.log', '${appInfo.root}/logs/${appInfo.name}/common-error.log', '${appInfo.root}/logs/${appInfo.name}/egg-agent.log' ], - // packages: [ '${appInfo.baseDir}/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { + ...defaultConfig(appInfo), ...config, - ...bizConfig, }; }; diff --git a/web-server/config/config.monitor.ts b/web-server/config/config.monitor.ts index e91a9fa16..56eeeb048 100644 --- a/web-server/config/config.monitor.ts +++ b/web-server/config/config.monitor.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,57 +13,15 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_monitor_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - exports.xtransit = { server: 'ws://127.0.0.1:9092', appId: 3, appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101' }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.stable.ts b/web-server/config/config.stable.ts index 241fe1ec1..7ae29f720 100644 --- a/web-server/config/config.stable.ts +++ b/web-server/config/config.stable.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,58 +13,16 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_2020' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - config.xtransit = { server: 'ws://172.26.117.35:9092', appId: 3, appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101', error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; };