Update EmailController.java

This commit is contained in:
Ludy87 2025-05-01 12:01:52 +02:00
parent 1831aa1452
commit 493ed6d5a5
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

View File

@ -2,16 +2,15 @@ package stirling.software.SPDF.controller.api;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.mail.MessagingException; import jakarta.mail.MessagingException;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -41,15 +40,7 @@ public class EmailController {
*/ */
@PostMapping(consumes = "multipart/form-data", value = "/send-email") @PostMapping(consumes = "multipart/form-data", value = "/send-email")
public ResponseEntity<String> sendEmailWithAttachment( public ResponseEntity<String> sendEmailWithAttachment(
@RequestBody( @Valid @ModelAttribute
description =
"Email object containing the recipient's email address,"
+ " subject, body, and attachment",
required = true,
content =
@Content(
mediaType = "multipart/form-data",
schema = @Schema(implementation = Email.class)))
Email email) { Email email) {
try { try {
// Calls the service to send the email with attachment // Calls the service to send the email with attachment