package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxCarPayRecord;
import com.iformall.mapper.WxCarPayRecordMapper;
import com.iformall.service.WxCarPayRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author luozukai
 * @date 2019/1/16 17:37
 */
@Service
public class WxCarPayRecordServiceImpl implements WxCarPayRecordService{
    @Autowired
    private WxCarPayRecordMapper wxCarPayRecordMapper;

    @Override
    public PageInfo<WxCarPayRecord> findCarPayListByPage(WxCarPayRecord record,Integer pageIndex, Integer pageSize) {
        return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCarPayRecordMapper.findCarPayListByPage(record));
    }

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

    @Override
    public void updateBySynId(WxCarPayRecord record) {
        wxCarPayRecordMapper.updateBySynId(record);
    }

    @Override
    public Integer findCarPayCount(WxCarPayRecord record) {
        return wxCarPayRecordMapper.findCarPayCount(record);
    }
}
