|  | @ -8,10 +8,9 @@ let redisClient = RedisClient.redisClient();
 | 
	
		
			
				|  |  | let redis = redisClient.connection;
 | 
	
		
			
				|  |  | let RedisModel = require('./../redis.model.js');
 | 
	
		
			
				|  |  | let modelUtil = require('../../util/model.util');
 | 
	
		
			
				|  |  | let imDb = require('../../repository/mysql/db/im.db');
 | 
	
		
			
				|  |  | let ParticipantRepo = require('../../repository/mysql/participant.repo');
 | 
	
		
			
				|  |  | let log = require('../../util/log.js');
 | 
	
		
			
				|  |  | const RedisKey = require('../../include/commons').REDIS_KEYS;
 | 
	
		
			
				|  |  | const IMTABLE = require('../../include/commons').IM_DB;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | class Participants extends RedisModel {
 | 
	
		
			
				|  |  |     constructor() {
 | 
	
	
		
			
				|  | @ -40,17 +39,7 @@ class Participants extends RedisModel {
 | 
	
		
			
				|  |  |                     handler(res);
 | 
	
		
			
				|  |  |                 })
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 let sql ="select w.* from participants w where w.session_id =? ";
 | 
	
		
			
				|  |  |                 imDb.execQuery({
 | 
	
		
			
				|  |  |                     "sql": sql,
 | 
	
		
			
				|  |  |                     "args": [sessionId],
 | 
	
		
			
				|  |  |                     "handler": function (err, res) {
 | 
	
		
			
				|  |  |                         if(err) {
 | 
	
		
			
				|  |  |                             log.error("getParticipantsBySessionId is fail error: "+err);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         handler(res);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 });
 | 
	
		
			
				|  |  |                 ParticipantRepo.getParticipantsBySessionId(sessionId,handler);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         })
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -76,17 +65,7 @@ class Participants extends RedisModel {
 | 
	
		
			
				|  |  |                   handler(exists);
 | 
	
		
			
				|  |  |               })
 | 
	
		
			
				|  |  |           }else{//不存在从数据库中获取
 | 
	
		
			
				|  |  |               let sql ="select count(1) as count from participants w where w.session_id =? and w.participaint_id = ? ";
 | 
	
		
			
				|  |  |               imDb.execQuery({
 | 
	
		
			
				|  |  |                   "sql": sql,
 | 
	
		
			
				|  |  |                   "args": [sessionId,userId],
 | 
	
		
			
				|  |  |                   "handler": function (err, res) {
 | 
	
		
			
				|  |  |                       if(err) {
 | 
	
		
			
				|  |  |                           log.error("existsUser is fail error: "+err);
 | 
	
		
			
				|  |  |                       }
 | 
	
		
			
				|  |  |                       handler(res[0].count);
 | 
	
		
			
				|  |  |                   }
 | 
	
		
			
				|  |  |               });
 | 
	
		
			
				|  |  |               ParticipantRepo.existsUser(sessionId,userId,handler);
 | 
	
		
			
				|  |  |           }
 | 
	
		
			
				|  |  |       })
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -98,20 +77,7 @@ class Participants extends RedisModel {
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     getSessionIdByParticipants(patient,doctor,handler){
 | 
	
		
			
				|  |  |         let sql ="select session_id from "+IMTABLE.PARTICIPANTS+" p1 ,participants p2 " +
 | 
	
		
			
				|  |  |             "where p1.session_id = p2.session_id and " +
 | 
	
		
			
				|  |  |             "((p1.participaint_id = ? and p2.participaint_id = ?) or (p1.participaint_id = ? and p2.participaint_id = ?))"
 | 
	
		
			
				|  |  |         imDb.execQuery({
 | 
	
		
			
				|  |  |             "sql": sql,
 | 
	
		
			
				|  |  |             "args": [patient,doctor,doctor,patient],
 | 
	
		
			
				|  |  |             "handler": function (err, res) {
 | 
	
		
			
				|  |  |                 if(err) {
 | 
	
		
			
				|  |  |                     log.error("getSessionIdByParticipants is fail error: "+err);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 handler(err,res);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         ParticipantRepo.getSessionIdByParticipants(patient,doctor,handler);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -140,28 +106,7 @@ class Participants extends RedisModel {
 | 
	
		
			
				|  |  |      * @param users
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     createParticipantsToMysql(session_id,users){
 | 
	
		
			
				|  |  |         let sql="insert into "+IMTABLE.PARTICIPANTS +" (session_id,participaint_id,participaint_role,receiving) VALUES "
 | 
	
		
			
				|  |  |         let args=[];
 | 
	
		
			
				|  |  |         for(var j in users){
 | 
	
		
			
				|  |  |             sql+="(?,?,?,?),";
 | 
	
		
			
				|  |  |             args.push(session_id);
 | 
	
		
			
				|  |  |             args.push(users[j]);
 | 
	
		
			
				|  |  |             args.push(0);
 | 
	
		
			
				|  |  |             args.push(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql = sql.substring(0,sql.lastIndexOf(","));
 | 
	
		
			
				|  |  |         imDb.execQuery({
 | 
	
		
			
				|  |  |             "sql": sql,
 | 
	
		
			
				|  |  |             "args": args,
 | 
	
		
			
				|  |  |             "handler": function (err, res) {
 | 
	
		
			
				|  |  |                 if(err) {
 | 
	
		
			
				|  |  |                     log.error("createParticipantsForMysql is fail error: "+err+",session_id:"+session_id+",users:"+users.join(","));
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                    return res;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         return true;
 | 
	
		
			
				|  |  |         return createParticipantsToMysql(session_id,users);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 |