🐛Fix: 修复前后端数据格式不一致问题
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/email")
|
||||
@@ -19,9 +15,9 @@ public class MailController {
|
||||
private MailService mailService;
|
||||
|
||||
@PostMapping("/send")
|
||||
public Response sendMail(@RequestBody Mail mail) {
|
||||
mailService.sendMessage(mail.getTo(), mail.getSubject(), mail.getContent());
|
||||
log.info(mail.toString());
|
||||
public Response sendMail(@RequestParam String to, @RequestParam String subject, @RequestParam String content) {
|
||||
mailService.sendMessage(to, subject, content);
|
||||
log.info("[To]: {}\n[Subject]: {}\n[Content]: {}\n", to, subject, content);
|
||||
return new Response(200, "success");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package cn.hezhaohui.mail.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Mail {
|
||||
private String to;
|
||||
private String subject;
|
||||
private String content;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Response {
|
||||
final private int code;
|
||||
final private int status;
|
||||
final private String message;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user