Browse Source

成员替换,创建会话,人员先删除后写入

8 years ago
parent
commit
b39a5041fa

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

@ -52,7 +52,7 @@ router.post("/", function (req, res) {
    for (let j in participants) {
        participantArray.push(j + ":" + participants[j]);
    }
    console.error("payload"+JSON.stringify(payload));
    ControllerUtil.regModelEventHandler(sessions, res);
    sessions.createSession(sessionId, sessionName, sessionType, participantArray);
});

+ 10 - 9
src/server/models/sessions/sessions.js

@ -90,6 +90,8 @@ class Sessions extends RedisModel {
        for (let i in participantArray) {
            participantIdArray.push(participantArray[i].split(":")[0]);
        }
        logger.error("create session by participantIdArray,:"+participantIdArray.join(","));
        logger.error("create session by type,:"+type);
        if (type == SESSION_TYPES.P2P || type == SESSION_TYPES.SYSTEM) {
            if (sessionId) {
                callBusinessType(sessionId);
@ -112,13 +114,9 @@ class Sessions extends RedisModel {
        }
        function callBusinessType(sessionId) {
            if(type == SESSION_TYPES.MUC){
                callCreate(sessionId, 2);
            }else{
                ParticipantRepo.getBusinessType(participantIdArray.join("','"), function (err, businessType) {
                    callCreate(sessionId, businessType);
                });
            }
            ParticipantRepo.getBusinessType(participantIdArray, function (err, businessType) {
                callCreate(sessionId, businessType);
            });
        }
        function callCreate(sessionId, businessType) {
@ -132,6 +130,9 @@ class Sessions extends RedisModel {
                timestamp: createDate,
                id: messageId
            };
            if(type == SESSION_TYPES.MUC){
                businessType = 2;
            }
            let session = {
                id: sessionId,
                name: name,
@ -185,7 +186,7 @@ class Sessions extends RedisModel {
        //流程2-判断session的业务类型;
        function callBusinessType() {
            ParticipantRepo.getBusinessType(participantIdArray.join("','"), function (err, businessType) {
            ParticipantRepo.getBusinessType(participantIdArray, function (err, businessType) {
                if (err) {
                    handler(err, null);
                    return;
@ -236,7 +237,7 @@ class Sessions extends RedisModel {
                    handler(err, null);
                    return;
                }
                callBeginTrans(session);
                // callBeginTrans(session);
            })
        }

+ 3 - 3
src/server/repository/mysql/participant.repo.js

@ -103,15 +103,15 @@ class ParticipantRepo {
    }
    static getBusinessType(users, handler) {
        let sql = "SELECT count(1) as count FROM patients p WHERE p.id in ('" + users + "')";
        let sql = "SELECT count(1) as count FROM patients p WHERE p.id in (?)";
        ImDb.execQuery({
            "sql": sql,
            "args": [],
            "args": [users],
            "handler": function (err, res) {
                if (err) {
                    console.log("err businessType  : " + err);
                } else {
                    if (res[0].count) {
                    if (res[0].count>0) {
                        handler(err, SESSION_BUSINESS_TYPE.PATIENT);
                    } else {
                        handler(err, SESSION_BUSINESS_TYPE.DOCTOR);