package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxWeappBasicSet;
import com.iformall.mapper.WxWeappBasicSetMapper;
import com.iformall.service.WxWeappBasicSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class WxWeappBasicSetServiceImpl implements WxWeappBasicSetService {
	
	@Autowired
    WxWeappBasicSetMapper wxWeappBasicSetMapper;


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

    @Override
    public WxWeappBasicSet getById(Long id) {
        return wxWeappBasicSetMapper.selectByPrimaryKey(id);
    }

    @Override
    public WxWeappBasicSet getByTypeAndDeploy(WxWeappBasicSet weappBasicSet) {
        return wxWeappBasicSetMapper.selectOne(weappBasicSet);
    }

    @Override
    public void saveOrUpdate(WxWeappBasicSet record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            wxWeappBasicSetMapper.insertSelective(record);
        } else {
            wxWeappBasicSetMapper.updateByPrimaryKeySelective(record);
        }
    }

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