|
@@ -1,47 +0,0 @@
|
|
|
-package com.uas.cloud.mall.admin.web;
|
|
|
|
|
-
|
|
|
|
|
-import com.uas.cloud.mall.admin.service.LoginService;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
-
|
|
|
|
|
-import javax.servlet.http.HttpSession;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * 登录、登出
|
|
|
|
|
- * @author liuam
|
|
|
|
|
- * @version 2018/4/19 0019 下午 13:56 创建文件
|
|
|
|
|
- *
|
|
|
|
|
- */
|
|
|
|
|
-@Controller
|
|
|
|
|
-public class LoginAndLogoutController {
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private LoginService loginService;
|
|
|
|
|
-
|
|
|
|
|
- @RequestMapping(value = "/dologin", method = RequestMethod.POST)
|
|
|
|
|
- public String dologin(String userName, String password, HttpSession session, Map<String, String> model) {
|
|
|
|
|
- String user = loginService.findUser(userName, password);
|
|
|
|
|
- if (StringUtils.isEmpty(user)) {
|
|
|
|
|
- model.put("message", "用户名或密码错误");
|
|
|
|
|
- return "login";
|
|
|
|
|
- }
|
|
|
|
|
- session.setAttribute("user", user);
|
|
|
|
|
- return "redirect:/";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequestMapping(value = "/login", method = RequestMethod.GET)
|
|
|
|
|
- public String login() {
|
|
|
|
|
- return "login";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequestMapping(value = "/logout", method = RequestMethod.GET)
|
|
|
|
|
- public String logout(HttpSession session) {
|
|
|
|
|
- session.removeAttribute("user");
|
|
|
|
|
- return "redirect:/login";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|