增加服务端配置

This commit is contained in:
yulixing 2019-09-03 13:58:29 +08:00
parent c3065965ad
commit eab1697c33
2 changed files with 116 additions and 119 deletions

View File

@ -1,13 +1,13 @@
const path = require('path');
const path = require('path')
const rootPath = path.normalize(__dirname + '/..');
const env = process.env.NODE_ENV || 'development';
const rootPath = path.normalize(__dirname + '/..')
const env = process.env.NODE_ENV || 'development'
const config = {
development: {
root: rootPath,
app: {
name: 'pikachu'
name: 'pikachu',
},
host: 'http://192.168.199.210:3000',
port: process.env.PORT || 2333,
@ -21,26 +21,34 @@ const config = {
db_dalmatian: 'mongodb://localhost/dalmatian-development',
db_beagle: 'mongodb://localhost/beagle-development',
db_ghost: 'mongodb://localhost/ghost-development',
db_admin_test: 'mongodb://localhost/pikachu-test',
db_garfield_test: 'mongodb://localhost/garfield-test',
db_snoopy_test: 'mongodb://localhost/snoopy-test',
db_dalmatian_test: 'mongodb://localhost/dalmatian-test',
db_beagle_test: 'mongodb://localhost/beagle-test',
db_ghost_test: 'mongodb://localhost/ghost-test',
upload_to: rootPath + '/public/uploads',
upload_prefix: '/uploads',
short_url_base: 'https://wechat-test.kingsome.cn/s/',
ad_api: 'http://154.8.214.202:5015/interface',
game_report: 'http://154.8.214.202:5022/webapp/index.php',
redis: {
port: 6379,
host: '127.0.0.1',
password: ''
password: '',
},
redisPublish: {
redisPublish: {
port: 6379,
host: '192.144.140.87',
password: ''
password: '',
},
cos: {
SecretId: 'AKIDufGerr0GfssfTBiy3vZzEF4f3C8rfb3K',
SecretKey: 'B7mDPL3WlobBgy4xgDUXO0NVP3ScWBcn'
SecretKey: 'B7mDPL3WlobBgy4xgDUXO0NVP3ScWBcn',
},
cos_cdn: {
SecretId: 'AKIDvmW8mNvCQVt9GEnd3JNH5lHKI8oJnv46',
SecretKey: 'd6QZhgT7alnhR3VghWAg3FF4c2JMG1c2'
SecretKey: 'd6QZhgT7alnhR3VghWAg3FF4c2JMG1c2',
},
pay_weapp: {
app_id: 'wxaf55c10d3fa61c40',
@ -49,36 +57,46 @@ const config = {
schedule_send_time: '0 30 19 * * *',
message_value1: '晚间轻松一刻',
message_value2: '邀新人玩游戏,赚零花钱',
message_value3: '可以在小程序底部进入游戏哦'
message_value3: '可以在小程序底部进入游戏哦',
},
pay_db: {
db_name: 'paydb',
username: 'root',
password: 'keji178',
host: '192.144.140.87',
port: 3306,
dialect: 'mysql',
},
youme: {
baseUrl: 'https://api.youme.im/v1/im/',
identifier: 'admin',
app_key: 'YOUME4E2394D4CE21BAAFF95831701696A885A3372F6F',
app_secret:
'3vHmwZkDGHXsURalxCvg51ns11aCULY4HiGcQZQ4PG0vDJMZwTgK4oFOgo9dZJ/wsyHIT7lDQk8JMohNa6RqhmiwZ0Mo9yq0B3Glu/3yv+YYkqQbKXU/xHDEug6tiOTIf7Cz/GlZXxB5VuPyx2CgLCtNz8XUYAUrpnUM8yrAGkcBAAE='
'3vHmwZkDGHXsURalxCvg51ns11aCULY4HiGcQZQ4PG0vDJMZwTgK4oFOgo9dZJ/wsyHIT7lDQk8JMohNa6RqhmiwZ0Mo9yq0B3Glu/3yv+YYkqQbKXU/xHDEug6tiOTIf7Cz/GlZXxB5VuPyx2CgLCtNz8XUYAUrpnUM8yrAGkcBAAE=',
},
ldap: {
url: 'ldap://ldap.kingsome.cn:389',
user: 'cn=admin,dc=kingsome,dc=cn',
password: 'milesQWE321'
password: 'milesQWE321',
},
minigame: {
api: 'http://192.168.100.206:8000/api/',
// api: 'http://192.168.100.206:8000/api/',
api: 'http://ops.kingsome.cn/api/',
username: 'ops-apiuser',
password: 'hhsxafTuUtVV'
password: 'hhsxafTuUtVV',
},
jwtSecret: 'OA3A$0X6*OsD*6oE',
pay_record: 'http://192.168.100.23:7051/webapp/index.php',
logs_path: 'E:logsgarfield'
logs_path: 'E:logsgarfield',
},
production: {
root: rootPath,
app: {
name: 'pikachu'
name: 'pikachu',
},
host: 'http://192.168.199.210:3000',
host: 'https://mp-test.kingsome.cn',
port: process.env.PORT || 2333,
secret: 'garfield_sd*3,Jd32-xd..q(jd,vHdklx2z;3',
session_name: 'sessionId_garfield',
@ -91,26 +109,34 @@ const config = {
db_dalmatian: 'mongodb://localhost/dalmatian-production',
db_beagle: 'mongodb://localhost/beagle-production',
db_ghost: 'mongodb://localhost/ghost-production',
db_admin_test: 'mongodb://10.10.9.5:27017/pikachu-production',
db_garfield_test: 'mongodb://10.10.9.5:27017/garfield-production',
db_snoopy_test: 'mongodb://10.10.9.5:27017/snoopy-production',
db_dalmatian_test: 'mongodb://10.10.9.5:27017/dalmatian-production',
db_beagle_test: 'mongodb://10.10.9.5:27017/beagle-production',
db_ghost_test: 'mongodb://10.10.9.5:27017/ghost-production',
upload_to: rootPath + '/public/uploads',
upload_prefix: '/uploads',
short_url_base: 'https://wechat-test.kingsome.cn/s/',
ad_api: 'http://promotion.kingsome.cn/interface',
game_report: 'http://154.8.214.202:5020/webapp/index.php',
redis: {
port: 6379,
host: '10.10.9.3',
password: ''
password: '',
},
redisPublish: {
port: 6379,
host: '10.10.9.3',
password: ''
password: '',
},
cos: {
SecretId: 'AKIDufGerr0GfssfTBiy3vZzEF4f3C8rfb3K',
SecretKey: 'B7mDPL3WlobBgy4xgDUXO0NVP3ScWBcn'
SecretKey: 'B7mDPL3WlobBgy4xgDUXO0NVP3ScWBcn',
},
cos_cdn: {
SecretId: 'AKIDvmW8mNvCQVt9GEnd3JNH5lHKI8oJnv46',
SecretKey: 'd6QZhgT7alnhR3VghWAg3FF4c2JMG1c2'
SecretKey: 'd6QZhgT7alnhR3VghWAg3FF4c2JMG1c2',
},
pay_weapp: {
app_id: 'wxaf55c10d3fa61c40',
@ -119,29 +145,37 @@ const config = {
schedule_send_time: '0 30 19 * * *',
message_value1: '晚间轻松一刻',
message_value2: '邀新人玩游戏,赚零花钱',
message_value3: '可以在小程序底部进入游戏哦'
message_value3: '可以在小程序底部进入游戏哦',
},
pay_db: {
db_name: 'paydb',
username: 'root',
password: 'keji178',
host: '192.144.140.87',
port: 3306,
dialect: 'mysql',
},
youme: {
baseUrl: 'https://api.youme.im/v1/im/',
identifier: 'admin',
app_key: 'YOUME4E2394D4CE21BAAFF95831701696A885A3372F6F',
app_secret:
'3vHmwZkDGHXsURalxCvg51ns11aCULY4HiGcQZQ4PG0vDJMZwTgK4oFOgo9dZJ/wsyHIT7lDQk8JMohNa6RqhmiwZ0Mo9yq0B3Glu/3yv+YYkqQbKXU/xHDEug6tiOTIf7Cz/GlZXxB5VuPyx2CgLCtNz8XUYAUrpnUM8yrAGkcBAAE='
'3vHmwZkDGHXsURalxCvg51ns11aCULY4HiGcQZQ4PG0vDJMZwTgK4oFOgo9dZJ/wsyHIT7lDQk8JMohNa6RqhmiwZ0Mo9yq0B3Glu/3yv+YYkqQbKXU/xHDEug6tiOTIf7Cz/GlZXxB5VuPyx2CgLCtNz8XUYAUrpnUM8yrAGkcBAAE=',
},
ldap: {
url: 'ldap://ldap.kingsome.cn:389',
user: 'cn=admin,dc=kingsome,dc=cn',
password: 'milesQWE321'
password: 'milesQWE321',
},
minigame: {
api: 'http://192.168.100.206:8000/api/',
api: 'http://ops.kingsome.cn/api/',
username: 'ops-apiuser',
password: 'hhsxafTuUtVV'
password: 'hhsxafTuUtVV',
},
jwtSecret: 'OA3A$0X6*OsD*6oE',
pay_record: 'http://192.168.100.23:7051/webapp/index.php',
logs_path: 'E:logsgarfield'
}
};
logs_path: 'E:logsgarfield',
},
}
module.exports = config[env];
module.exports = config[env]

View File

@ -10,47 +10,6 @@ import logger from '../../utils/logger'
const router = new Router()
const redisDao = new RedisDao()
/* 获取所有游戏配置*/
router.get('/games', async (req, res, next) => {
// logger.db(req, '游戏管理', '配置管理', '获取所有游戏配置信息');
const type = parseInt(req.query.type)
try {
const pattern = !type ? 'config*' : 'private_config*'
const results = await redisDao.scanAsync('0', pattern, [])
let games = []
const gameList = await GameInfo.find({deleted: false})
const gameMap = new Map()
for (const g of gameList) {
gameMap.set(g.game_id, g.game_name)
}
const platforms = await SystemDic.find({
type: 'platform',
deleted: false,
})
const platformMap = new Map()
for (const p of platforms) {
platformMap.set(p.key, p.value)
}
for (const result of results) {
const infos = result.split(':')
const gameObj = {
id: infos[1],
platform_id: infos[2],
}
if (infos.length > 2) {
gameObj.name = gameMap.get(infos[1])
gameObj.platform = platformMap.get(infos[2])
}
games.push(gameObj)
}
games = _.sortBy(games, o => {
return o.id
})
res.json({errcode: 0, errmsg: '', rows: games, total: games.length})
} catch (err) {
next(err)
}
})
/* 获取单个游戏的配置*/
router.get('/one_game_cfg', async (req, res, next) => {
// logger.db(req, '游戏管理', '配置管理', '获取单个游戏配置信息');
@ -72,10 +31,20 @@ router.get('/one_game_cfg', async (req, res, next) => {
const id = req.query.id
const pid = req.query.pid
const type = parseInt(req.query.type)
const key = !type ? `config:${id}:${pid}` : `private_config:${id}:${pid}`
const flag = !type
? `config_publish:${id}:${pid}`
: `private_config_publish:${id}:${pid}`
let key = ''
let flag = ''
if (type === 0) {
key = `config:${id}:${pid}`
flag = `config_publish:${id}:${pid}`
} else if (type === 1) {
key = `private_config:${id}:${pid}`
flag = `private_config_publish:${id}:${pid}`
} else if (type === 2) {
key = `server_config:${id}:${pid}`
flag = `server_config_publish:${id}:${pid}`
}
try {
let records = await redisDao.getByKey(key)
let published = await redisDao.getByKey(flag)
@ -110,7 +79,6 @@ router.get('/one_game_cfg', async (req, res, next) => {
/* 还原配置(获取正式配置) */
router.get('/reset_one_game_cfg', async (req, res, next) => {
// 权限判断
const hasPerm =
req.user.permissions.includes(`${req.query.uid}-readable`) ||
@ -128,7 +96,16 @@ router.get('/reset_one_game_cfg', async (req, res, next) => {
const id = req.query.id
const pid = req.query.pid
const type = parseInt(req.query.type)
const key = !type ? `config:${id}:${pid}` : `private_config:${id}:${pid}`
let key = ''
if (type === 0) {
key = `config:${id}:${pid}`
} else if (type === 1) {
key = `private_config:${id}:${pid}`
} else if (type === 2) {
key = `server_config:${id}:${pid}`
}
const client = redis.createClient({
host: config.redisPublish.host,
@ -167,36 +144,7 @@ router.get('/reset_one_game_cfg', async (req, res, next) => {
}
})
/* 删除一个游戏配置*/
router.post('/delete_cfg', async (req, res, next) => {
logger.db(req, '游戏管理', '配置管理', '删除单个游戏配置信息')
// 权限判断
const hasPerm =
req.user.permissions.includes(`${req.body.uid}-edit`) ||
req.user.permissions.includes(`${req.body.uid}-publish`) ||
req.user.permissions.includes(`games-writeable`)
if (!hasPerm) {
res.status(403).send({
errcode: 1,
errmsg: '用户无游戏编辑权限!',
})
return
}
const games = req.body.games
const type = parseInt(req.body.type)
let keys
if (type) {
keys = games.map(o => `private_config:${o.id}:${o.platform_id}`)
} else {
keys = games.map(o => `config:${o.id}:${o.platform_id}`)
}
try {
await redisDao.deleteKeys(keys)
res.json({errcode: 0, errmsg: ''})
} catch (err) {
next(err)
}
})
/* 更新配置*/
router.post('/save_cfg', async (req, res, next) => {
logger.db(req, '游戏管理', '配置管理', '更新单个游戏配置信息')
@ -217,12 +165,19 @@ router.post('/save_cfg', async (req, res, next) => {
const gameId = body.gameId
const platform = body.platform
const type = parseInt(body.type)
const key = !type
? `config:${gameId}:${platform}`
: `private_config:${gameId}:${platform}`
const flag = !type
? `config_publish:${gameId}:${platform}`
: `private_config_publish:${gameId}:${platform}`
let key = ''
let flag = ''
if (type === 0) {
key = `config:${gameId}:${platform}`
flag = `config_publish:${gameId}:${platform}`
} else if (type === 1) {
key = `private_config:${gameId}:${platform}`
flag = `private_config_publish:${gameId}:${platform}`
} else if (type === 2) {
key = `server_config:${gameId}:${platform}`
flag = `server_config_publish:${gameId}:${platform}`
}
for (const cfg of cfgs) {
if (cfg.type === 'bool' || cfg.type === 'num') {
cfg.value = Number(cfg.value)
@ -260,12 +215,20 @@ router.post('/publish_cfg', async (req, res, next) => {
const gameId = body.gameId
const platform = body.platform
const type = parseInt(body.type)
const key = !type
? `config:${gameId}:${platform}`
: `private_config:${gameId}:${platform}`
const flag = !type
? `config_publish:${gameId}:${platform}`
: `private_config_publish:${gameId}:${platform}`
let key = ''
let flag = ''
if (type === 0) {
key = `config:${gameId}:${platform}`
flag = `config_publish:${gameId}:${platform}`
} else if (type === 1) {
key = `private_config:${gameId}:${platform}`
flag = `private_config_publish:${id}:${platform}`
} else if (type === 2) {
key = `server_config:${gameId}:${platform}`
flag = `server_config_publish:${gameId}:${platform}`
}
const client = redis.createClient({
host: config.redisPublish.host,