package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxBLog;
import com.iformall.mapper.WxBLogMapper;
import com.iformall.service.WxBLogService;
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 WxBLogServiceImpl implements WxBLogService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxBLogMapper wxBLogMapper;


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

    @Override
    public WxBLog getById(Long id) {
        return wxBLogMapper.selectById(id);
    }

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

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