[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;
|
---|
[5201690] | 9 | import org.springframework.web.bind.annotation.*;
|
---|
[dfd5d87] | 10 |
|
---|
| 11 | import java.util.List;
|
---|
| 12 |
|
---|
| 13 | @RestController
|
---|
[f25d07e] | 14 | @AllArgsConstructor
|
---|
[dfd5d87] | 15 | public class PhoneOfferController {
|
---|
| 16 | private final PhoneOfferService phoneOfferService;
|
---|
| 17 |
|
---|
[e5b84dc] | 18 | @GetMapping(path = "/phones/offers/{phoneId}")
|
---|
[dfd5d87] | 19 | public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){
|
---|
| 20 | return phoneOfferService.getPhoneOffersForPhone(phoneId);
|
---|
| 21 | }
|
---|
[f25d07e] | 22 |
|
---|
[5201690] | 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 |
|
---|
[e5b84dc] | 33 | @GetMapping(path = "/phoneoffer/{offerId}")
|
---|
| 34 | public PhoneOffer getPhoneOffer(@PathVariable("offerId") Long offerId){
|
---|
| 35 | return phoneOfferService.getPhoneOffer(offerId);
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[775e15e] | 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 |
|
---|
[dfd5d87] | 60 | }
|
---|