mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 重构 pr_172 集成邮件发送功能
This commit is contained in:
@ -3,6 +3,8 @@ package com.ruoyi.demo.controller;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.email.MailUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -14,41 +16,34 @@ import java.io.File;
|
||||
|
||||
|
||||
/**
|
||||
* 测试邮件发送 Controller
|
||||
* 邮件发送案例
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Validated
|
||||
@Api(value = "邮件控制器", tags = {"测试邮件发送"})
|
||||
@Api(value = "邮件发送案例", tags = {"邮件发送案例"})
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RequestMapping("/demo/mail")
|
||||
@RestController
|
||||
public class MailController {
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
*/
|
||||
@ApiOperation("发送邮件")
|
||||
@GetMapping("/sendSimpleMessage")
|
||||
public R<Void> sendSimpleMessage(String to, String subject, String text) {
|
||||
MailUtils.send(to, subject, text, false);
|
||||
return R.ok("操作成功");
|
||||
public R<Void> sendSimpleMessage(@ApiParam("接收人") String to,
|
||||
@ApiParam("标题") String subject,
|
||||
@ApiParam("内容") String text) {
|
||||
MailUtils.sendText(to, subject, text);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件(带附件)
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
*/
|
||||
@ApiOperation("发送邮件(带附件)")
|
||||
@GetMapping("/sendMessageWithAttachment")
|
||||
public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) {
|
||||
MailUtils.send(to, subject, text, false, new File(filePath));
|
||||
return R.ok("操作成功");
|
||||
public R<Void> sendMessageWithAttachment(@ApiParam("接收人") String to,
|
||||
@ApiParam("标题") String subject,
|
||||
@ApiParam("内容") String text,
|
||||
@ApiParam("附件路径") String filePath) {
|
||||
MailUtils.sendText(to, subject, text, new File(filePath));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user