package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxScoreHistory;
import com.iformall.mapper.WxScoreHistoryMapper;
import com.iformall.service.WxScoreHistoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

import java.util.Date;

@Service
public class WxScoreHistoryServiceImpl implements WxScoreHistoryService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxScoreHistoryMapper wxScoreHistoryMapper;


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

    @Override
    public WxScoreHistory getById(Long id) {
        return wxScoreHistoryMapper.selectById(id);
    }

    @Override
    public void saveOrUpdate(WxScoreHistory record) {
        if (record.getId() == null) {
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
        	record.setCreateDate(new Date());
            wxScoreHistoryMapper.insert(record);
        } else {
            wxScoreHistoryMapper.updateById(record);
        }
    }

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