Merge remote-tracking branch 'origin/在线访问lhj' into 在线访问lhj

在线访问lhj
李宏杰 8 months ago
commit f987a30e2e

@ -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, "服务器异常");
}
}
Loading…
Cancel
Save