com.jim.im.offline.service.OfflineMessageServiceImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.jim.im.offline.service.OfflineMessageServiceImpl.java

Source

/*
 * Copyright 2014 Jim. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jim.im.offline.service;

import com.jim.im.exception.ImParamException;
import com.jim.im.mongo.entity.msg.ImMessage;
import com.jim.im.offline.repo.OfflineMessageRepo;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigInteger;
import java.util.Collection;

/**
 * @version 1.0
 */
@Service
public class OfflineMessageServiceImpl implements OfflineMessageService {
    @Autowired
    private OfflineMessageRepo offlineMessageRepo;

    @Override
    public Collection<ImMessage> getOfflineMessages(Collection<String> topics, BigInteger lastMessageId)
            throws ImParamException {
        return offlineMessageRepo.findByTopicNameIn(topics, new ObjectId(lastMessageId.toString(16)));
    }
}