Skip to content
Snippets Groups Projects
Commit 8cbcbe98 authored by Martin Gargalovič's avatar Martin Gargalovič
Browse files

fixing typos and refactoring MailDto to correct dir

parent 17c730b2
No related branches found
No related tags found
1 merge request!12Mail module
Pipeline #
......@@ -23,6 +23,10 @@
<artifactId>final-annotation-web</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package org.fuseri.modulemail.service;
package org.fuseri.model.dto.mail;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
public class EmailDto {
@Getter
@Setter
public class MailDto {
@NotBlank
public
String receiver;
@NotBlank
public
String content;
public EmailDto(String receiver, String content) {
public MailDto(String receiver, String content) {
this.receiver = receiver;
this.content = content;
}
......
......@@ -41,8 +41,14 @@
<artifactId>spring-boot-starter-mail</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.fuseri</groupId>
<artifactId>models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <dependency>-->
<!-- <groupId>javax.mail</groupId>-->
<!-- <artifactId>mail</artifactId>-->
<!-- <version>1.4.7</version>-->
......
......@@ -3,6 +3,7 @@ package org.fuseri.modulemail.service;
import jakarta.validation.Valid;
import jakarta.validation.constraints.PositiveOrZero;
import org.fuseri.model.dto.mail.MailDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -14,12 +15,12 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/mail")
public class MailControler {
public class MailController {
private final MailService service;
@Autowired
public MailControler(MailService service) {
public MailController(MailService service) {
this.service = service;
}
......@@ -35,7 +36,7 @@ public class MailControler {
}
@PostMapping()
public String sendMail(@Valid @RequestBody EmailDto emailDto) {
public String sendMail(@Valid @RequestBody MailDto emailDto) {
return service.send(emailDto);
}
}
package org.fuseri.modulemail.service;
import org.fuseri.model.dto.mail.MailDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.mail.SimpleMailMessage;
......@@ -10,7 +11,7 @@ public class MailService {
@Autowired
private JavaMailSender emailSender;
public String send(EmailDto dto) {
public String send(MailDto dto) {
var message = new SimpleMailMessage();
message.setFrom("sprachul@gmail.com");
message.setTo(dto.receiver);
......@@ -23,11 +24,11 @@ public class MailService {
return "Success, you have sent: " + dto.content;
}
public EmailDto getMail(long id) {
return new EmailDto("empty","empty"); // return from database once there is one
public MailDto getMail(long id) {
return new MailDto("empty","empty"); // return from database once there is one
}
public String DeleteMail (long id) {
public String deleteMail(long id) {
return "No mail with that Id";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment