package me.zhengjie.modules.dm.messageSendLog.service.impl;

import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.dm.messageSendLog.domain.DmMessageSendLog;
import me.zhengjie.modules.dm.messageSendLog.service.DmMessageSendLogService;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.awt.print.Pageable;
import java.util.List;

@Service
@RequiredArgsConstructor
public class DmMessageSendLogServiceImpl implements DmMessageSendLogService {

    @Resource
    private MongoTemplate mongoTemplate;

    @Override
    public long getCount() {
        Query query = new Query();
        long count = mongoTemplate.count(query, DmMessageSendLog.class);
        return count;
    }

    @Override
    public DmMessageSendLog create(DmMessageSendLog resources) {
        return  mongoTemplate.save(resources);
    }

    @Override
    public DmMessageSendLog findById(String id) {
        Query query=new Query(Criteria.where("_id").is(id));
        return mongoTemplate.findById(query,DmMessageSendLog.class);
    }

    @Override
    public List<DmMessageSendLog> queryAll() {
        return mongoTemplate.findAll(DmMessageSendLog.class);
    }

}
