1 | package finki.it.phoneluxbackend.controllers;
|
---|
2 |
|
---|
3 | import finki.it.phoneluxbackend.entities.Phone;
|
---|
4 | import finki.it.phoneluxbackend.entities.PhoneOffer;
|
---|
5 | import finki.it.phoneluxbackend.services.PhoneOfferService;
|
---|
6 | import finki.it.phoneluxbackend.services.PhoneService;
|
---|
7 | import lombok.AllArgsConstructor;
|
---|
8 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
9 | import org.springframework.web.bind.annotation.*;
|
---|
10 |
|
---|
11 | import java.util.List;
|
---|
12 |
|
---|
13 | @RestController
|
---|
14 | @AllArgsConstructor
|
---|
15 | public class PhoneOfferController {
|
---|
16 | private final PhoneOfferService phoneOfferService;
|
---|
17 |
|
---|
18 | @GetMapping(path = "/phones/offers/{phoneId}")
|
---|
19 | public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){
|
---|
20 | return phoneOfferService.getPhoneOffersForPhone(phoneId);
|
---|
21 | }
|
---|
22 |
|
---|
23 | @GetMapping(path = "/multipleoffers")
|
---|
24 | public List<PhoneOffer> getPhoneOffer(@RequestParam("offerIds") String offerIds){
|
---|
25 | return phoneOfferService.getMultiplePhoneOffers(offerIds);
|
---|
26 | }
|
---|
27 |
|
---|
28 | @GetMapping(path = "/phoneoffer/shop/{shop}")
|
---|
29 | public List<PhoneOffer> getOffersFromShop(@PathVariable("shop") String shop){
|
---|
30 | return phoneOfferService.getOffersFromShop(shop);
|
---|
31 | }
|
---|
32 |
|
---|
33 | @GetMapping(path = "/phoneoffer/{offerId}")
|
---|
34 | public PhoneOffer getPhoneOffer(@PathVariable("offerId") Long offerId){
|
---|
35 | return phoneOfferService.getPhoneOffer(offerId);
|
---|
36 | }
|
---|
37 |
|
---|
38 | @GetMapping(path = "/phoneoffer/{offerId}/cheaperoffers")
|
---|
39 | public List<PhoneOffer> getCheaperOffers(@PathVariable("offerId") Long offerId){
|
---|
40 | return phoneOfferService.getCheaperOffers(offerId);
|
---|
41 | }
|
---|
42 |
|
---|
43 | @GetMapping(path = "/shops")
|
---|
44 | public List<String> getShops(){
|
---|
45 | return phoneOfferService.getShops();
|
---|
46 | }
|
---|
47 |
|
---|
48 | @GetMapping(path = "/lowestPrice")
|
---|
49 | public int getLowestPrice()
|
---|
50 | {
|
---|
51 | return phoneOfferService.getLowestPrice();
|
---|
52 | }
|
---|
53 |
|
---|
54 | @GetMapping(path = "/highestPrice")
|
---|
55 | public int getHighestPrice()
|
---|
56 | {
|
---|
57 | return phoneOfferService.getHighestPrice();
|
---|
58 | }
|
---|
59 |
|
---|
60 | }
|
---|