package cn.superdesk.uniorder.service.kafka.impl;

import cn.superdesk.uniorder.common.numerical.AnCollectionUtils;
import cn.superdesk.uniorder.dao.entity.kafka.KafkaConsumerRecordOffset;
import cn.superdesk.uniorder.dao.entity.kafka.KafkaConsumerRecordOffsetExample;
import cn.superdesk.uniorder.dao.mapper.kafka.KafkaConsumerRecordOffsetMapper;
import cn.superdesk.uniorder.service.kafka.KafkaConsumerRecordOffsetService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 5/13/20 8:49 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 5/13/20 8:49 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Service
public class KafkaConsumerRecordOffsetServiceImpl implements KafkaConsumerRecordOffsetService {

    @Autowired
    private KafkaConsumerRecordOffsetMapper kafkaConsumerRecordOffsetMapper;

    @Override
    public PageInfo<KafkaConsumerRecordOffset> findByPaging(Map<String, Object> params, Integer pageNo, Integer pageSize) {
        return null;
    }

    @Override
    public void deleteObj(Long id) {


        KafkaConsumerRecordOffsetExample example = new KafkaConsumerRecordOffsetExample();
        example.createCriteria().andIdEqualTo(id);

        kafkaConsumerRecordOffsetMapper.deleteByExample(example);

    }

    @Override
    public int updateByPrimaryKeySelective(KafkaConsumerRecordOffset kafkaConsumerRecordOffset) {

        return kafkaConsumerRecordOffsetMapper.updateByPrimaryKeySelective(kafkaConsumerRecordOffset);
    }

    @Override
    public KafkaConsumerRecordOffset findById(Long id) {

        KafkaConsumerRecordOffset entity = null;

        KafkaConsumerRecordOffsetExample example = new KafkaConsumerRecordOffsetExample();
        example.createCriteria().andIdEqualTo(id);

        List<KafkaConsumerRecordOffset> result = kafkaConsumerRecordOffsetMapper.selectByExample(example);

        if (AnCollectionUtils.isNotEmpty(result)) {
            entity = result.get(0);
        }
        return entity;

    }

    @Override
    public int insertSelective(KafkaConsumerRecordOffset kafkaConsumerRecordOffset) {
        return kafkaConsumerRecordOffsetMapper.insertSelective(kafkaConsumerRecordOffset);
    }

    @Override
    public List<KafkaConsumerRecordOffset> findAll(Map<String, Object> queryMap) {
        return null;
    }
}
