Explorar o código

会话列表添加按姓名查找

bing %!s(int64=4) %!d(string=hai) anos
pai
achega
9f3b1590af

+ 6 - 4
src/server/endpoints/v2/session.endpoint.js

@ -159,6 +159,8 @@ router.get("/", function (req, res) {
    let userId = req.query.user_id;
    let businessType = req.query.business_type;
    let status = req.query.status;
    let name = req.query.name;
    let search_type = req.query.search_type;//搜索类型 1医生 2患者 3会话名称
    let videoconferencing = req.query.videoconferencing;
    if (!page) {
        throw {httpStatus: 406, message: 'Missing page.'};
@ -177,17 +179,17 @@ router.get("/", function (req, res) {
        sessions.conversionAarticipant(userId, (doctorid) => {
            //传入参数齐全走过滤方法
            if(status&&businessType&&doctorid&&size&&page){
                sessions.getUserStatusSessions(doctorid,status,businessType,page,size);
                sessions.getUserStatusSessions(doctorid,status,businessType,name,search_type,page,size);
            }else{
                sessions.getUserSessions(doctorid, page, size, businessType);
                sessions.getUserSessions(doctorid,name,search_type, page, size, businessType);
            }
        })
    }else{
        //传入参数齐全走过滤方法
        if(status&&businessType&&userId&&size&&page){
            sessions.getUserStatusSessions(userId,status,businessType,page,size);
            sessions.getUserStatusSessions(userId,status,businessType,name,search_type,page,size);
        }else{
            sessions.getUserSessions(userId, page, size, businessType);
            sessions.getUserSessions(userId,name,search_type, page, size, businessType);
        }
    }
});

+ 193 - 44
src/server/models/sessions/sessions.js

@ -412,7 +412,7 @@ class Sessions extends RedisModel {
     * @param size
     * @param businessType
     */
    getUserSessions(userId, page, size, businessType) {
    getUserSessions(userId,name,search_type, page, size, businessType) {
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        let self = this;
        if (page > 0) {
@ -658,6 +658,7 @@ class Sessions extends RedisModel {
                                            }
                                        }
                                    });
                                    participantsTimeJson["id"] = participantsTimeArray[j];
                                    participantsTimeJson[participantsTimeArray[j]] = participantsTimeArray[j+1];
                                    participantsTime.push(participantsTimeJson);
@ -713,29 +714,101 @@ class Sessions extends RedisModel {
                                                    let topicId = topic.id;
                                                });
                                            });
                                            sessionList.push({
                                                id: sessionId,
                                                name: sessionName,
                                                create_date: parseInt(session.create_date),
                                                last_content_type: session.last_content_type||"",
                                                last_content: session.last_content||"",
                                                sender_id: session.last_sender_id||"",
                                                last_message_time: session.last_message_time||"",
                                                type: session.type,
                                                sender_name: session.last_sender_name||"",
                                                unread_count: count,
                                                // business_type: session.business_type,
                                                business_type: businessType,
                                                my_role: role,
                                                sender_sex: sex,
                                                sender_birthday: bir,
                                                participantsTimeArray:participantsTime,
                                                status:session.status,
                                                is_invite:isInvite,
                                                backTopid:backTopid
                                            });
                                            var SearchExist=false;
                                            if (search_type==1&&name){//医生
                                                if (session.type!=2){
                                                    SearchExist = false;
                                                }
                                                else {
                                                    for (var tmpIndex in participantsTime){
                                                        var patientName = participantsTime[tmpIndex].name
                                                        var is_patient = participantsTime[tmpIndex].is_patient
                                                        if (is_patient=0&&(patientName+"").indexOf(name)!=-1){
                                                            SearchExist = true;
                                                        }
                                                    }
                                                }
                                                if((sessionName+"").indexOf(name)!=-1){SearchExist = true;}
                                            }
                                            if (search_type==2&&name){//患者
                                                if (session.type!=2){
                                                    SearchExist = false;
                                                }
                                                else{
                                                    for (var tmpIndex in participantsTime){
                                                        var patientName = participantsTime[tmpIndex].name
                                                        var is_patient = participantsTime[tmpIndex].is_patient
                                                        if (is_patient=1&&(patientName+"").indexOf(name)!=-1){
                                                            SearchExist = true;
                                                        }
                                                    }
                                                }
                                                if((sessionName+"").indexOf(name)!=-1){SearchExist = true;}
                                            }
                                            if (search_type==3&&name){
                                                if((sessionName+"").indexOf(name)!=-1){
                                                    sessionList.push({
                                                        id: sessionId,
                                                        name: sessionName,
                                                        create_date: new Date(session.last_message_time).getTime(),
                                                        last_content_type: session.last_content_type,
                                                        last_content: session.last_content,
                                                        sender_id: session.last_sender_id,
                                                        type: session.type,
                                                        sender_name: session.last_sender_name,
                                                        unread_count: count,
                                                        business_type: session.business_type,
                                                        my_role: role,
                                                        sender_sex: sex,
                                                        sender_birthday: bir,
                                                        participantsTimeArray:participantsTime,
                                                        status:session.status,
                                                        is_invite:isInvite
                                                    });
                                                }
                                            }
                                            else if(name&&(search_type==1||search_type==2)){
                                                if (SearchExist){
                                                    sessionList.push({
                                                        id: sessionId,
                                                        name: sessionName,
                                                        create_date: new Date(session.last_message_time).getTime(),
                                                        last_content_type: session.last_content_type,
                                                        last_content: session.last_content,
                                                        sender_id: session.last_sender_id,
                                                        type: session.type,
                                                        sender_name: session.last_sender_name,
                                                        unread_count: count,
                                                        business_type: session.business_type,
                                                        my_role: role,
                                                        sender_sex: sex,
                                                        sender_birthday: bir,
                                                        participantsTimeArray:participantsTime,
                                                        status:session.status,
                                                        is_invite:isInvite
                                                    });
                                                }
                                            }
                                            else{
                                                sessionList.push({
                                                    id: sessionId,
                                                    name: sessionName,
                                                    create_date: new Date(session.last_message_time).getTime(),
                                                    last_content_type: session.last_content_type,
                                                    last_content: session.last_content,
                                                    sender_id: session.last_sender_id,
                                                    type: session.type,
                                                    sender_name: session.last_sender_name,
                                                    unread_count: count,
                                                    business_type: session.business_type,
                                                    my_role: role,
                                                    sender_sex: sex,
                                                    sender_birthday: bir,
                                                    participantsTimeArray:participantsTime,
                                                    status:session.status,
                                                    is_invite:isInvite
                                                });
                                            }
                                            index = (parseInt(index) + 1);
                                            if (index == sessionIds.length) {
                                                ModelUtil.emitOK(self.eventEmitter, sessionList);
@ -1032,7 +1105,7 @@ class Sessions extends RedisModel {
     * @param size
     * @param businessType
     */
    getUserStatusSessions(userId,status,businessType,page, size) {
    getUserStatusSessions(userId,status,businessType,name,search_type,page, size) {
        let userSessionKey = RedisModel.makeRedisKey(REDIS_KEYS.UserSessions, userId);
        log.info(userId);
        let self = this;
@ -1144,26 +1217,102 @@ class Sessions extends RedisModel {
                                            if (res.length != 0 && res[0].sex) {
                                                sex = res[0].sex;
                                            }
                                            var SearchExist=false;
                                            if (search_type==1&&name){//医生
                                                if (session.type!=2){
                                                    SearchExist = false;
                                                }
                                                else{
                                                    for (var tmpIndex in participantsTime){
                                                        var patientName = participantsTime[tmpIndex].name
                                                        var is_patient = participantsTime[tmpIndex].is_patient
                                                        if (is_patient=0&&(patientName+"").indexOf(name)!=-1){
                                                            SearchExist = true;
                                                        }
                                                    }
                                                }
                                                if((sessionName+"").indexOf(name)!=-1){SearchExist = true;}
                                            }
                                            if (search_type==2&&name){//患者
                                                if (session.type!=2){
                                                    SearchExist = false;
                                                }
                                                else{
                                                    for (var tmpIndex in participantsTime){
                                                        var patientName = participantsTime[tmpIndex].name
                                                        var is_patient = participantsTime[tmpIndex].is_patient
                                                        if (is_patient=1&&(patientName+"").indexOf(name)!=-1){
                                                            SearchExist = true;
                                                        }
                                                    }
                                                }
                                                if((sessionName+"").indexOf(name)!=-1){SearchExist = true;}
                                            sessionList.push({
                                                id: sessionId,
                                                name: sessionName,
                                                create_date: new Date(mysqlSession.last_message_time).getTime(),
                                                last_content_type: session.last_content_type,
                                                last_content: session.last_content,
                                                sender_id: session.last_sender_id,
                                                type: session.type,
                                                sender_name: session.last_sender_name,
                                                unread_count: count,
                                                business_type: session.business_type,
                                                my_role: role,
                                                sender_sex: sex,
                                                sender_birthday: bir,
                                                participantsTimeArray:participantsTime,
                                                status:session.status,
                                                is_invite:isInvite
                                            });
                                            }
                                            if (search_type==3&&name){
                                                if((sessionName+"").indexOf(name)!=-1){
                                                    sessionList.push({
                                                        id: sessionId,
                                                        name: sessionName,
                                                        create_date: new Date(mysqlSession.last_message_time).getTime(),
                                                        last_content_type: session.last_content_type,
                                                        last_content: session.last_content,
                                                        sender_id: session.last_sender_id,
                                                        type: session.type,
                                                        sender_name: session.last_sender_name,
                                                        unread_count: count,
                                                        business_type: session.business_type,
                                                        my_role: role,
                                                        sender_sex: sex,
                                                        sender_birthday: bir,
                                                        participantsTimeArray:participantsTime,
                                                        status:session.status,
                                                        is_invite:isInvite
                                                    });
                                                }
                                            }
                                            else if(name&&(search_type==1||search_type==2)){
                                                if (SearchExist){
                                                    sessionList.push({
                                                        id: sessionId,
                                                        name: sessionName,
                                                        create_date: new Date(mysqlSession.last_message_time).getTime(),
                                                        last_content_type: session.last_content_type,
                                                        last_content: session.last_content,
                                                        sender_id: session.last_sender_id,
                                                        type: session.type,
                                                        sender_name: session.last_sender_name,
                                                        unread_count: count,
                                                        business_type: session.business_type,
                                                        my_role: role,
                                                        sender_sex: sex,
                                                        sender_birthday: bir,
                                                        participantsTimeArray:participantsTime,
                                                        status:session.status,
                                                        is_invite:isInvite
                                                    });
                                                }
                                            }
                                            else{
                                                sessionList.push({
                                                    id: sessionId,
                                                    name: sessionName,
                                                    create_date: new Date(mysqlSession.last_message_time).getTime(),
                                                    last_content_type: session.last_content_type,
                                                    last_content: session.last_content,
                                                    sender_id: session.last_sender_id,
                                                    type: session.type,
                                                    sender_name: session.last_sender_name,
                                                    unread_count: count,
                                                    business_type: session.business_type,
                                                    my_role: role,
                                                    sender_sex: sex,
                                                    sender_birthday: bir,
                                                    participantsTimeArray:participantsTime,
                                                    status:session.status,
                                                    is_invite:isInvite
                                                });
                                            }
                                            index = (parseInt(index) + 1);
                                            if (index == sessionIds.length) {
                                                ModelUtil.emitOK(self.eventEmitter, sessionList);