package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxUserChannel;
import com.iformall.mapper.WxUserChannelMapper;
import com.iformall.service.WxUserChannelService;
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 WxUserChannelServiceImpl implements WxUserChannelService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxUserChannelMapper wxUserChannelMapper;


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

    @Override
    public WxUserChannel getById(Long id) {
        return wxUserChannelMapper.selectById(id);
    }

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

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

	@Override
	public List<WxUserChannel> findDistinctChannel() {
	
		return wxUserChannelMapper.findDistinctChannel();
	}
    
    
    
    
}
