package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxChannel;
import com.iformall.mapper.WxChannelMapper;
import com.iformall.service.WxChannelService;
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 WxChannelServiceImpl implements WxChannelService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxChannelMapper wxChannelMapper;


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

    @Override
    public WxChannel getById(Long id) {
        return wxChannelMapper.selectById(id);
    }

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

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