Code cleaning.
This commit is contained in:
@@ -2,21 +2,21 @@ package fr.ippon.example.intellijfeatures.controller;
|
|||||||
|
|
||||||
import fr.ippon.example.intellijfeatures.model.User;
|
import fr.ippon.example.intellijfeatures.model.User;
|
||||||
import fr.ippon.example.intellijfeatures.services.mail.EmailService;
|
import fr.ippon.example.intellijfeatures.services.mail.EmailService;
|
||||||
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 static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/mails")
|
@RequestMapping("/api/mails")
|
||||||
public class MailController {
|
public class EmailController {
|
||||||
private final EmailService emailService;
|
private final EmailService emailService;
|
||||||
|
|
||||||
public MailController(EmailService emailService) {
|
public EmailController(EmailService emailService) {
|
||||||
this.emailService = emailService;
|
this.emailService = emailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/send")
|
@PostMapping("/send")
|
||||||
|
@ResponseStatus(NO_CONTENT)
|
||||||
public void sendMail(@RequestBody User user) {
|
public void sendMail(@RequestBody User user) {
|
||||||
emailService.sendMail(user);
|
emailService.sendMail(user);
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,13 @@ package fr.ippon.example.intellijfeatures.services.mail;
|
|||||||
|
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
@Service
|
@Component
|
||||||
public class EmailSender {
|
class EmailSender {
|
||||||
private final JavaMailSender javaMailSender;
|
private final JavaMailSender javaMailSender;
|
||||||
|
|
||||||
public EmailSender(JavaMailSender javaMailSender) {
|
public EmailSender(JavaMailSender javaMailSender) {
|
||||||
|
|||||||
Reference in New Issue
Block a user