source: phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers/PhoneController.java@ 775e15e

Last change on this file since 775e15e was 775e15e, checked in by Marko <Marko@…>, 22 months ago

Added more controllers

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[b68ae8d]1package finki.it.phoneluxbackend.controllers;
2
3import finki.it.phoneluxbackend.entities.Phone;
4import finki.it.phoneluxbackend.entities.PhoneOffer;
[f25d07e]5import finki.it.phoneluxbackend.services.PhoneOfferService;
[b68ae8d]6import finki.it.phoneluxbackend.services.PhoneService;
[f25d07e]7import lombok.AllArgsConstructor;
[b68ae8d]8import org.springframework.beans.factory.annotation.Autowired;
9import org.springframework.web.bind.annotation.*;
10
[f25d07e]11import java.util.Comparator;
[b68ae8d]12import java.util.List;
[f25d07e]13import java.util.stream.Collectors;
[b68ae8d]14
15@RestController
[f25d07e]16@AllArgsConstructor
[b68ae8d]17@RequestMapping(path = "/")
18public class PhoneController {
19 private final PhoneService phoneService;
20
[f25d07e]21 @GetMapping(path = "/phones")
[e5b84dc]22 public List<Phone> getPhones(@RequestParam(name = "shops", required = false) String shops,
23 @RequestParam(name = "brands", required = false) String brands,
24 @RequestParam(name = "sortBy", required = false) String sortBy,
25 @RequestParam(name = "priceRange", required = false) String priceRange,
26 @RequestParam(name = "searchValue", required = false) String searchValue){
27
28 return phoneService.getPhones(shops,brands,sortBy,priceRange,searchValue);
[b68ae8d]29 }
30
[f25d07e]31 @GetMapping(path = "/phones/{phoneId}")
32 public Phone getPhoneById(@PathVariable("phoneId") Long phoneId)
33 {
34 return phoneService.getPhoneById(phoneId);
35 }
[dfd5d87]36
[f25d07e]37 @GetMapping(path = "/brands")
38 public List<String> getBrands(){
39 return phoneService.getBrands();
40 }
41
[b68ae8d]42}
Note: See TracBrowser for help on using the repository browser.