diff --git a/helpapp-backend/README.md b/helpapp-backend/README.md index 2d8eeb6..dbf4d5f 100644 --- a/helpapp-backend/README.md +++ b/helpapp-backend/README.md @@ -101,3 +101,85 @@ curl -X POST -H "Content-Type: application/json" -d '{"description":"Available f - **Scalabilité** : Les microservices peuvent être déployés et mis à l'échelle individuellement. - **Flexibilité** : Possibilité d’utiliser différentes technologies pour chaque service. - **Maintenance** : Une meilleure isolation des fonctionnalités simplifie le débogage et les mises à jour. + + + + + + + + + + + + + + + + + + + + + + + + + + + +#### Tester les services + +##### 1. **Créer un utilisateur avec UserService** +```bash +curl -X POST -H "Content-Type: application/json" \ +-d '{"name":"Jane Doe", "email":"jane@example.com", "password":"1234", "role":"REQUESTER"}' \ +http://localhost:8083/users +``` + +##### 2. **Créer une demande avec RequestService** +```bash +curl -X POST -H "Content-Type: application/json" \ +-d '{"userId":1, "details":"I need help with my groceries"}' \ +http://localhost:8082/requests +``` + +##### 3. **Valider une demande avec AdministrationService** +```bash +curl -X PUT http://localhost:8080/admin/requests/1/validate +``` + +##### 4. **Ajouter un feedback avec FeedbackService** +```bash +curl -X POST -H "Content-Type: application/json" \ +-d '{"requestId":1, "comment":"Great service!", "rating":5}' \ +http://localhost:8081/feedbacks +``` + +##### 5. **Un volontaire répond à une demande avec VolunteerService** +```bash +curl -X POST http://localhost:8084/volunteers/1/help?requestId=1 +``` + + + +- **Lister les utilisateurs (UserService)** : + ```bash + curl -X GET http://localhost:8083/users/1 + ``` + +- **Lister les demandes associées à un utilisateur (RequestService)** : + ```bash + curl -X GET http://localhost:8082/requests/user/1 + ``` + +- **Lister les feedbacks pour une demande (FeedbackService)** : + ```bash + curl -X GET http://localhost:8081/feedbacks/request/1 + ``` + +- **Lister les actions des volontaires (VolunteerService)** : + ```bash + curl -X GET http://localhost:8084/volunteers/actions + ``` + diff --git a/helpapp-backend/administration-service/src/main/java/insa/application/helpapp/rest/AdministrationServiceApplication.java b/helpapp-backend/administration-service/src/main/java/insa/application/helpapp/rest/AdministrationServiceApplication.java index f07ef42..e0ac220 100644 --- a/helpapp-backend/administration-service/src/main/java/insa/application/helpapp/rest/AdministrationServiceApplication.java +++ b/helpapp-backend/administration-service/src/main/java/insa/application/helpapp/rest/AdministrationServiceApplication.java @@ -2,19 +2,38 @@ 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; +import org.springframework.web.bind.annotation.*; + +import java.util.*; @SpringBootApplication @RestController +@RequestMapping("/admin/requests") public class AdministrationServiceApplication { + private final Map requestStatusDatabase = new HashMap<>(); + public static void main(String[] args) { SpringApplication.run(AdministrationServiceApplication.class, args); } - @GetMapping("/hello") - public String hello() { - return "Hello from Administration Service!"; + // Validate a request + @PutMapping("/{id}/validate") + public String validateRequest(@PathVariable Long id) { + requestStatusDatabase.put(id, "Validated"); + return "Request " + id + " validated."; + } + + // Reject a request with justification + @PutMapping("/{id}/reject") + public String rejectRequest(@PathVariable Long id, @RequestParam String reason) { + requestStatusDatabase.put(id, "Rejected: " + reason); + return "Request " + id + " rejected for reason: " + reason; + } + + // View request statuses + @GetMapping + public Map viewAllStatuses() { + return requestStatusDatabase; } } diff --git a/helpapp-backend/feedback-service/src/main/java/insa/application/helpapp/rest/FeedbackServiceApplication.java b/helpapp-backend/feedback-service/src/main/java/insa/application/helpapp/rest/FeedbackServiceApplication.java index 242a16e..89f29f1 100644 --- a/helpapp-backend/feedback-service/src/main/java/insa/application/helpapp/rest/FeedbackServiceApplication.java +++ b/helpapp-backend/feedback-service/src/main/java/insa/application/helpapp/rest/FeedbackServiceApplication.java @@ -2,19 +2,82 @@ 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; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import java.util.concurrent.atomic.AtomicLong; @SpringBootApplication @RestController +@RequestMapping("/feedbacks") public class FeedbackServiceApplication { + private final Map feedbackDatabase = new HashMap<>(); + private final AtomicLong idGenerator = new AtomicLong(1); + public static void main(String[] args) { SpringApplication.run(FeedbackServiceApplication.class, args); } - @GetMapping("/hello") - public String hello() { - return "Hello from FeedBack Service!"; + // Add feedback + @PostMapping + public Feedback addFeedback(@RequestBody Feedback feedback) { + long id = idGenerator.getAndIncrement(); + feedback.setId(id); + feedbackDatabase.put(id, feedback); + return feedback; + } + + // Get feedback by request ID + @GetMapping("/request/{requestId}") + public List getFeedbackByRequest(@PathVariable Long requestId) { + List feedbackList = new ArrayList<>(); + for (Feedback feedback : feedbackDatabase.values()) { + if (feedback.getRequestId().equals(requestId)) { + feedbackList.add(feedback); + } + } + return feedbackList; + } + + // Feedback entity + static class Feedback { + private Long id; + private Long requestId; + private String comment; + private Integer rating; // 1 to 5 + + // Getters and setters + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getRequestId() { + return requestId; + } + + public void setRequestId(Long requestId) { + this.requestId = requestId; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public Integer getRating() { + return rating; + } + + public void setRating(Integer rating) { + this.rating = rating; + } } } diff --git a/helpapp-backend/request-service/src/main/java/insa/application/helpapp/rest/RequestServiceApplication.java b/helpapp-backend/request-service/src/main/java/insa/application/helpapp/rest/RequestServiceApplication.java index 3fafff7..571ce1e 100644 --- a/helpapp-backend/request-service/src/main/java/insa/application/helpapp/rest/RequestServiceApplication.java +++ b/helpapp-backend/request-service/src/main/java/insa/application/helpapp/rest/RequestServiceApplication.java @@ -57,6 +57,12 @@ public class RequestServiceApplication { return userRequests; } + // Get all help requests + @GetMapping + public List getAllRequests() { + return new ArrayList<>(requestDatabase.values()); + } + // Simulate user validation (integration with UserService) private boolean isUserValid(Long userId) { try { diff --git a/helpapp-backend/volunteer-service/src/main/java/insa/application/helpapp/rest/VolunteerServiceApplication.java b/helpapp-backend/volunteer-service/src/main/java/insa/application/helpapp/rest/VolunteerServiceApplication.java index 41dfd4c..65897e5 100644 --- a/helpapp-backend/volunteer-service/src/main/java/insa/application/helpapp/rest/VolunteerServiceApplication.java +++ b/helpapp-backend/volunteer-service/src/main/java/insa/application/helpapp/rest/VolunteerServiceApplication.java @@ -2,19 +2,37 @@ 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; +import org.springframework.web.bind.annotation.*; + +import java.util.*; @SpringBootApplication @RestController +@RequestMapping("/volunteers") public class VolunteerServiceApplication { + private final Map volunteerActions = new HashMap<>(); + public static void main(String[] args) { SpringApplication.run(VolunteerServiceApplication.class, args); } - @GetMapping("/hello") - public String hello() { - return "Hello from Volunteer Service!"; + // View available requests (simulating) + @GetMapping("/requests") + public List viewAvailableRequests() { + return List.of("Request 1: Grocery delivery", "Request 2: Medical help"); + } + + // Respond to a specific request + @PostMapping("/{volunteerId}/help") + public String respondToRequest(@PathVariable Long volunteerId, @RequestParam Long requestId) { + volunteerActions.put(requestId, "Volunteer " + volunteerId + " responded."); + return "Volunteer " + volunteerId + " responded to request " + requestId; + } + + // View all volunteer actions + @GetMapping("/actions") + public Map viewActions() { + return volunteerActions; } } diff --git a/helpapp-frontend/index.html b/helpapp-frontend/index.html deleted file mode 100644 index a6011d8..0000000 --- a/helpapp-frontend/index.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - HelpApp - Simple Frontend - - -

HelpApp - Test Frontend

- - -
-

User Service

-
-

Create User

- - - - - -
- -
-

Get User by ID

- - -
-
-
- - -
-

Request Service

-
-

Create Help Request

- - - -
- -
-

Get Requests by User ID

- - -
-
-
- - - -