package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.mapper.WxPayAccountMapper;
import com.iformall.service.WxPayAccountService;
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 WxPayAccountServiceImpl implements WxPayAccountService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxPayAccountMapper wxPayAccountMapper;


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

    @Override
    public WxPayAccount getById(Long id) {
        return wxPayAccountMapper.selectById(id);
    }

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

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