package com.iformall.service.kw.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.common.ResultData;
import com.iformall.domain.po.KwBoxCmdHistory;
import com.iformall.domain.po.KwMeter;
import com.iformall.mapper.KwBoxCmdHistoryMapper;
import com.iformall.service.kw.KwBoxCmdHistoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class KwBoxCmdHistoryServiceImpl implements KwBoxCmdHistoryService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    KwBoxCmdHistoryMapper kwBoxCmdHistoryMapper;

    @Override
    public PageInfo<KwBoxCmdHistory> listAsPage(KwBoxCmdHistory record, Integer pageIndex, Integer pageSize) {
        return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> kwBoxCmdHistoryMapper.findList(record));
    }

    @Override
    public KwBoxCmdHistory getById(Long id) {
        return kwBoxCmdHistoryMapper.selectById(id);
    }


    @Override
    public void saveOrUpdate(KwBoxCmdHistory record) {
        if (record.getId() == null) {
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            kwBoxCmdHistoryMapper.insert(record);
        } else {
            kwBoxCmdHistoryMapper.updateById(record);
        }
    }


    @Override
    public void deleteById(Long id) {
        kwBoxCmdHistoryMapper.deleteById(id);
    }

    @Override
    public List<KwBoxCmdHistory> findList(KwBoxCmdHistory record) {
        return kwBoxCmdHistoryMapper.findList(record);
    }


}
