commit
e22e504c4b
@ -1,28 +1,27 @@
|
|||||||
package com.tamguo.web;
|
package com.tamguo.web;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest; // 导入 HttpServletRequest 类
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse; // 导入 HttpServletResponse 类
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession; // 导入 HttpSession 类
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller; // 表示这是一个控制器类
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping; // 用于处理请求映射
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod; // 用于指定请求方法
|
||||||
|
|
||||||
import com.tamguo.utils.ShiroUtils;
|
import com.tamguo.utils.ShiroUtils; // 导入 ShiroUtils 类
|
||||||
|
|
||||||
@Controller
|
@Controller // 声明这是一个控制器
|
||||||
public class LogoutController {
|
public class LogoutController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注销
|
* 注销方法
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "logout.html", method = RequestMethod.GET)
|
@RequestMapping(value = "logout.html", method = RequestMethod.GET) // 映射到 "logout.html" 且使用 GET 方法的请求
|
||||||
public String logout(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
public String logout(HttpServletRequest request, HttpServletResponse response, HttpSession session) { // 接收请求、响应和会话对象
|
||||||
if (session.getAttribute("currMember") != null) {
|
if (session.getAttribute("currMember")!= null) { // 如果会话中当前成员不为空
|
||||||
session.removeAttribute("currMember");
|
session.removeAttribute("currMember"); // 从会话中移除当前成员属性
|
||||||
ShiroUtils.logout();
|
ShiroUtils.logout(); // 执行 ShiroUtils 的注销操作
|
||||||
}
|
}
|
||||||
return "redirect:/";
|
return "redirect:/"; // 重定向到根路径
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,81 +1,95 @@
|
|||||||
package com.tamguo.web;
|
package com.tamguo.web;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession; // 导入 HttpSession 类
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired; // 表示自动注入
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller; // 声明这是一个控制器类
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping; // 处理请求映射
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod; // 指定请求方法
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody; // 用于返回响应体
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView; // 模型和视图类
|
||||||
|
|
||||||
import com.tamguo.common.utils.Result;
|
import com.tamguo.common.utils.Result; // 通用结果类
|
||||||
import com.tamguo.common.utils.SystemConstant;
|
import com.tamguo.common.utils.SystemConstant; // 系统常量类
|
||||||
import com.tamguo.modules.member.service.IMemberService;
|
import com.tamguo.modules.member.service.IMemberService; // 会员服务接口
|
||||||
|
|
||||||
@Controller
|
@Controller // 控制器注解
|
||||||
public class PasswordController {
|
public class PasswordController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired // 自动注入会员服务
|
||||||
private IMemberService iMemberService;
|
private IMemberService iMemberService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认账号页面的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/find.html", method = RequestMethod.GET)
|
@RequestMapping(value = "password/find.html", method = RequestMethod.GET)
|
||||||
public ModelAndView confirmAccount(ModelAndView model){
|
public ModelAndView confirmAccount(ModelAndView model) { // 处理方法,接收模型和视图对象
|
||||||
model.setViewName("password/confirmAccount");
|
model.setViewName("password/confirmAccount"); // 设置视图名称
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交确认账号的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/confirmAccount.html", method = RequestMethod.POST)
|
@RequestMapping(value = "password/confirmAccount.html", method = RequestMethod.POST)
|
||||||
public ModelAndView submitConfirmAccount(String username , String veritycode , ModelAndView model , HttpSession session){
|
public ModelAndView submitConfirmAccount(String username, String veritycode, ModelAndView model, HttpSession session) { // 处理方法,接收参数、模型和视图对象、会话对象
|
||||||
Result result = iMemberService.confirmAccount(username, veritycode);
|
Result result = iMemberService.confirmAccount(username, veritycode); // 调用会员服务的确认账号方法
|
||||||
String kaptcha = session.getAttribute(SystemConstant.KAPTCHA_SESSION_KEY).toString();
|
String kaptcha = session.getAttribute(SystemConstant.KAPTCHA_SESSION_KEY).toString(); // 获取验证码
|
||||||
if (!veritycode.equalsIgnoreCase(kaptcha)) {
|
if (!veritycode.equalsIgnoreCase(kaptcha)) { // 比较验证码是否正确
|
||||||
result = Result.result(202, null, "验证码错误");
|
result = Result.result(202, null, "验证码错误"); // 设置错误结果
|
||||||
}
|
}
|
||||||
if(result.getCode() == 200){
|
if (result.getCode() == 200) { // 如果结果码为 200
|
||||||
model.setViewName("password/securityCheck");
|
model.setViewName("password/securityCheck"); // 设置视图名称
|
||||||
model.addObject("result", result);
|
model.addObject("result", result); // 添加结果到模型
|
||||||
model.addObject("isEmail", username.contains("@") ? "1" : "0");
|
model.addObject("isEmail", username.contains("@")? "1" : "0"); // 添加是否为邮箱的标识到模型
|
||||||
} else {
|
} else {
|
||||||
model.setViewName("password/confirmAccount");
|
model.setViewName("password/confirmAccount"); // 设置视图名称
|
||||||
model.addObject("account", username);
|
model.addObject("account", username); // 添加账号到模型
|
||||||
model.addObject("username",username);
|
model.addObject("username", username); // 添加用户名到模型
|
||||||
model.addObject("veritycode", veritycode);
|
model.addObject("veritycode", veritycode); // 添加验证码到模型
|
||||||
model.addObject("code", result.getCode());
|
model.addObject("code", result.getCode()); // 添加结果码到模型
|
||||||
}
|
}
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全检查页面的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/securityCheck.html", method = RequestMethod.POST)
|
@RequestMapping(value = "password/securityCheck.html", method = RequestMethod.POST)
|
||||||
public ModelAndView securityCheck(String username , String isEmail , String mobileVcode , ModelAndView model){
|
public ModelAndView securityCheck(String username, String isEmail, String mobileVcode, ModelAndView model) { // 处理方法,接收参数、模型和视图对象
|
||||||
Result result = iMemberService.securityCheck(username , isEmail , mobileVcode);
|
Result result = iMemberService.securityCheck(username, isEmail, mobileVcode); // 调用会员服务的安全检查方法
|
||||||
if(result.getCode() == 200){
|
if (result.getCode() == 200) { // 如果结果码为 200
|
||||||
model.addObject("username", username);
|
model.addObject("username", username); // 添加用户名到模型
|
||||||
model.addObject("resetPasswordKey" , result.getResult());
|
model.addObject("resetPasswordKey", result.getResult()); // 添加重置密码键到模型
|
||||||
model.setViewName("password/resetPassword");
|
model.setViewName("password/resetPassword"); // 设置视图名称
|
||||||
} else {
|
} else {
|
||||||
model.addObject("result", result);
|
model.addObject("result", result); // 添加结果到模型
|
||||||
model.addObject("isEmail", isEmail);
|
model.addObject("isEmail", isEmail); // 添加是否为邮箱的标识到模型
|
||||||
model.addObject("codeError", "1");
|
model.addObject("codeError", "1"); // 添加错误标识到模型
|
||||||
model.setViewName("password/securityCheck");
|
model.setViewName("password/securityCheck"); // 设置视图名称
|
||||||
}
|
}
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置密码页面的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/resetPassword.html", method = RequestMethod.POST)
|
@RequestMapping(value = "password/resetPassword.html", method = RequestMethod.POST)
|
||||||
public ModelAndView resetPassword(String resetPasswordKey , String username , String password , String verifypwd , ModelAndView model){
|
public ModelAndView resetPassword(String resetPasswordKey, String username, String password, String verifypwd, ModelAndView model) { // 处理方法,接收参数、模型和视图对象
|
||||||
Result result = iMemberService.resetPassword(resetPasswordKey , username , password , verifypwd);
|
Result result = iMemberService.resetPassword(resetPasswordKey, username, password, verifypwd); // 调用会员服务的重置密码方法
|
||||||
if(result.getCode() == 200){
|
if (result.getCode() == 200) { // 如果结果码为 200
|
||||||
model.setViewName("password/resetPwSuccess");
|
model.setViewName("password/resetPwSuccess"); // 设置视图名称
|
||||||
} else {
|
} else {
|
||||||
model.setViewName("password/resetPassword");
|
model.setViewName("password/resetPassword"); // 设置视图名称
|
||||||
}
|
}
|
||||||
return model;
|
return model; // 返回模型和视图
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查账号的请求映射
|
||||||
|
*/
|
||||||
@RequestMapping(value = "password/checkAccount.html", method = RequestMethod.GET)
|
@RequestMapping(value = "password/checkAccount.html", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody // 返回响应体
|
||||||
public Result checkAccount(String account){
|
public Result checkAccount(String account) { // 处理方法,接收账号参数
|
||||||
return iMemberService.checkAccount(account);
|
return iMemberService.checkAccount(account); // 调用会员服务的检查账号方法并返回结果
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in new issue