package com.ssm.service.impl.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.ssm.mapper.system.SysLogMapper;
import com.ssm.model.system.SysLog;
import com.ssm.service.system.SysLogService;
import com.ssm.util.page.BeanUtil;
import com.ssm.util.page.PagedResult;

@Service
public class SysLogServiceImpl implements SysLogService {

	@Autowired
	SysLogMapper sysLogMapper;

	// 完全 插入数据
	@Override
	@Transactional(value = "txManager", propagation = Propagation.REQUIRED)
	public int insert(SysLog record) {
		return sysLogMapper.insert(record);
	}

	@Override
	public PagedResult<SysLog> selectlog(SysLog sysLog, Integer pageNo,
			Integer pageSize) {
		// TODO Auto-generated method stub
		pageNo = pageNo == null?1:pageNo;  
	    pageSize = pageSize == null?10:pageSize;
	    PageHelper.startPage(pageNo,pageSize);  //startPage是告诉拦截器说我要开始分页了。分页参数是这两个。  
	    List<SysLog> list = sysLogMapper.selectlog(sysLog);
		PagedResult<SysLog> pagedResult = BeanUtil.toPagedResult(list);  
		return pagedResult;
	}

	@Override
	public SysLog findById(Integer id) {
		return sysLogMapper.selectById(id);
	}
}
