LAPTOP-KB9HII50\70708 преди 2 години
родител
ревизия
c0e028567d

+ 2 - 1
src/server/endpoints/v2/session.endpoint.js

@ -83,6 +83,7 @@ router.get("/", function (req, res) {
    let size = req.query.size;
    let userId = req.query.user_id;
    let businessType = req.query.business_type;
    let sessionType = req.query.type;
    let status = req.query.status;
    if (!page) {
        throw {httpStatus: 406, message: 'Missing page.'};
@ -98,7 +99,7 @@ router.get("/", function (req, res) {
    ControllerUtil.regModelEventHandler(sessions, res);
    //传入参数齐全走过滤方法
    if(status&&businessType&&userId&&size&&page){
        sessions.getUserStatusSessions(userId,status,businessType,page,size);
        sessions.getUserStatusSessions(userId,status,sessionType,businessType,page,size);
    }else{
        sessions.getUserSessions(userId, page, size, businessType);
    }

+ 2 - 2
src/server/models/sessions/sessions.js

@ -823,14 +823,14 @@ class Sessions extends RedisModel {
     * @param size
     * @param businessType
     */
    getUserStatusSessions(userId,status,businessType,page, size) {
    getUserStatusSessions(userId,status,sessionType,businessType,page, size) {
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        log.info(userId);
        let self = this;
        async.waterfall([
            // 获取会话ID列表
            function (callback) {
                SessionRepo.findAllByTypeAndStatus(userId,businessType,status,page,size,function(err,res){
                SessionRepo.findAllByTypeAndStatus(userId,sessionType,businessType,status,page,size,function(err,res){
                    if (res.length == 0) {
                        ModelUtil.emitOK(self.eventEmitter, []);
                        return;

+ 11 - 5
src/server/repository/mysql/session.repo.js

@ -190,7 +190,7 @@ class SessionRepo {
        });
    }
    static findAllByTypeAndStatus(userId, businessType,status,page,pagesize, handler) {
    static findAllByTypeAndStatus(userId,sessionType, businessType,status,page,pagesize, handler) {
        if (page > 0) {
            if (page == 1) {
                page = 0;
@ -206,10 +206,16 @@ class SessionRepo {
                sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ?  group by w.session_id";
                //找出角色讨论组中为旁听且未结束的咨询
                let sql1 = ("select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.REGULAR+" group by w.session_id")
                sessionSQL =  "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
                    " where ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
                    // " and s.id = p.session_id and p.participant_id = ? ORDER BY (p.last_fetch_time - s.last_message_time+1)>0,s.create_date desc limit "+page+","+pagesize;
                    " and s.id = p.session_id and p.participant_id = ? ORDER BY s.last_message_time desc limit "+page+","+pagesize;
                if(sessionType){
                    sessionSQL =  "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
                        " where s.type='"+sessionType+"' and  ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
                        " and s.id = p.session_id and p.participant_id = ? ORDER BY s.last_message_time desc limit "+page+","+pagesize;
                }else {
                    sessionSQL =  "select s.* from " + DB_TABLES.Sessions + " s, " + DB_TABLES.Participants + " p " +
                        " where ((s.id in(" + sql + ") and s.business_type = ? and s.status = 1) or (s.id in(" + sql1 + ") and s.business_type = ? and s.status = 0)) " +
                        " and s.id = p.session_id and p.participant_id = ? ORDER BY s.last_message_time desc limit "+page+","+pagesize;
                }
                log.info("1."+sessionSQL);
                ImDb.execQuery({
                    "sql": sessionSQL,

+ 100 - 0
src/server/resources/config/config.laprod.js

@ -0,0 +1,100 @@
"use strict";
let imDbConfig = {
    host: '192.10.20.42',
    user: 'root',
    password: '1jMQNUAZXip#!0B^',
    database: 'im_new',
    connectionLimit: '50',
    charset: 'utf8mb4'
};
// Redis
let redisConfig = {
    host: '192.10.20.42',
    port: 6379,
    db: 1,
    password:'Kb6wKDQP1W4'
};
// let redisConfig = {
//     host: '192.168.1.220',
//     port: 6379,
//     db: 1
// };
// 内网Redis
let innerRedisConfig = {
    host: '192.10.20.42',
    port: 6379,
    db: 1,
    password:'Kb6wKDQP1W4'
};
// 三师后台
let wlyyServerConfig = {
    host: '192.10.20.43',
    port: 8081,
    model:"/wlyy"
};
//医生助手配置
let wlyyDAServerConfig = {
    host: '174',
    port: 8080,
    model:"/wlyy"
};
// 个推AppStore版参数
let getTuiConfig = {
    HOST: 'https://api.htm',
    APPID: 'H6FY3uH7V6',
    APPKEY: '0PFWlFWVgYA',
    MASTERSECRET: 'pODkxc816'
};
// 微信配置
let wechatConfig = {
    appId: 'wx1f11428',
    appSecret: '988f042431fb',
    token: '27eb3bb1bb154b08040',
    accId: 'gh_ffb21',
    baseUrl: 'http://ehwlyy',
    template: {
        consultTemplate: '-dr4QNywJ21vBLhf18'  // 咨询回复模板
    }
};
// 会话配置
let sessionConfig = {
    maxMessageCount: 1000,                  // 会话缓存的消息数量
    maxMessageTimespan: 7 * 24 * 3600,      // 会话缓存的最大时间跨度
    expireSessionCleanCount: 10             // 每次清理多少个过期会话
};
// 议题配置
let topicConfig = {
    TTL: 24,                                // 议题的存活时间,TTL = Time To Live
    TERMINATING_CRON: "* 30 * * * *"        // 议题自动关闭的任务执行时间间隔
};
exports.environment = 'laprod';
exports.pubChannel = 'prod';
exports.subChannel = 'dev';
exports.pubSubSwitch = false;
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.innerRedisConfig = innerRedisConfig;
exports.getTuiConfig = getTuiConfig;
exports.wlyyServerConfig = wlyyServerConfig;
exports.wlyyDAServerConfig = wlyyDAServerConfig;
exports.wechatConfig = wechatConfig;
exports.sessionConfig = sessionConfig;
exports.topicConfig = topicConfig;