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 @@ ...@@ -23,6 +23,10 @@
<artifactId>final-annotation-web</artifactId> <artifactId>final-annotation-web</artifactId>
<version>1.4.0</version> <version>1.4.0</version>
</dependency> </dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package org.fuseri.modulemail.service; package org.fuseri.model.dto.mail;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
public class EmailDto { @Getter
@Setter
public class MailDto {
@NotBlank @NotBlank
public
String receiver; String receiver;
@NotBlank @NotBlank
public
String content; String content;
public EmailDto(String receiver, String content) { public MailDto(String receiver, String content) {
this.receiver = receiver; this.receiver = receiver;
this.content = content; this.content = content;
} }
......
...@@ -41,8 +41,14 @@ ...@@ -41,8 +41,14 @@
<artifactId>spring-boot-starter-mail</artifactId> <artifactId>spring-boot-starter-mail</artifactId>
<version>3.0.4</version> <version>3.0.4</version>
</dependency> </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>--> <!-- <groupId>javax.mail</groupId>-->
<!-- <artifactId>mail</artifactId>--> <!-- <artifactId>mail</artifactId>-->
<!-- <version>1.4.7</version>--> <!-- <version>1.4.7</version>-->
......
...@@ -3,6 +3,7 @@ package org.fuseri.modulemail.service; ...@@ -3,6 +3,7 @@ package org.fuseri.modulemail.service;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.PositiveOrZero; import jakarta.validation.constraints.PositiveOrZero;
import org.fuseri.model.dto.mail.MailDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -14,12 +15,12 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,12 +15,12 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/mail") @RequestMapping("/mail")
public class MailControler { public class MailController {
private final MailService service; private final MailService service;
@Autowired @Autowired
public MailControler(MailService service) { public MailController(MailService service) {
this.service = service; this.service = service;
} }
...@@ -35,7 +36,7 @@ public class MailControler { ...@@ -35,7 +36,7 @@ public class MailControler {
} }
@PostMapping() @PostMapping()
public String sendMail(@Valid @RequestBody EmailDto emailDto) { public String sendMail(@Valid @RequestBody MailDto emailDto) {
return service.send(emailDto); return service.send(emailDto);
} }
} }
package org.fuseri.modulemail.service; package org.fuseri.modulemail.service;
import org.fuseri.model.dto.mail.MailDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
...@@ -10,7 +11,7 @@ public class MailService { ...@@ -10,7 +11,7 @@ public class MailService {
@Autowired @Autowired
private JavaMailSender emailSender; private JavaMailSender emailSender;
public String send(EmailDto dto) { public String send(MailDto dto) {
var message = new SimpleMailMessage(); var message = new SimpleMailMessage();
message.setFrom("sprachul@gmail.com"); message.setFrom("sprachul@gmail.com");
message.setTo(dto.receiver); message.setTo(dto.receiver);
...@@ -23,11 +24,11 @@ public class MailService { ...@@ -23,11 +24,11 @@ public class MailService {
return "Success, you have sent: " + dto.content; return "Success, you have sent: " + dto.content;
} }
public EmailDto getMail(long id) { public MailDto getMail(long id) {
return new EmailDto("empty","empty"); // return from database once there is one 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"; 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