diff --git a/pom.xml b/pom.xml index f76eb84..2452c16 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,10 @@ spring-boot-starter-test test + + org.springframework.boot + spring-boot-starter-mail + diff --git a/src/main/java/de/telekom/silly_game/GameController.java b/src/main/java/de/telekom/silly_game/GameController.java index 572cbf6..aee72fd 100644 --- a/src/main/java/de/telekom/silly_game/GameController.java +++ b/src/main/java/de/telekom/silly_game/GameController.java @@ -25,4 +25,25 @@ public class GameController { System.out.println(total); return Collections.singletonMap("totalJumps", total); } + + @GetMapping("/getJumpStrength/low") + public Map getLowJumpStrength() { + return Collections.singletonMap("JumpStrength", JumpStrength.LOW); + } + + @GetMapping("/getJumpStrength/midium") + public Map getMediumJumpStrength() { + return Collections.singletonMap("JumpStrength", JumpStrength.MEDIUM); + } + + @GetMapping("/getJumpStrength/high") + public Map getHightJumpStrength() { + return Collections.singletonMap("JumpStrength", JumpStrength.HIGH); + } + + @GetMapping("/getColor/{name}") + public Map getHightJumpStrength(@PathVariable String name) { + Sky sky = new Sky(); + return Collections.singletonMap("JumpStrength", sky.getSkyColor(name)); + } } \ No newline at end of file diff --git a/src/main/java/de/telekom/silly_game/InviteController.java b/src/main/java/de/telekom/silly_game/InviteController.java new file mode 100644 index 0000000..72dfd17 --- /dev/null +++ b/src/main/java/de/telekom/silly_game/InviteController.java @@ -0,0 +1,42 @@ +package de.telekom.silly_game; + +import jakarta.mail.internet.MimeMessage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +@RestController +@RequestMapping("/api") +@CrossOrigin(origins = "http://localhost:4200") +public class InviteController { + + @PostMapping("/invite") + public ResponseEntity sendInvite(@RequestBody Map payload) { + String email = payload.get("email"); + + // Simulate sending an email (MailHog catches it) + try { + MimeMessage message = mailSender.createMimeMessage(); + MimeMessageHelper helper = new MimeMessageHelper(message, true); + helper.setTo(email); + helper.setSubject("You've been invited!"); + helper.setText("Your friend invited you to play a game!", true); + + mailSender.send(message); + return ResponseEntity.ok().build(); + } catch (Exception e) { + return ResponseEntity.status(500).body("Failed to send email."); + } + } + @GetMapping("/hello") + public ResponseEntity sendInvite2(@RequestBody Map payload) { + return ResponseEntity.status(200).body("Failed to send email."); + } + + @Autowired + private JavaMailSender mailSender; +} diff --git a/src/main/java/de/telekom/silly_game/JumpStrength.java b/src/main/java/de/telekom/silly_game/JumpStrength.java new file mode 100644 index 0000000..4a4b523 --- /dev/null +++ b/src/main/java/de/telekom/silly_game/JumpStrength.java @@ -0,0 +1,7 @@ +package de.telekom.silly_game; + +public class JumpStrength { + static final int LOW = 10; + static final int MEDIUM = 25; + static final int HIGH = 40; +} diff --git a/src/main/java/de/telekom/silly_game/SillyGameApplication.java b/src/main/java/de/telekom/silly_game/SillyGameApplication.java index ee06199..9ba29b6 100644 --- a/src/main/java/de/telekom/silly_game/SillyGameApplication.java +++ b/src/main/java/de/telekom/silly_game/SillyGameApplication.java @@ -4,7 +4,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class SillyGameApplication { +public class +SillyGameApplication { public static void main(String[] args) { SpringApplication.run(SillyGameApplication.class, args); diff --git a/src/main/java/de/telekom/silly_game/Sky.java b/src/main/java/de/telekom/silly_game/Sky.java new file mode 100644 index 0000000..5034963 --- /dev/null +++ b/src/main/java/de/telekom/silly_game/Sky.java @@ -0,0 +1,18 @@ +package de.telekom.silly_game; + +public class Sky { + final String blue = "#c8f4ff"; + final String darkBlue = "#3d4781"; + final String green = "##044d00"; + final String orange = "orange"; + + public String getSkyColor(String name) { + return switch (name) { + case "blue" -> blue; + case "dark_blue" -> darkBlue; + case "green" -> green; + case "orange" -> orange; + default -> "black"; + }; + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d1fdedc..f86ecaf 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,8 @@ spring.application.name=silly-game + +spring.mail.host=localhost +spring.mail.port=1025 +spring.mail.username= +spring.mail.password= +spring.mail.properties.mail.smtp.auth=false +spring.mail.properties.mail.smtp.starttls.enable=false \ No newline at end of file