🔄Update: 完成邮件发送接口
This commit is contained in:
@@ -35,6 +35,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package cn.hezhaohui.mail.controller;
|
||||||
|
|
||||||
|
import cn.hezhaohui.mail.entity.Mail;
|
||||||
|
import cn.hezhaohui.mail.entity.Response;
|
||||||
|
import cn.hezhaohui.mail.service.MailService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/email")
|
||||||
|
public class MailController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MailService mailService;
|
||||||
|
|
||||||
|
@PostMapping("/send")
|
||||||
|
public Response sendMail(@RequestBody Mail mail) {
|
||||||
|
mailService.sendMessage(mail.getTo(), mail.getSubject(), mail.getContent());
|
||||||
|
return new Response(200, "success");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package cn.hezhaohui.mail.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Mail {
|
||||||
|
private String to;
|
||||||
|
private String subject;
|
||||||
|
private String content;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.hezhaohui.mail.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Response {
|
||||||
|
final private int code;
|
||||||
|
final private String message;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user