package com.iformall.service.impl;

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

@Service
public class SysMonitorServiceImpl implements SysMonitorService {
	
	@Autowired
    SysMonitorMapper sysMonitorMapper;


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

    @Override
    public List<SysMonitor> getList(SysMonitor record) {
        return sysMonitorMapper.findList(record);
    }

    @Override
    public SysMonitor getById(Long id) {
        return sysMonitorMapper.selectById(id);
    }

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

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