1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| @RequestMapping(path = "/register", method = RequestMethod.GET) public String getRegisterPage() { return "/site/register"; }
@RequestMapping(path = "/login", method = RequestMethod.GET) public String getLoginPage() { return "/site/login"; }
@RequestMapping(path = "/register", method = RequestMethod.POST) public String register(Model model, User user) { Map<String, Object> map = userService.register(user); if(map == null || map.isEmpty()) { model.addAttribute("msg", "注册成功,我们已经向您的邮箱发送了一封激活邮件,请尽快激活!"); model.addAttribute("target", "/index"); return "/site/operate-result"; } else { model.addAttribute("usernameMsg", map.get("usernameMsg")); model.addAttribute("passwordMsg", map.get("passwordMsg")); model.addAttribute("emailMsg", map.get("emailMsg")); return "/site/register"; } }
@RequestMapping(path = "/activation/{userId}/{code}", method = RequestMethod.GET) public String activation(Model model, @PathVariable("userId") int userId, @PathVariable("code") String code) { int result = userService.activation(userId, code); if (result == ACTIVATION_SUCCESS) { model.addAttribute("msg", "激活成功,您的账号已经可以正常使用了!"); model.addAttribute("target", "/login"); } else if (result == ACTIVATION_REPEAT) { model.addAttribute("msg", "无效操作,该账号已经激活过了!"); model.addAttribute("target", "/index"); } else { model.addAttribute("msg", "激活失败,您提供的激活码不正确!"); model.addAttribute("target", "/index"); } return "/site/operate-result"; }
|