package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxProfitSharingResult;
import com.iformall.mapper.WxProfitSharingResultMapper;
import com.iformall.service.WxProfitSharingResultService;
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 WxProfitSharingResultServiceImpl implements WxProfitSharingResultService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxProfitSharingResultMapper wxProfitSharingResultMapper;


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

    @Override
    public WxProfitSharingResult getById(Long id) {
        return wxProfitSharingResultMapper.selectById(id);
    }

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

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