package com.iformall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxPayAccountBill;
import com.iformall.mapper.WxPayAccountBillMapper;
import com.iformall.service.WxPayAccountBillService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WxPayAccountBillServiceImpl implements WxPayAccountBillService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxPayAccountBillMapper wxPayAccountBillMapper;


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

    @Override
    public WxPayAccountBill getById(Long id) {
        return wxPayAccountBillMapper.selectById(id);
    }

    @Override
    public WxPayAccountBill getByTenantId(String tenantId) {
        WxPayAccountBill payAccountBillQ = new WxPayAccountBill();
        payAccountBillQ.setTenantId(tenantId);
        return wxPayAccountBillMapper.selectOne(new QueryWrapper(payAccountBillQ));
    }

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

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