filteredRequests = new ArrayList<>();
+ for (HelpRequest request : requestDatabase.values()) {
+ if (request.getStatus().equalsIgnoreCase(status)) {
+ filteredRequests.add(request);
+ }
+ }
+ return filteredRequests;
+ }
+
+ // Get a specific request by ID
+ @GetMapping("/{id}")
+ public HelpRequest getRequest(@PathVariable Long id) {
+ return Optional.ofNullable(requestDatabase.get(id))
+ .orElseThrow(() -> new RuntimeException("Request not found"));
+ }
+
+ // Update a request (e.g., status or details)
+ @PutMapping("/{id}")
+ public HelpRequest updateRequest(@PathVariable Long id, @RequestBody HelpRequest updatedRequest) {
+ if (!requestDatabase.containsKey(id)) {
+ throw new RuntimeException("Request not found");
+ }
+ HelpRequest existingRequest = requestDatabase.get(id);
+ if (updatedRequest.getDetails() != null) {
+ existingRequest.setDetails(updatedRequest.getDetails());
+ }
+ if (updatedRequest.getStatus() != null) {
+ existingRequest.setStatus(updatedRequest.getStatus());
+ }
+ return existingRequest;
+ }
+
+ // Delete a request
+ @DeleteMapping("/{id}")
+ public String deleteRequest(@PathVariable Long id) {
+ if (requestDatabase.remove(id) == null) {
+ throw new RuntimeException("Request not found");
+ }
+ return "Request deleted successfully";
+ }
+
+ // HelpRequest entity
+ static class HelpRequest {
+ private Long id;
+ private String details;
+ private String status; // e.g., Pending, Validated, Rejected, Completed
+
+ // Getters and setters
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getDetails() {
+ return details;
+ }
+
+ public void setDetails(String details) {
+ this.details = details;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+ }
+}
diff --git a/helpapp/request-service/src/main/resources/application.properties b/helpapp/request-service/src/main/resources/application.properties
new file mode 100644
index 0000000..3cf12af
--- /dev/null
+++ b/helpapp/request-service/src/main/resources/application.properties
@@ -0,0 +1 @@
+server.port=8082
diff --git a/helpapp/src/main/java/insa/application/helpapp/CustomErrorController.java b/helpapp/src/main/java/insa/application/helpapp/CustomErrorController.java
deleted file mode 100644
index 32f0f72..0000000
--- a/helpapp/src/main/java/insa/application/helpapp/CustomErrorController.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package insa.application.helpapp;
-
-import org.springframework.boot.web.servlet.error.ErrorController;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-@Controller
-public class CustomErrorController implements ErrorController {
-
- @RequestMapping("/error")
- @ResponseBody
- public String handleError() {
- // Return the inline HTML content for the custom error page
- return "ErrorSomething went wrong!
We are sorry, but the page you are looking for does not exist.
";
- }
-}
\ No newline at end of file
diff --git a/helpapp/src/main/java/insa/application/helpapp/HelpappApplication.java b/helpapp/src/main/java/insa/application/helpapp/HelpappApplication.java
deleted file mode 100644
index ee1a710..0000000
--- a/helpapp/src/main/java/insa/application/helpapp/HelpappApplication.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package insa.application.helpapp;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class HelpappApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(HelpappApplication.class, args);
- }
-
-}
diff --git a/helpapp/src/main/resources/application.properties b/helpapp/src/main/resources/application.properties
deleted file mode 100644
index 42482f7..0000000
--- a/helpapp/src/main/resources/application.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-spring.application.name=helpapp
-server.port=8080
\ No newline at end of file
diff --git a/helpapp/src/test/java/insa/application/helpapp/HelpappApplicationTests.java b/helpapp/src/test/java/insa/application/helpapp/HelpappApplicationTests.java
deleted file mode 100644
index 34f598c..0000000
--- a/helpapp/src/test/java/insa/application/helpapp/HelpappApplicationTests.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package insa.application.helpapp;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class HelpappApplicationTests {
-
- @Test
- void contextLoads() {
- }
-
-}
diff --git a/helpapp/user-service/pom.xml b/helpapp/user-service/pom.xml
new file mode 100644
index 0000000..49f044d
--- /dev/null
+++ b/helpapp/user-service/pom.xml
@@ -0,0 +1,40 @@
+
+
+ insa.application.helpapp
+ helpapp
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ user-service
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 3.1.4
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 21
+ 21
+
+
+
+
+
+
diff --git a/helpapp/user-service/src/main/java/insa/application/helpapp/rest/UserServiceApplication.java b/helpapp/user-service/src/main/java/insa/application/helpapp/rest/UserServiceApplication.java
new file mode 100644
index 0000000..a2d7b66
--- /dev/null
+++ b/helpapp/user-service/src/main/java/insa/application/helpapp/rest/UserServiceApplication.java
@@ -0,0 +1,98 @@
+package insa.application.helpapp.rest;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+import java.util.concurrent.atomic.AtomicLong;
+
+@SpringBootApplication
+@RestController
+@RequestMapping("/users")
+public class UserServiceApplication {
+
+ private final Map userDatabase = new HashMap<>();
+ private final AtomicLong idGenerator = new AtomicLong(1);
+
+ public static void main(String[] args) {
+ SpringApplication.run(UserServiceApplication.class, args);
+ }
+
+ // Create a new user
+ @PostMapping
+ public User createUser(@RequestBody User user) {
+ long id = idGenerator.getAndIncrement();
+ user.setId(id);
+ userDatabase.put(id, user);
+ return user;
+ }
+
+ // Get a user by ID
+ @GetMapping("/{id}")
+ public User getUser(@PathVariable Long id) {
+ return Optional.ofNullable(userDatabase.get(id))
+ .orElseThrow(() -> new RuntimeException("User not found"));
+ }
+
+ // Update a user by ID
+ @PutMapping("/{id}")
+ public User updateUser(@PathVariable Long id, @RequestBody User updatedUser) {
+ if (!userDatabase.containsKey(id)) {
+ throw new RuntimeException("User not found");
+ }
+ updatedUser.setId(id);
+ userDatabase.put(id, updatedUser);
+ return updatedUser;
+ }
+
+ // Delete a user by ID
+ @DeleteMapping("/{id}")
+ public String deleteUser(@PathVariable Long id) {
+ if (userDatabase.remove(id) == null) {
+ throw new RuntimeException("User not found");
+ }
+ return "User deleted successfully";
+ }
+
+ // User entity
+ static class User {
+ private Long id;
+ private String name;
+ private String email;
+ private String role;
+
+ // Getters and setters
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+ }
+}
diff --git a/helpapp/user-service/src/main/resources/application.properties b/helpapp/user-service/src/main/resources/application.properties
new file mode 100644
index 0000000..8f91ca7
--- /dev/null
+++ b/helpapp/user-service/src/main/resources/application.properties
@@ -0,0 +1 @@
+server.port=8083
diff --git a/helpapp/volunteer-service/pom.xml b/helpapp/volunteer-service/pom.xml
new file mode 100644
index 0000000..298515b
--- /dev/null
+++ b/helpapp/volunteer-service/pom.xml
@@ -0,0 +1,40 @@
+
+
+ insa.application.helpapp
+ helpapp
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ volunteer-service
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 3.1.4
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 21
+ 21
+
+
+
+
+
+
diff --git a/helpapp/volunteer-service/src/main/java/insa/application/helpapp/rest/VolunteerServiceApplication.java b/helpapp/volunteer-service/src/main/java/insa/application/helpapp/rest/VolunteerServiceApplication.java
new file mode 100644
index 0000000..41dfd4c
--- /dev/null
+++ b/helpapp/volunteer-service/src/main/java/insa/application/helpapp/rest/VolunteerServiceApplication.java
@@ -0,0 +1,20 @@
+package insa.application.helpapp.rest;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@SpringBootApplication
+@RestController
+public class VolunteerServiceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(VolunteerServiceApplication.class, args);
+ }
+
+ @GetMapping("/hello")
+ public String hello() {
+ return "Hello from Volunteer Service!";
+ }
+}
diff --git a/helpapp/volunteer-service/src/main/resources/application.properties b/helpapp/volunteer-service/src/main/resources/application.properties
new file mode 100644
index 0000000..5e3bb81
--- /dev/null
+++ b/helpapp/volunteer-service/src/main/resources/application.properties
@@ -0,0 +1 @@
+server.port=8084