| 
					
				 | 
			
			
				@ -80,6 +80,7 @@ class Participants extends RedisModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param handler 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    getSessionIdByParticipants(patient, doctor, handler) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ParticipantRepo.findSessionIdByParticipantIds(patient, doctor, handler); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -144,28 +145,23 @@ class Participants extends RedisModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    deleteUser(sessionId, userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    removeUser(sessionId, userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let participants_key = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let user_session_key = RedisModel.makeRedisKey(REDIS_KEYS.UsersSessions, userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.移除SESSION成员表中的成员信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        redis.zremAsync(participants_key, userId).then(function (res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            log.info("remove participants:" + res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //2.删除对应人员的Session列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            redis.zremAsync(user_session_key, sessionId).then(function (res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                log.info("remove user_session:" + res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //3.移除数据库中的人员记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 移除会话中的成员信息,用户的Session信息及MySQL中的记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        redis.multi() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            .zrem(participants_key, userId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            .zrem(user_session_key, sessionId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            .execAsync() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            .then(function (res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                self.deleteUserFromMysql(sessionId, userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ModelUtil.emitOK(self.eventEmitter, {"status": 200, "msg": "人员删除成功!"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }).catch(function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ModelUtil.emitOK(self.eventEmitter, {"status": -1, "msg": "人员删除失败!" + err}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ModelUtil.emitOK(self.eventEmitter, {}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }).catch(function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ModelUtil.emitOK(self.eventEmitter, {"status": -1, "msg": "人员删除失败!" + err}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            .catch(function (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ModelUtil.emitError(self.eventEmitter, {message: "成员删除失败: " + err}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -175,12 +171,12 @@ class Participants extends RedisModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param role 变更状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    updateUser(sessionId, user, role) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let participants_role_key = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipantsRole, sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        redis.hsetAsync(sessionId, user, role).then(function (res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ParticipantRepo.updateParticipant(sessionId, user, role, function (err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let participantsRoleKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipantsRole, sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        redis.hsetAsync(participantsRoleKey, user, role) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            .then(function (res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ParticipantRepo.updateParticipant(sessionId, user, role, function (err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -190,13 +186,12 @@ class Participants extends RedisModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    addUser(sessionId, user) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let users = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        users.push(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let users = [user]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        self.saveParticipantsToRedis(sessionId, users, new Date(), function (res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                self.saveParticipantsToMysql(sessionId, users); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ModelUtil.emitOK(self.eventEmitter, {"status": -1, "msg": "人员添加失败!"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ModelUtil.emitOK(self.eventEmitter, {message: "成员添加失败"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -209,7 +204,6 @@ class Participants extends RedisModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    deleteUserFromMysql(sessionId, user) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ParticipantRepo.deleteUserFromMysql(sessionId, user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// Expose class 
			 |