Browse Source

Merge branch 'feature-refactor' of yeshijie/im.doctor into feature-refactor

yeshijie 8 years ago
parent
commit
00e6359b26

+ 7 - 1
src/server/app.js

@ -22,6 +22,9 @@ let SocketHandler = require('./handlers/socket.handler');
let UrlInitializer = require('./endpoints/url.initializer');
let JobInitializer = require('./models/schedule/job.initializer');
//消息订阅
let pubSub = require('./models/redis/pubSub.js');
// initialize express application
let app = express();
app.set('port', config.serverPort);
@ -112,4 +115,7 @@ if(!server.address()){
    log.info('Configuration profile: ' + configFile.split('.')[1]);
}
JobInitializer.init();
JobInitializer.init();
pubSub.registerHandlers(config.subChannel,msg=> console.log(msg));
pubSub.subscribe(config.subChannel);

+ 1 - 1
src/server/endpoints/v2/user.endpoint.js

@ -87,7 +87,7 @@ router.delete(APIv2.Users.Logout, function (req, res) {
    let userStatus = new Users();
    ControllerUtil.regModelEventHandler(userStatus, res);
    userStatus.logout(userId);
    userStatus.logout(userId,req.query.platform);
});
module.exports = router;

+ 7 - 3
src/server/handlers/socket.handler.js

@ -31,10 +31,14 @@ class SocketHandler {
                if (!data.userId) {
                    socketServer.sockets.emit('error', {message: 'Missing fields(s): userId.'});
                } else {
                    if(clientCache.removeByUserId(data.userId)){
                        log.info("User " + data.userId + " already login");
                        return;
                    if("pc_doctor"===data.clientType){//新增pc端医生登录
                        data.userId = "pc_"+data.userId;
                    }
                    clientCache.removeByUserId(data.userId);
                    // if(clientCache.removeByUserId(data.userId)){
                    //     log.info("User " + data.userId + " already login");
                    //     return;
                    // }
                    log.error('User ' + data.userId + ' login');
                    if(!data.clientType||data.clientType=="patient"){

+ 8 - 3
src/server/include/commons.js

@ -13,6 +13,8 @@ let configFile = "config.";
if (process.env.IM_PROFILE === "prod") {
    configFile += "prod";
} else if (process.env.IM_PROFILE === "prodPC") {
    configFile += "prodPC";
} else if (process.env.IM_PROFILE === "test") {
    configFile += "test";
} else {
@ -62,9 +64,9 @@ exports.TOPIC_STATUS = TOPIC_STATUS;
 * 会话参与者角色
 */
const PARTICIPANT_ROLES = {
    HOST: 0,
    REGULAR: 1,
    BYSTANDER: 10
    HOST: 0,//主持者
    REGULAR: 1,//普通参与者
    BYSTANDER: 10//旁听者
};
exports.PARTICIPANT_ROLES = PARTICIPANT_ROLES;
@ -105,6 +107,7 @@ exports.CONTENT_TYPES = CONTENT_TYPES;
exports.SOCKET_TYPES={
    PATIENT:"patient",
    DOCTOR:"doctor",
    PC_DOCTOR:"pc_doctor",
    DEMO:"demo"
}
@ -114,6 +117,7 @@ exports.SOCKET_TYPES={
exports.PLATFORM = {
    iOS: 0,
    Android: 1,
    PC: 3,
    Wechat: 10
};
@ -169,6 +173,7 @@ exports.REDIS_KEYS = {
    User: "users:" + REDIS_KEY_REPLACER,
    UserAppStatus: "users:" + REDIS_KEY_REPLACER + ":app_status",
    UserPcStatus: "users:" + REDIS_KEY_REPLACER + ":pc_status",
    UserWechatStatus: "users:" + REDIS_KEY_REPLACER + ":wechat_status",
    UserSessions: "users:" + REDIS_KEY_REPLACER + ":sessions",

+ 7 - 0
src/server/models/client/app.client.js

@ -7,6 +7,7 @@ let RedisClient = require('../../repository/redis/redis.client');
let RedisModel = require('./../redis.model');
let AppStatusRepo = require('../../repository/mysql/app.status.repo');
let ModelUtil = require('../../util/model.util');
let clientCache = require('../socket.io/client.cache').clientCache();
let log = require("../../util/log.js");
let pusher = require('../push/pusher');
@ -108,6 +109,12 @@ class AppClient extends RedisModel {
                    return;
                }
                // let pc_doctorClient = clientCache.findByIdAndType("pc_"+targetId,SOCKET_TYPES.PC_DOCTOR);
                // if(pc_doctorClient){
                //     log.warn("User's pc is online, user id: " + targetId + ", we cannot send getui.");
                //     return;
                // }
                if (!userStatus) {
                    log.warn("User's app status is not found, user id: " + targetId + ", maybe user never login yet or logout?");
                    return;

+ 47 - 4
src/server/models/client/wechat.client.js

@ -156,11 +156,13 @@ class WechatClient extends RedisModel {
    static sendReadDoctorByDoctorId(doctorId, message) {
        let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
        // let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
        if(!doctorClient){
            log.warn("target doctor is not online!");
            return;
        }
        let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
        // let pc_sendDoctorClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
        if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
            WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
            sendDoctorClient.socket.emit('message', {
@ -176,21 +178,44 @@ class WechatClient extends RedisModel {
                read:"one"
            });
        }else{
            log.warn("doctor is not in the same session");
            log.warn("doctor is not in the same session or not online");
        }
        //发送pc版医生端
        // if(pc_doctorClient&&pc_sendDoctorClient&&pc_sendDoctorClient.sessionId==pc_doctorClient.sessionId){
        //     WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
        //     pc_sendDoctorClient.socket.emit('message', {
        //         id: message.id,
        //         session_id: message.session_id,
        //         sender_id: message.sender_id,
        //         sender_name: message.sender_name,
        //         content_type: message.content_type,
        //         content: message.content,
        //         timestamp: ObjectUtil.timestampToLong(message.timestamp),
        //         type: message.content_type,          // legacy support
        //         name: message.sender_name,
        //         read:"one"
        //     });
        // }else{
        //     log.warn("doctor is not in the same session or not online");
        // }
    }
    static sendSocketMessageToDoctor(doctorId, message) {
        let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
        // let pc_doctorClient = clientCache.findByIdAndType("pc_"+doctorId,SOCKET_TYPES.PC_DOCTOR);
        if(!doctorClient){
            log.warn("target doctor is not online!");
            return;
        }
        let sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
        if(!sendClient){
        let sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);//app医生发送的消息
        // if(!sendClient){//pc医生发送的消息
        //     sendClient = clientCache.findByIdAndType("pc_"+message.sender_id,SOCKET_TYPES.PC_DOCTOR);
        // }
        if(!sendClient){//居民发送的消息
            sendClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.PATIENT);
        }
        if(sendClient&&sendClient.sessionId==doctorClient.sessionId){
            WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
            doctorClient.socket.emit('message', {
@ -205,8 +230,26 @@ class WechatClient extends RedisModel {
                name: message.sender_name,
            });
        }else{
            log.warn("doctor is not in the same session");
            log.warn("doctor is not in the same session or is not online");
        }
        //发送pc端
        // if(pc_doctorClient&&sendClient&&sendClient.sessionId==pc_doctorClient.sessionId){
        //     WechatClient.updateParticipantLastFetchTime(pc_doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
        //     pc_doctorClient.socket.emit('message', {
        //         id: message.id,
        //         session_id: message.session_id,
        //         sender_id: message.sender_id,
        //         sender_name: message.sender_name,
        //         content_type: message.content_type,
        //         content: message.content,
        //         timestamp: ObjectUtil.timestampToLong(message.timestamp),
        //         type: message.content_type,          // legacy support
        //         name: message.sender_name,
        //     });
        // }else{
        //     log.warn("doctor is not in the same session or is not online");
        // }
    }
    /**
     * 发送微信模板消息给居民

+ 114 - 0
src/server/models/redis/pubSub.js

@ -0,0 +1,114 @@
/*
 * redis发布订阅
 *example:
 * let channel="ryan";
 redis.pubSub.registerHandlers("ryan",msg=> console.log(msg));
 redis.pubSub.subscribe(channel);
 redis.pubSub.publish(channel,"hello from chen");
 */
"use strict";
let configFile = require('../../include/commons').CONFIG_FILE;
let config = require('../../resources/config/' + configFile);
let RedisModel = require('./../redis.model');
let RedisSubClient = require('./redisSubClient');
let RedisPubClient = require('./redisPubClient');
let redisPubConn = RedisPubClient.redisClient().connection;
let redisSubConn = RedisSubClient.redisClient().connection;
let Sessions = require('../sessions/sessions.js');
let WechatClient = require("../client/wechat.client.js");
let WlyySDK = require("../../util/wlyy.sdk");
let AppClient = require("../client/app.client.js");
class PubSub{
    constructor(){
        this.sub=redisSubConn;
        this.handlers=new Map();
        this.subAction=(channle,message)=>{
            let actions= this.handlers.get(channle)||new Set();
            for(let action of actions)
            {
                console.log("接收消息:"+message);
                if(config.pubSubSwitch){//接收订阅消息处理开关,本地运行和测试库单独运行时防止用户接收消息2次
                    message = JSON.parse(message);
                    //Sessions.getRedisPushNotification(message);这里不知为什么无法调用这个方法,提示getRedisPushNotification不是方法
                    if (message.targetType=='patient') {
                        if(config.environment!='prodPC'){//pc版接收要发给居民的消息不做处理
                            WechatClient.sendMessage(message.targetUserId, message.targetUserName, message);
                        }
                    } else {
                        if(message.sessionType=="1"){
                            WechatClient.sendReadDoctorByDoctorId(message.targetUserId, message);
                        }
                        //告知医生新消息
                        WechatClient.sendSocketMessageToDoctor(message.targetUserId,message);
                        if(config.environment!='prodPC'){//pc版不推送个推
                            WlyySDK.request(message.targetUserId, '', '', '', '/im/common/message/messages', 'POST', function (err, res) {
                                let count = 0;
                                res =  JSON.parse(res)
                                if (res.status == 200) {
                                    let data = res.data;
                                    count = parseInt(JSON.parse(data.imMsgCount).count) + parseInt(data.system.amount) + parseInt(data.healthIndex.amount) + parseInt(data.sign.amount);
                                }
                                AppClient.sendNotification(message.targetUserId, message,message.sessionType,count);
                            });
                        }
                    }
                }
                //action(message);
            }
        }
        this.alredyPublishs=[];
        this.subConnected=false;
    }
    publish(channel,message)
    {
        let action=()=>{
            let pub=redisPubConn;
            pub.publish(channel,message);
            console.log("发布消息:channel:"+channel+",message:"+message);
        };
        if(this.subConnected===false)
        {
            this.alredyPublishs.push(action);
        }
        else{
            action();
        }
    }
    registerHandlers(channel,action)
    {
        var actions=this.handlers.get(channel)||new Set();
        actions.add(action);
        this.handlers.set(channel,actions);
    }
    subscribe(channel)
    {
        let self=this;
        this.sub.subscribe(channel,function (err,reply) {
            if(err){
                log.error(err);
            }
            self.subConnected=true;
            for(let publish of self.alredyPublishs){
                publish();
            }
            console.log("订阅成功:"+reply);
        });
        this.sub.on("message", function (channel, message) {
            self.subAction(channel,message);
        });
    }
    tearDown()
    {
        this.sub.quit();
    }
}
// Expose class
module.exports = new PubSub();

+ 70 - 0
src/server/models/redis/redisPubClient.js

@ -0,0 +1,70 @@
/**
 * Redis客户端封装。
 * Redis客户端封装发布订阅(redis只要使用了发布订阅,这个client不能做其他操作)
 *
 * 注意Redis使用Promises保证调用流程。
 *
 * https://github.com/NodeRedis/node_redis
 *
 * author: linzhuo
 * since: 2016/12/09
 */
"use strict";
let redis = require('redis');
let configFile = require('../../include/commons').CONFIG_FILE;
let config = require('../../resources/config/' + configFile);
let log = require("../../util/log.js");
let redisPubClient = null;
class RedisPubClient {
    constructor() {
        var redisConfig = config.redisConfig;
            redisConfig.retry_strategy = function(options){
                log.info("pub Redis重新连接次数:"+options.times_connected);
                if (options.error.code === 'ECONNREFUSED') {
                    log.error('pub Redis连接被拒绝');
                }
                if (options.times_connected > 10) {
                    log.error('pub Redis重试连接超过十次');
                }
                return Math.max(options.attempt * 100, 3000);
            }
        this._connection = redis.createClient(
            config.redisConfig
        );
        this._connection.auth(config.redisConfig.password||"",function(){
            console.log('pub Redis通过认证');
        });
        this._connection.on('connect', function (res) {
            log.info('pub Redis is connected.');
        });
        this._connection.on('error', function (res) {
            log.error("pub Redis connect failed.");
        })
    }
    get connection() {
        return this._connection;
    }
    static redisClient() {
        if (redisPubClient == null) {
            redisPubClient = new RedisPubClient();
        }
        return redisPubClient;
    }
}
function uncaughtExceptionHandler(err){
    if(err && err.code == 'ECONNREFUSED'){
        //do someting
    }else{
        log.error(err+"exit in pub Redis");
    }
}
process.on('uncaughtException', uncaughtExceptionHandler);
module.exports = RedisPubClient;

+ 70 - 0
src/server/models/redis/redisSubClient.js

@ -0,0 +1,70 @@
/**
 * Redis客户端封装。
 * Redis客户端封装发布订阅(redis只要使用了发布订阅,这个client不能做其他操作)
 *
 * 注意Redis使用Promises保证调用流程。
 *
 * https://github.com/NodeRedis/node_redis
 *
 * author: linzhuo
 * since: 2016/12/09
 */
"use strict";
let redis = require('redis');
let configFile = require('../../include/commons').CONFIG_FILE;
let config = require('../../resources/config/' + configFile);
let log = require("../../util/log.js");
let redisSubClient = null;
class RedisSubClient {
    constructor() {
        var redisConfig = config.redisConfig;
            redisConfig.retry_strategy = function(options){
                log.info("sub Redis重新连接次数:"+options.times_connected);
                if (options.error.code === 'ECONNREFUSED') {
                    log.error('sub Redis连接被拒绝');
                }
                if (options.times_connected > 10) {
                    log.error('sub Redis重试连接超过十次');
                }
                return Math.max(options.attempt * 100, 3000);
            }
        this._connection = redis.createClient(
            config.redisConfig
        );
        this._connection.auth(config.redisConfig.password||"",function(){
            console.log('sub Redis通过认证');
        });
        this._connection.on('connect', function (res) {
            log.info('sub Redis is connected.');
        });
        this._connection.on('error', function (res) {
            log.error("sub Redis connect failed.");
        })
    }
    get connection() {
        return this._connection;
    }
    static redisClient() {
        if (redisSubClient == null) {
            redisSubClient = new RedisSubClient();
        }
        return redisSubClient;
    }
}
function uncaughtExceptionHandler(err){
    if(err && err.code == 'ECONNREFUSED'){
        //do someting
    }else{
        log.error(err+"exit in sub Redis");
    }
}
process.on('uncaughtException', uncaughtExceptionHandler);
module.exports = RedisSubClient;

+ 54 - 11
src/server/models/sessions/sessions.js

@ -25,6 +25,7 @@ let logger = require('../../util/log.js');
let mongoose = require('mongoose');
let async = require("async");
let log = require("../../util/log.js");
let pubSub = require("../redis/pubSub.js");
const REDIS_KEYS = require('../../include/commons').REDIS_KEYS;
const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
@ -1230,11 +1231,6 @@ class Sessions extends RedisModel {
                    participant.participant_role == PARTICIPANT_ROLES.HOST) {
                    Sessions.pushNotification(participant.id, participant.name, message,sessionType);
                }
                // if(agent&&participant.id == message.sender_id&&
                //     participant.participant_role == PARTICIPANT_ROLES.HOST){
                //     //有代理人时,也会发送消息给被代理者(此时)
                //     Sessions.pushNotification(participant.id, participant.name, message,sessionType);
                // }
            });
        }
    }
@ -1407,25 +1403,72 @@ class Sessions extends RedisModel {
        let self = this;
        Users.isPatientId(targetUserId, function (err, isPatient) {
            if (isPatient) {
                WechatClient.sendMessage(targetUserId, targetUserName, message);
            }
            else {
                if(config.environment!='prodPC'){//pc版不直接发送给居民,通过redis的publish
                    WechatClient.sendMessage(targetUserId, targetUserName, message);
                }
                message.targetUserId = targetUserId;
                message.targetUserName = targetUserName;
                message.sessionType = sessionType;
                message.targetType = 'patient';
            } else {
                if(sessionType==SESSION_TYPES.P2P){
                     WechatClient.sendReadDoctorByDoctorId(targetUserId, message);
                }
                //告知医生新消息
                WechatClient.sendSocketMessageToDoctor(targetUserId,message);
                WlyySDK.request(targetUserId, '', '', '', '/im/common/message/messages', 'POST', function (err, res) {
                if(config.environment!='prodPC'){//pc版不推送个推,通过redis的publish
                    WlyySDK.request(targetUserId, '', '', '', '/im/common/message/messages', 'POST', function (err, res) {
                        let count = 0;
                        res =  JSON.parse(res)
                        if (res.status == 200) {
                            let data = res.data;
                            count = parseInt(JSON.parse(data.imMsgCount).count) + parseInt(data.system.amount) + parseInt(data.healthIndex.amount) + parseInt(data.sign.amount);
                        }
                        AppClient.sendNotification(targetUserId, message,sessionType,count);
                    });
                }
                message.targetUserId = targetUserId;
                message.targetUserName = targetUserName;
                message.sessionType = sessionType;
                message.targetType = 'doctor';
            }
            //redis发布消息
            if(config.pubSubSwitch) {//接收订阅消息处理开关,本地运行和测试库单独运行时防止用户接收消息2次
                pubSub.publish(config.pubChannel,JSON.stringify(message));
            }
        });
    }
    /**
     * 获取redis订阅消息,并处理
     * @param targetUserId
     * @param targetUserName
     * @param message
     * @param sessionType
     */
    static getRedisPushNotification(message) {
        if (message.targetType=='patient') {
            if(config.environment!='prodPC'){//pc版接收要发给居民的消息不做处理
                WechatClient.sendMessage(message.targetUserId, message.targetUserName, message);
            }
        } else {
            if(message.sessionType==SESSION_TYPES.P2P){
                WechatClient.sendReadDoctorByDoctorId(message.targetUserId, message);
            }
            //告知医生新消息
            WechatClient.sendSocketMessageToDoctor(message.targetUserId,message);
            if(config.environment!='prodPC'){//pc版不推送个推
                WlyySDK.request(message.targetUserId, '', '', '', '/im/common/message/messages', 'POST', function (err, res) {
                    let count = 0;
                    res =  JSON.parse(res)
                    if (res.status == 200) {
                        let data = res.data;
                        count = parseInt(JSON.parse(data.imMsgCount).count) + parseInt(data.system.amount) + parseInt(data.healthIndex.amount) + parseInt(data.sign.amount);
                    }
                    AppClient.sendNotification(targetUserId, message,sessionType,count);
                    AppClient.sendNotification(message.targetUserId, message,message.sessionType,count);
                });
            }
        });
        }
    }
    /**

+ 20 - 8
src/server/models/user/users.js

@ -87,10 +87,11 @@ class Users extends RedisModel {
    login(userId, platform, deviceToken, clientId) {
        let self = this;
        let loginFromApp = platform !== PLATFORMS.Wechat;
        let loginFromPc = platform !== PLATFORMS.PC;
        log.error(userId+"  "+ platform+"  "+deviceToken+"  "+clientId);
        let usersKey = REDIS_KEYS.Users;
        let userKey = RedisModel.makeRedisKey(REDIS_KEYS.User, userId);
        let userStatusKey = RedisModel.makeRedisKey(loginFromApp ? REDIS_KEYS.UserAppStatus : REDIS_KEYS.UserWechatStatus, userId);
        let userStatusKey = RedisModel.makeRedisKey(loginFromApp ? REDIS_KEYS.UserAppStatus : (loginFromPc?REDIS_KEYS.UserPcStatus:REDIS_KEYS.UserWechatStatus), userId);
        let lastLoginTime = new Date();
        async.waterfall([
@ -126,7 +127,12 @@ class Users extends RedisModel {
                            'device_token', deviceToken,
                            'last_login_time', lastLoginTime.getTime(),
                            'platform', platform);
                    } else {
                    } else if(loginFromPc){
                        // cache pc status
                        multi = multi.hmset(userStatusKey,
                            'last_login_time', lastLoginTime.getTime(),
                            'platform', platform);
                    }else {
                        // cache wechat status
                        multi = multi.hmset(userStatusKey,
                            'last_login_time', lastLoginTime.getTime(),
@ -287,7 +293,7 @@ class Users extends RedisModel {
            });
    }
    logout(userId) {
    logout(userId,platform) {
        let self = this;
        async.waterfall([
                function (callback) {
@ -297,7 +303,12 @@ class Users extends RedisModel {
                },
                function (isPatient, callback) {
                    let usersKey = REDIS_KEYS.Users;
                    let userStatusKey = RedisModel.makeRedisKey(isPatient ? REDIS_KEYS.UserWechatStatus : REDIS_KEYS.UserAppStatus, userId);
                    let userStatusKey;
                    if(platform){
                        userStatusKey = RedisModel.makeRedisKey(isPatient ? REDIS_KEYS.UserWechatStatus : (platform==PLATFORM.PC?REDIS_KEYS.UserPcStatus:REDIS_KEYS.UserAppStatus), userId);
                    }else {
                        userStatusKey = RedisModel.makeRedisKey(isPatient ? REDIS_KEYS.UserWechatStatus :REDIS_KEYS.UserAppStatus, userId);
                    }
                    redisConn.multi()
                        .zrem(usersKey, userId)
                        .del(userStatusKey)
@ -313,10 +324,11 @@ class Users extends RedisModel {
                            log.error("Logout failed: ", ex);
                        });
                    AppStatusRepo.destroy(userId, function (err, res) {
                        if(err) log.error("Delete user status failed: " + err);
                    });
                    if(!platform||platform!=PLATFORM.PC){
                        AppStatusRepo.destroy(userId, function (err, res) {
                            if(err) log.error("Delete user status failed: " + err);
                        });
                    }
                    callback(null, null);
                }],
            function (err, res) {

+ 35 - 7
src/server/resources/config/config.dev.js

@ -9,6 +9,14 @@ let imDbConfig = {
    connectionLimit: '50',
    charset: 'utf8mb4'
};
// let imDbConfig = {
//     host: '172.19.103.77',
//     user: 'root',
//     password: '123456',
//     database: 'im_new',
//     connectionLimit: '50',
//     charset: 'utf8mb4'
// };
// Redis
let redisConfig = {
@ -18,10 +26,15 @@ let redisConfig = {
};
// 三师后台
// let wlyyServerConfig = {
//     host: '172.19.103.88',
//     port: 9092,
//     model:"/wlyy"
// };
let wlyyServerConfig = {
    host: '172.19.103.88',
    port: 9092,
    model:"/wlyy"
    host: '192.168.131.24',
    port: 8080,
    model:"/"
};
// 个推AppStore版参数
@ -40,14 +53,24 @@ let getTuiConfig = {
    MASTERSECRET: '9lpy5vEss46tVzP1RCJiC4'
};*/
// 微信配置
// let wechatConfig = {
//     appId: 'wxd03f859efdf0873d',
//     appSecret: '2935b54b53a957d9516c920a544f2537',
//     token: '27eb3bb24f149a7760cf1bb154b08040',
//     baseUrl: 'weixin.xmtyw.cn/wlyy',
//     template: {
//         consultTemplate: 'qSOW0DBxO3qEBm4ucG0Ial0jxsOyD7_f2TFK5e-mQEc'  // 咨询回复模板
//     }
// };
// 微信配置
let wechatConfig = {
    appId: 'wxd03f859efdf0873d',
    appSecret: '2935b54b53a957d9516c920a544f2537',
    appId: 'wx1f129f7b51701428',
    appSecret: '988f005d8309ed1795939e0f042431fb',
    token: '27eb3bb24f149a7760cf1bb154b08040',
    baseUrl: 'weixin.xmtyw.cn/wlyy',
    baseUrl: 'ehr.yihu.com/wlyy',
    template: {
        consultTemplate: 'qSOW0DBxO3qEBm4ucG0Ial0jxsOyD7_f2TFK5e-mQEc'  // 咨询回复模板
        consultTemplate: '-dr4QNyFoRvVsf8uWxXMC1dRyjwnbUuJwJ21vBLhf18'  // 咨询回复模板
    }
};
@ -66,6 +89,11 @@ let topicConfig = {
    TERMINATING_CRON: "* 30 * * * *"     // 议题自动关闭的任务执行时间间隔
};
exports.environment = 'dev';
exports.pubChannel = 'dev';
exports.subChannel = 'dev';
exports.pubSubSwitch = true;
exports.app = 'IM.Server';
exports.version = '2.0.0';
exports.debug = true;

+ 5 - 0
src/server/resources/config/config.prod.js

@ -58,6 +58,11 @@ let topicConfig = {
    TERMINATING_CRON: "* 59 * * * *"        // 议题自动关闭的任务执行时间间隔
};
exports.environment = 'prod';
exports.pubChannel = 'phone_to_pc';
exports.subChannel = 'pc_to_phone';
exports.pubSubSwitch = true;
exports.app = 'im.server';
exports.version = '2.0.0';
exports.debug = true;

+ 80 - 0
src/server/resources/config/config.prodPC.js

@ -0,0 +1,80 @@
"use strict";
let imDbConfig = {
    host: '59.61.92.94',
    user: 'im',
    password: 'im!)123',
    database: 'im',
    connectionLimit: '100',
    charset : 'utf8mb4'
};
// Redis
let redisConfig = {
    host: '120.41.253.95',
    port: 6380,
    db: 1,
    password:'jkzl_ehr'
};
// 三师后台
let wlyyServerConfig = {
    host: '120.41.252.108',
    port: 9660,
    model:"/wlyy"
};
// 个推AppStore版参数
let getTuiConfig = {
    HOST: 'https://api.getui.com/apiex.htm',
    APPID: 'qWmRh2X88l7HuE36z3qBe8',
    APPKEY: 'EzERfV8c849lBkZqHWzQG1',
    MASTERSECRET: 'veXiajQrId6iojy7Qv8kZ2'
};
// 微信配置
let wechatConfig = {
    appId: 'wxad04e9c4c5255acf',
    appSecret: 'ae77c48ccf1af5d07069f5153d1ac8d3',
    token: '27eb3bb24f149a7760cf1bb154b08040',
    baseUrl: 'www.xmtyw.cn/wlyy',
    template: {
        consultTemplate: '0mF_vHj-ILx8EH8DwzmAi7LqzjqYiU9IrSRRmziTZyc'  // 咨询回复模板
    }
};
// 会话配置
let sessionConfig = {
    maxMessageCount: 1000,                  // 会话缓存的消息数量
    maxMessageTimespan: 7 * 24 * 3600,      // 会话缓存的最大时间跨度
    expireTime: 3 * 60 * 60 * 1000,         // 会话过期时间,以毫秒计
    expireSessionCleanCount: 10             // 每次清理多少个过期会话
};
// 议题配置
let topicConfig = {
    TTL: 24,                                // 议题的存活时间,TTL = Time To Live
    TERMINATING_CRON: "* 59 * * * *"        // 议题自动关闭的任务执行时间间隔
};
exports.environment = 'prodPC';
exports.pubChannel = 'pc_to_phone';
exports.subChannel = 'phone_to_pc';
exports.pubSubSwitch = true;
exports.app = 'im.server';
exports.version = '2.0.0';
exports.debug = true;
exports.serverPort = 3000;
exports.sessionExpire = 1800;
exports.showSQL = false;
exports.imDbConfig = imDbConfig;
exports.redisConfig = redisConfig;
exports.getTuiConfig = getTuiConfig;
exports.wlyyServerConfig = wlyyServerConfig;
exports.wechatConfig = wechatConfig;
exports.sessionConfig = sessionConfig;
exports.topicConfig = topicConfig;

+ 5 - 0
src/server/resources/config/config.test.js

@ -56,6 +56,11 @@ let topicConfig = {
    TERMINATING_CRON: "* 30 * * * *"        // 议题自动关闭的任务执行时间间隔
};
exports.environment = 'test';
exports.pubChannel = 'test';
exports.subChannel = 'test';
exports.pubSubSwitch = true;
exports.app = 'im.server';
exports.version = '2.0.0';
exports.debug = true;