mirror of
https://github.com/Lemonochrme/service-architecture.git
synced 2025-06-08 05:30:50 +02:00
Backend: Added "get" for both Feedback and request
This commit is contained in:
parent
3b8b095db5
commit
afa0b81a04
4 changed files with 25 additions and 3 deletions
|
@ -24,7 +24,7 @@ Course Exercice : Application to help others
|
|||
- [X] `Rest` Create a Help Request
|
||||
- [X] `Rest` Modify the Help Request status
|
||||
- [X] `Rest` Create a User Feedback
|
||||
- [ ] `Rest` Gather User Feedbacks
|
||||
- [X] `Rest` Gather User Feedbacks
|
||||
|
||||
## Check `SOAP` Requests
|
||||
|
||||
|
|
|
@ -2,5 +2,8 @@ package insa.application.helpapp.rest;
|
|||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FeedbackRepository extends JpaRepository<Feedback, Integer> {
|
||||
List<Feedback> findByIdRequest(int idRequest);
|
||||
}
|
|
@ -8,10 +8,10 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
|
@ -64,4 +64,14 @@ public class FeedbackServiceApplication {
|
|||
feedback.setMessage(message);
|
||||
return ResponseEntity.ok(feedbackRepository.save(feedback));
|
||||
}
|
||||
|
||||
@GetMapping("/get_feedback")
|
||||
public ResponseEntity<?> GetFeedback(@RequestParam int idRequest)
|
||||
{
|
||||
List<Feedback> feedbacks = feedbackRepository.findByIdRequest(idRequest);
|
||||
if(feedbacks.isEmpty()) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("No feedback exists for the following request.");
|
||||
}
|
||||
return ResponseEntity.ok(feedbacks);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@SpringBootApplication
|
||||
|
@ -116,4 +117,12 @@ public class RequestServiceApplication {
|
|||
.body("Only Admins can perform this action.");
|
||||
}
|
||||
|
||||
@GetMapping("/get_request")
|
||||
public ResponseEntity<?> getRoles() {
|
||||
List<Request> requests = requestRepository.findAll();
|
||||
if(requests.isEmpty()) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("No requests.");
|
||||
}
|
||||
return ResponseEntity.ok(requests);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue