[dfd5d87] | 1 | package finki.it.phoneluxbackend.controllers;
|
---|
| 2 |
|
---|
[f25d07e] | 3 | import finki.it.phoneluxbackend.entities.Phone;
|
---|
[dfd5d87] | 4 | import finki.it.phoneluxbackend.entities.PhoneOffer;
|
---|
| 5 | import finki.it.phoneluxbackend.services.PhoneOfferService;
|
---|
[f25d07e] | 6 | import finki.it.phoneluxbackend.services.PhoneService;
|
---|
| 7 | import lombok.AllArgsConstructor;
|
---|
[dfd5d87] | 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
|
---|
[f25d07e] | 17 | @AllArgsConstructor
|
---|
[dfd5d87] | 18 | public class PhoneOfferController {
|
---|
| 19 | private final PhoneOfferService phoneOfferService;
|
---|
| 20 |
|
---|
[e5b84dc] | 21 | @GetMapping(path = "/phones/offers/{phoneId}")
|
---|
[dfd5d87] | 22 | public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){
|
---|
| 23 | return phoneOfferService.getPhoneOffersForPhone(phoneId);
|
---|
| 24 | }
|
---|
[f25d07e] | 25 |
|
---|
[e5b84dc] | 26 | @GetMapping(path = "/phoneoffer/{offerId}")
|
---|
| 27 | public PhoneOffer getPhoneOffer(@PathVariable("offerId") Long offerId){
|
---|
| 28 | return phoneOfferService.getPhoneOffer(offerId);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
[775e15e] | 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 |
|
---|
[dfd5d87] | 53 | }
|
---|