Pārlūkot izejas kodu

医生socket开发

8 gadi atpakaļ
vecāks
revīzija
b18bdd7a30

+ 8 - 0
src/server/models/sessions/sessions.js

@ -1003,6 +1003,14 @@ class Sessions extends RedisModel {
                            res.forEach(function (participant) {
                                if (participant.id == message.sender_id){
                                    message.sender_img = participant.avatar;
                                    if(participant.participant_role == PARTICIPANT_ROLES.REGULAR){
                                        if (message.content_type == CONTENT_TYPES.PlainText ||
                                            message.content_type == CONTENT_TYPES.Image ||
                                            message.content_type == CONTENT_TYPES.Audio||
                                            message.content_type == CONTENT_TYPES.Video){
                                                 participants.updateUser(sessionId,message.sender_id,PARTICIPANT_ROLES.HOST);
                                        }
                                    }
                                    callPush(res,message);
                                }
                            })

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

@ -7,7 +7,8 @@ let ImDb = require('../mysql/db/im.db');
let log = require('../../util/log.js');
const DB_TABLES = require('../../include/commons').DB_TABLES;
const PARTICIPANT_ROLES = require('../../include/commons').PARTICIPANT_ROLES;
const SESSION_STATUS = require('../../include/commons').SESSION_STATUS;
class SessionRepo {
    constructor() {
    }
@ -77,16 +78,36 @@ class SessionRepo {
                page = (parseInt(page)-1) * parseInt(pagesize);
            }
        }
        let sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? group by w.session_id";
        let sessionSQL = "select * from "
            + DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type = ? and s.status = ? limit "+page+","+pagesize;
        ImDb.execQuery({
            "sql": sessionSQL,
            "args": [userId, businessType,status],
            "handler": handler || function (err, res) {
                if(err) log.error(err);
            }
        });
        let sessionSQL ="";
        let sql ="";
        if(status == SESSION_STATUS.ENDED){
            //找出已经结束的咨询
            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 * from "
                + DB_TABLES.Sessions + " s 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) limit "+page+","+pagesize;
            ImDb.execQuery({
                "sql": sessionSQL,
                "args": [userId, businessType,userId,businessType],
                "handler": handler || function (err, res) {
                    if(err) log.error(err);
                }
            });
        }else{
            sql = "select session_id from " + DB_TABLES.Participants + " w where w.participant_id = ? and participant_role ="+PARTICIPANT_ROLES.HOST+" group by w.session_id";
            sessionSQL =  "select * from "
                + DB_TABLES.Sessions + " s where s.id in(" + sql + ") and s.business_type = ? and s.status = ? limit "+page+","+pagesize;
            ImDb.execQuery({
                "sql": sessionSQL,
                "args": [userId, businessType,status],
                "handler": handler || function (err, res) {
                    if(err) log.error(err);
                }
            });
        }
    }
    /**