package lingtao.net.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import lingtao.net.bean.LoginLog;
import lingtao.net.service.LoginLogService;

@Controller
public class LoginLogController {

	@Autowired
	private LoginLogService loginLogService;

	// 登录情况跳转页面
	@RequestMapping("/loginLog/index")
	public void index(HttpServletRequest request, HttpServletResponse response) throws Exception {
		response.sendRedirect(request.getContextPath() + "/views/system/loginLog/loginLog.jsp");
	}

	/**
	 * 查询所有登录情况
	 */
	@RequestMapping("/getLoginLogList")
	@ResponseBody
	private PageInfo<LoginLog> IPList(@RequestParam(value = "page", defaultValue = "1") Integer page,
			@RequestParam(value = "limit", defaultValue = "10") Integer limit, LoginLog loginLog) {
		PageHelper.startPage(page, limit);
		List<LoginLog> list = loginLogService.getLoginLogList(loginLog);
		PageInfo<LoginLog> pageInfo = new PageInfo<LoginLog>(list);
		return pageInfo;
	}
	
}
