package web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.Users;
import service.UsersService;

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

/**
 * 用户登录控制器
 */
@Controller
@RequestMapping("/user")
public class UserLoginController {
    @Autowired
    private UsersService usersService;

    @RequestMapping("/userLogin")
    public String userLogin(Users users,Model model, HttpServletRequest request){
        Users users1 = this.usersService.usersLogin(users);
        HttpSession session = request.getSession();
        session.setAttribute("user",users1);
        return "redirect:/page/index";
    }
}
