首页>代码>Spring Boot整合邮件发送并保存历史发送邮箱>/springboot-email/src/main/java/com/gstarcad/controller/EmailAction.java
package com.gstarcad.controller;/** * @Title: ${file_name} * @Package ${package_name} * @Description: * @author fengzf fengzf@gstarcad.com * @date 2018/8/23 16:58 * @version Vxxx (项目版本) * @redmine * @update @Description TODO(这里用一句话描述这个方法的作用) * @update @author fengzf fengzf@gstarcad.com * @update @date 2018/8/23 16:58 */ import com.gstarcad.entity.EmailInfo; import com.gstarcad.model.ResultVO; import com.gstarcad.service.EmailService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; /** * @ClassName: EmailAction.java * @Description: * @author: fengzf fengzf@gstarcad.com * @Date: 2018/8/23 16:58 * */ @RestController @RequestMapping(value = "/email") public class EmailAction extends BaseAction{ @Autowired private EmailService emailService; /** * * @param emailInfo * @param error * @return */ @PostMapping(value = "/add", produces = {"application/json;charset=UTF-8"}) public ResultVO addEmail(@Valid EmailInfo emailInfo, BindingResult error){ try{ if (error.hasErrors()) { return operateFail(error.getFieldError().getDefaultMessage()); } //查询是否已存在数据 EmailInfo s_email = emailService.findByEmail(emailInfo.getEmail()); if(s_email==null){ emailService.addEmail(emailInfo); }else{ emailInfo = s_email; } //发送邮件 emailService.sendMail(emailInfo); return operateSuccessFul("操作成功!"); }catch(Exception e){ e.printStackTrace(); return operateFail(e.getMessage()); } } }

13021603815 LV7
2024年11月14日
annazhang LV29
2023年4月7日
npc也有忧伤 LV3
2022年3月20日
luesjim LV11
2021年6月18日
jp6863655 LV13
2020年11月20日
aa991215 LV17
2020年9月2日
17704627276 LV17
2020年6月8日
1529860026 LV24
2020年4月15日
geekcjj LV18
2020年4月4日
dhuashdjhsfhskh LV12
2020年3月17日

13021603815 LV7
2024年11月14日
charleswang LV7
2024年10月21日
漫步的海星 LV4
2023年9月26日
438130041 LV5
2023年8月1日
啦啦啦7719 LV15
2023年2月22日
不想起 LV10
2022年10月15日
second LV5
2022年9月21日
207666
2022年6月16日
暂无贡献等级
2468867327 LV10
2022年5月17日
adcxiaoxueren
2022年4月15日
暂无贡献等级