package com.ssm.service.impl.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.ssm.mapper.system.SysUserLoginLogMapper;
import com.ssm.model.system.SysUserLoginLog;
import com.ssm.service.system.SysUserLoginLogService;
import com.ssm.util.page.BeanUtil;
import com.ssm.util.page.PagedResult;

@Service
public class SysUserLoginLogServiceImpl implements SysUserLoginLogService{
	
	@Autowired
	private SysUserLoginLogMapper userLoginLogMapper;
	
	@Override
	public int saveUserLoginLog(SysUserLoginLog record) {
		return userLoginLogMapper.insertSelective(record);
	}

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

}
