package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxScoreValidityPeriod;
import com.iformall.mapper.WxScoreValidityPeriodMapper;
import com.iformall.service.WxScoreValidityPeriodService;
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;

@Service
public class WxScoreValidityPeriodServiceImpl implements WxScoreValidityPeriodService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxScoreValidityPeriodMapper wxScoreValidityPeriodMapper;


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

    @Override
    public WxScoreValidityPeriod getById(Long id) {
        return wxScoreValidityPeriodMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveOrUpdate(WxScoreValidityPeriod record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            wxScoreValidityPeriodMapper.insertSelective(record);
        } else {
            wxScoreValidityPeriodMapper.updateByPrimaryKeySelective(record);
        }
    }

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