package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxPark;
import com.iformall.mapper.WxParkMapper;
import com.iformall.service.WxParkService;
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 WxParkServiceImpl implements WxParkService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxParkMapper wxParkMapper;


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

    @Override
    public WxPark getById(Long id) {
        return wxParkMapper.selectById(id);
    }

    @Override
    public WxPark getByObj(WxPark record) {
        List<WxPark> parkList = wxParkMapper.findList(record);
        if (parkList.size() > 0)
            return  parkList.get(0);
        return null;
    }

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

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