From 9dc5fe697c760e4b12dc2fd289cbb98fcb0a5802 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Mon, 30 Mar 2026 16:14:38 -0300 Subject: [PATCH] Remove email endpoint --- pom.xml | 2 +- .../api/controller/EmailController.java | 57 ------------------- .../wordview/api/database/entity/Email.java | 40 ------------- .../api/repository/EmailRepository.java | 27 --------- .../cc/wordview/api/service/EmailService.java | 43 -------------- .../specification/EmailServiceInterface.java | 23 -------- .../api/controller/EmailControllerTest.java | 41 ------------- 7 files changed, 1 insertion(+), 232 deletions(-) delete mode 100644 src/main/java/cc/wordview/api/controller/EmailController.java delete mode 100644 src/main/java/cc/wordview/api/database/entity/Email.java delete mode 100644 src/main/java/cc/wordview/api/repository/EmailRepository.java delete mode 100644 src/main/java/cc/wordview/api/service/EmailService.java delete mode 100644 src/main/java/cc/wordview/api/service/specification/EmailServiceInterface.java delete mode 100644 src/test/java/cc/wordview/api/test/api/controller/EmailControllerTest.java diff --git a/pom.xml b/pom.xml index 9e71441..fe2a4a3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 cc wordview - 0.0.4-SNAPSHOT + 0.1.0-SNAPSHOT WordViewAPI diff --git a/src/main/java/cc/wordview/api/controller/EmailController.java b/src/main/java/cc/wordview/api/controller/EmailController.java deleted file mode 100644 index b526fc1..0000000 --- a/src/main/java/cc/wordview/api/controller/EmailController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Arthur Araujo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package cc.wordview.api.controller; - -import cc.wordview.api.Application; -import cc.wordview.api.database.entity.Email; -import cc.wordview.api.request.RequestValidation; -import cc.wordview.api.service.specification.EmailServiceInterface; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import static cc.wordview.api.controller.response.Response.badRequest; -import static cc.wordview.api.controller.response.Response.ok; - - -@RestController -@CrossOrigin(origins = Application.CORS_ORIGIN) -@RequestMapping(path = Application.API_PATH + "/email") -public class EmailController extends ServiceController { - private static final Logger logger = LoggerFactory.getLogger(EmailController.class); - - @Autowired - private EmailServiceInterface service; - - @GetMapping - public ResponseEntity addEmail(@RequestParam String email) throws Exception { - if (RequestValidation.invalidEmail(email)) { - return badRequest("Invalid email!"); - } - - Email emailEntity = new Email(); - emailEntity.setEmail(email); - service.insert(emailEntity); - - logger.info("A new email has arrived! (%s)".formatted(email)); - - return ok("OK!"); - } -} diff --git a/src/main/java/cc/wordview/api/database/entity/Email.java b/src/main/java/cc/wordview/api/database/entity/Email.java deleted file mode 100644 index d1f08cb..0000000 --- a/src/main/java/cc/wordview/api/database/entity/Email.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2025 Arthur Araujo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package cc.wordview.api.database.entity; - -import jakarta.persistence.*; -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; - -@Entity -@Data -@Table(name = "email") -public class Email implements Serializable { - @Serial - private static final long serialVersionUID = 3213291524891123131L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private Long id; - - @Column(name = "email", unique = true) - private String email; -} diff --git a/src/main/java/cc/wordview/api/repository/EmailRepository.java b/src/main/java/cc/wordview/api/repository/EmailRepository.java deleted file mode 100644 index 38db0ec..0000000 --- a/src/main/java/cc/wordview/api/repository/EmailRepository.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Arthur Araujo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package cc.wordview.api.repository; - -import cc.wordview.api.database.entity.Email; -import org.springframework.data.repository.CrudRepository; - -import java.util.Optional; - -public interface EmailRepository extends CrudRepository { - Optional findByEmail(String email); -} diff --git a/src/main/java/cc/wordview/api/service/EmailService.java b/src/main/java/cc/wordview/api/service/EmailService.java deleted file mode 100644 index eca5877..0000000 --- a/src/main/java/cc/wordview/api/service/EmailService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2025 Arthur Araujo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package cc.wordview.api.service; - -import cc.wordview.api.database.entity.Email; -import cc.wordview.api.repository.EmailRepository; -import cc.wordview.api.service.specification.EmailServiceInterface; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Optional; - -@Service -public class EmailService implements EmailServiceInterface { - @Autowired - private EmailRepository repository; - - @Override - public Email getById(Long id) { - return null; - } - - @Override - public Email insert(Email entity) throws Exception { - Optional existingEmail = repository.findByEmail(entity.getEmail()); - return existingEmail.orElseGet(() -> repository.save(entity)); - } -} diff --git a/src/main/java/cc/wordview/api/service/specification/EmailServiceInterface.java b/src/main/java/cc/wordview/api/service/specification/EmailServiceInterface.java deleted file mode 100644 index 0c20f8c..0000000 --- a/src/main/java/cc/wordview/api/service/specification/EmailServiceInterface.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2025 Arthur Araujo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package cc.wordview.api.service.specification; - -import cc.wordview.api.database.entity.Email; - -public interface EmailServiceInterface extends ServiceInterface { -} diff --git a/src/test/java/cc/wordview/api/test/api/controller/EmailControllerTest.java b/src/test/java/cc/wordview/api/test/api/controller/EmailControllerTest.java deleted file mode 100644 index f2b596c..0000000 --- a/src/test/java/cc/wordview/api/test/api/controller/EmailControllerTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2025 Arthur Araujo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package cc.wordview.api.test.api.controller; - -import org.junit.jupiter.api.Test; - -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -public class EmailControllerTest extends ControllerTest { - @Test - void addEmail() throws Exception { - req.get("/email?email=arthur.araujo@gmail.com").andExpect(status().isOk()); - } - - @Test - void addExistingEmail() throws Exception { - req.get("/email?email=mock.user@gmail.com").andExpect(status().isOk()); - } - - @Test - void invalidEmail() throws Exception { - req.get("/email?email=notaemail").andExpect(status().isBadRequest()); - req.get("/email?email=notaemai@com.com").andExpect(status().isBadRequest()); - req.get("/email?email=notaemail@").andExpect(status().isBadRequest()); - } -}