소스 검색

Merge branch 'im-internet-hospital' of http://192.168.1.220:10080/Amoy/im.doctor into im-internet-hospital

wangzhinan 4 년 전
부모
커밋
45d280cdcc
4개의 변경된 파일72개의 추가작업 그리고 0개의 파일을 삭제
  1. 17 0
      src/server/endpoints/v2/session.endpoint.js
  2. 1 0
      src/server/include/commons.js
  3. 1 0
      src/server/include/endpoints.js
  4. 53 0
      src/server/models/sessions/participants.js

+ 17 - 0
src/server/endpoints/v2/session.endpoint.js

@ -458,6 +458,23 @@ router.post(APIv2.Sessions.ParticipantUpdate, function (req, res) {
    participants.updateSessionUser(payload.user_id, payload.old_user_id, payload.session_id);
});
/**
 * 增加活跃成员
 * user_id:增加的人员
 * old_user_id:删除的人员
 * session_id 会话ID
 */
router.post(APIv2.Sessions.ParticipantUpdateNew, function (req, res) {
    let payload = req.body;
    let testing = ObjectUtil.fieldsCheck(payload, 'user_id', 'session_id');
    if (!testing.pass) {
        throw testing.message;
    }
    let participants = new Participants();
    ControllerUtil.regModelEventHandler(participants, res);
    participants.updateSessionUser0(payload.user_id, payload.old_user_id, payload.session_id);
});
/**
 * 移除成员

+ 1 - 0
src/server/include/commons.js

@ -117,6 +117,7 @@ const CONTENT_TYPES = {
    ChangeDoorCardInfo: 2102,//上门服务-修改工单卡片信息
    ChangeDoorDoctor: 2103,//上门服务-变更工单医生信息
    ChangeDoorPackageItems:2104, //上门服务-变更工单服务项信息
    InformedConsent:2105,//知情通知书
    typeToDescription: function (type, defaultDescription) {
        if (CONTENT_TYPES.Image == type) {
            return '[图片]';

+ 1 - 0
src/server/include/endpoints.js

@ -65,6 +65,7 @@ const APIv2 = {
        SessionUnreadMessages: '/:session_id/messages/unread',          // 会话未读消息
        ParticipantUpdate:'/:session_id/participant/update',            //更新成员=删除旧成员,新增新成员
        ParticipantUpdateNew:'/:session_id/participant/updateNew',            //更新成员=删除旧成员,新增新活跃成员
        Participants: '/:session_id/participants',                      // 会话所有成员
        ParticipantsAvatar: '/:session_id/participants/avatars',        // 会话所有成员头像
        Participant: '/:session_id/participants/:participant_id',       // 会话单个成员(多个participant_id 用英文逗号间隔)

+ 53 - 0
src/server/models/sessions/participants.js

@ -426,6 +426,59 @@ class Participants extends RedisModel {
            }
        })
    }
    /**
     * 新增活跃成员
     * @param userId
     * @param oldUserId
     * @param sessionId
     */
    updateSessionUser0(userId,oldUserId,sessionId){
        let self = this;
        let participantsRoleKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipantsRole, sessionId);
        SessionRepo.findOne(sessionId,function(err,res){
            if(err){
                ModelUtil.emitOK(self.eventEmitter, {status:-1,message: "会话查询失败!"});
                return;
            }
            if(res && res.length!=1){
                ModelUtil.emitOK(self.eventEmitter, {status:200,message: "用户未创建咨询!"});
                return;
            }else{
                let session = res[0];
                if(oldUserId){
                    redis.hgetAsync(participantsRoleKey,oldUserId).then(function(role){
                        if(!role)role = 0;
                        self.deleteUserFromMysql(session.id,userId,function(err,addResult){
                            if(err){
                                ModelUtil.emitOK(self.eventEmitter, {status:-1,message: "会话成员添加失败!"});
                                return;
                            }
                            self.removeUser(session.id,oldUserId,function(err,res){
                                if(err){
                                    ModelUtil.emitOK(self.eventEmitter, {status:-1,message: "会话成员移除失败!"});
                                    return;
                                }else{
                                    ModelUtil.emitOK(self.eventEmitter, {status:200,message: "成员变更成功!"});
                                    return;
                                }
                            })
                        });
                    })
                }else{
                    self.addUser(session.id,userId,"0",function(err,addResult){
                        if(!err){
                            ModelUtil.emitOK(self.eventEmitter, {status:200,message: "成员变更成功!"});
                            return;
                        }else{
                            ModelUtil.emitOK(self.eventEmitter, {status:-1,message: "成员变更失败!"});
                            return;
                        }
                    });
                }
            }
        })
    }
}
// Expose class