Skip to content

Commit

Permalink
🚧 (RandomTestimonialController) create
Browse files Browse the repository at this point in the history
  • Loading branch information
logikasciuro committed Jul 27, 2023
1 parent f7a7703 commit 0f137ca
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ecureuill.milhasapi.controller;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import ecureuill.milhasapi.domain.testimonial.TestimonialDetailRecord;
import ecureuill.milhasapi.domain.testimonial.TestimonialRepository;

@RestController
@RequestMapping("/depoimentos-home")
public class RandomTestimonialController {

@Autowired
private TestimonialRepository repository;

@GetMapping
public ResponseEntity<List<TestimonialDetailRecord>> get() {
var testimonials = repository.findThreeTestimonials();
return ResponseEntity.ok().body(testimonials.stream().map(TestimonialDetailRecord::new).collect(Collectors.toList()));
}
}

0 comments on commit 0f137ca

Please sign in to comment.