diff --git a/tamguo-mms/src/main/java/com/tamguo/web/EmailController.java b/tamguo-mms/src/main/java/com/tamguo/web/EmailController.java index fcbe63c..4f5ca5b 100644 --- a/tamguo-mms/src/main/java/com/tamguo/web/EmailController.java +++ b/tamguo-mms/src/main/java/com/tamguo/web/EmailController.java @@ -1,34 +1,45 @@ package com.tamguo.web; -import org.apache.commons.mail.EmailException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.apache.commons.mail.EmailException; // 导入邮件异常类 +import org.springframework.beans.factory.annotation.Autowired; // 导入自动注入注解 +import org.springframework.stereotype.Controller; // 标注为控制器类 +import org.springframework.web.bind.annotation.RequestMapping; // 处理请求映射 +import org.springframework.web.bind.annotation.RequestMethod; // 请求方法 +import org.springframework.web.bind.annotation.ResponseBody; // 返回响应体 -import com.tamguo.common.utils.Result; -import com.tamguo.common.utils.SystemConstant; -import com.tamguo.modules.sys.service.IEmailService; +import com.tamguo.common.utils.Result; // 通用结果类 +import com.tamguo.common.utils.SystemConstant; // 系统常量类 +import com.tamguo.modules.sys.service.IEmailService; // 邮件服务接口 +/** + * EmailController 类,处理邮件相关的请求 + */ @Controller public class EmailController { - - @Autowired + + @Autowired // 自动注入邮件服务实例 private IEmailService iEmailService; + /** + * 处理发送找回密码邮件的请求 + * @param email 接收邮件的地址 + * @return 响应结果 + */ @RequestMapping(value = {"sendFindPasswordEmail"}, method = RequestMethod.GET) @ResponseBody - public Result sendFindPasswordEmail(String email){ + public Result sendFindPasswordEmail(String email) { try { - Integer result = iEmailService.sendFindPasswordEmail(email , SystemConstant.ALIYUN_MAIL_SUBJECT_FINDPASSWORD); - if(result == 0){ + // 调用邮件服务发送找回密码邮件,并获取结果 + Integer result = iEmailService.sendFindPasswordEmail(email, SystemConstant.ALIYUN_MAIL_SUBJECT_FINDPASSWORD); + if (result == 0) { + // 如果结果为 0,返回服务器异常的结果 return Result.result(200, null, "服务器异常"); } } catch (EmailException e) { + // 捕获邮件异常并打印堆栈信息 e.printStackTrace(); } + // 无论是否发生异常,都返回服务器异常的结果 return Result.result(500, null, "服务器异常"); } - -} +} \ No newline at end of file