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.WxCouponSendConfig;
import com.iformall.mapper.WxCouponSendConfigMapper;
import com.iformall.service.WxCouponSendConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;


@Service
public class WxCouponSendConfigServiceImpl implements WxCouponSendConfigService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxCouponSendConfigMapper wxCouponSendConfigMapper;


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

    @Override
    public WxCouponSendConfig getById(Long id) {
        return wxCouponSendConfigMapper.selectById(id);
    }
	
	@Override
    public void saveOrUpdate(WxCouponSendConfig record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            record.setCreateTime(new Date());
            wxCouponSendConfigMapper.insert(record);
        } else {
            record.setUpdateTime(new Date());
            wxCouponSendConfigMapper.updateById(record);
        }
    }

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

    @Override
    public void update(WxCouponSendConfig record) {
        wxCouponSendConfigMapper.updateById(record);
    }


    
    
    
    
    
    
}
