package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxCouponType;
import com.iformall.mapper.WxCouponTypeMapper;
import com.iformall.service.WxCouponTypeService;
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 WxCouponTypeServiceImpl implements WxCouponTypeService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxCouponTypeMapper wxCouponTypeMapper;


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

    @Override
    public WxCouponType getById(Long id) {
        return wxCouponTypeMapper.selectById(id);
    }

    @Override
    public void saveOrUpdate(WxCouponType record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            wxCouponTypeMapper.insert(record);
        } else {
            wxCouponTypeMapper.updateById(record);
        }
    }

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