package com.bjsxt.web.controller;

import com.bjsxt.pojo.Users;
import com.bjsxt.pojo.UsersExt;
import com.bjsxt.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping(value = "/users")
public class UsersController {
    @Autowired
    private UsersService usersService;

    /**
     * 处理用户登入请求
     * @return
     */
    @RequestMapping("/usersLogin")
    public String usersLogin(UsersExt usersExt , HttpSession session, HttpServletRequest request){
        String ip = request.getRemoteAddr();
        usersExt.setIp(ip);

        Users user = usersService.usersLogin(usersExt);
        session.setAttribute("user",user);

        return "redirect:/page/index";
    }




}
