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.GetMapping;
|
---|
10 | import org.springframework.web.bind.annotation.PathVariable;
|
---|
11 | import org.springframework.web.bind.annotation.RequestMapping;
|
---|
12 | import org.springframework.web.bind.annotation.RestController;
|
---|
13 |
|
---|
14 | import java.util.List;
|
---|
15 |
|
---|
16 | @RestController
|
---|
17 | @AllArgsConstructor
|
---|
18 | public class PhoneOfferController {
|
---|
19 | private final PhoneOfferService phoneOfferService;
|
---|
20 |
|
---|
21 | @GetMapping(path = "/phones/offers/{phoneId}")
|
---|
22 | public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){
|
---|
23 | return phoneOfferService.getPhoneOffersForPhone(phoneId);
|
---|
24 | }
|
---|
25 |
|
---|
26 | @GetMapping(path = "/phoneoffer/{offerId}")
|
---|
27 | public PhoneOffer getPhoneOffer(@PathVariable("offerId") Long offerId){
|
---|
28 | return phoneOfferService.getPhoneOffer(offerId);
|
---|
29 | }
|
---|
30 |
|
---|
31 | @GetMapping(path = "/phoneoffer/{offerId}/cheaperoffers")
|
---|
32 | public List<PhoneOffer> getCheaperOffers(@PathVariable("offerId") Long offerId){
|
---|
33 | return phoneOfferService.getCheaperOffers(offerId);
|
---|
34 | }
|
---|
35 |
|
---|
36 | @GetMapping(path = "/shops")
|
---|
37 | public List<String> getShops(){
|
---|
38 | return phoneOfferService.getShops();
|
---|
39 | }
|
---|
40 |
|
---|
41 | @GetMapping(path = "/lowestPrice")
|
---|
42 | public int getLowestPrice()
|
---|
43 | {
|
---|
44 | return phoneOfferService.getLowestPrice();
|
---|
45 | }
|
---|
46 |
|
---|
47 | @GetMapping(path = "/highestPrice")
|
---|
48 | public int getHighestPrice()
|
---|
49 | {
|
---|
50 | return phoneOfferService.getHighestPrice();
|
---|
51 | }
|
---|
52 |
|
---|
53 | }
|
---|