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