Compare commits

..

No commits in common. '2a7e9abd878e51db15953083404a86d5642eaa40' and '5eaa3dd2f6f6f8f99d0fcce5fcab5f9f482234e2' have entirely different histories.

@ -1,45 +1,34 @@
package com.tamguo.web; package com.tamguo.web;
import org.apache.commons.mail.EmailException; // 导入邮件异常类 import org.apache.commons.mail.EmailException;
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 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.sys.service.IEmailService; // 邮件服务接口 import com.tamguo.modules.sys.service.IEmailService;
/**
* EmailController
*/
@Controller @Controller
public class EmailController { public class EmailController {
@Autowired // 自动注入邮件服务实例 @Autowired
private IEmailService iEmailService; private IEmailService iEmailService;
/**
*
* @param email
* @return
*/
@RequestMapping(value = {"sendFindPasswordEmail"}, method = RequestMethod.GET) @RequestMapping(value = {"sendFindPasswordEmail"}, method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Result sendFindPasswordEmail(String email) { public Result sendFindPasswordEmail(String email){
try { try {
// 调用邮件服务发送找回密码邮件,并获取结果 Integer result = iEmailService.sendFindPasswordEmail(email , SystemConstant.ALIYUN_MAIL_SUBJECT_FINDPASSWORD);
Integer result = iEmailService.sendFindPasswordEmail(email, SystemConstant.ALIYUN_MAIL_SUBJECT_FINDPASSWORD); if(result == 0){
if (result == 0) {
// 如果结果为 0返回服务器异常的结果
return Result.result(200, null, "服务器异常"); return Result.result(200, null, "服务器异常");
} }
} catch (EmailException e) { } catch (EmailException e) {
// 捕获邮件异常并打印堆栈信息
e.printStackTrace(); e.printStackTrace();
} }
// 无论是否发生异常,都返回服务器异常的结果
return Result.result(500, null, "服务器异常"); return Result.result(500, null, "服务器异常");
} }
}
}

Loading…
Cancel
Save