[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;
|
---|
[ffd50db] | 9 | import org.springframework.http.ResponseEntity;
|
---|
[5201690] | 10 | import org.springframework.web.bind.annotation.*;
|
---|
[dfd5d87] | 11 |
|
---|
| 12 | import java.util.List;
|
---|
| 13 |
|
---|
| 14 | @RestController
|
---|
[f25d07e] | 15 | @AllArgsConstructor
|
---|
[dfd5d87] | 16 | public class PhoneOfferController {
|
---|
| 17 | private final PhoneOfferService phoneOfferService;
|
---|
| 18 |
|
---|
[ffd50db] | 19 |
|
---|
| 20 | @GetMapping(path = "/alloffers")
|
---|
| 21 | public List<PhoneOffer> getAllOffers(){
|
---|
| 22 | return phoneOfferService.getAllOffers();
|
---|
| 23 | }
|
---|
[e5b84dc] | 24 | @GetMapping(path = "/phones/offers/{phoneId}")
|
---|
[dfd5d87] | 25 | public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){
|
---|
| 26 | return phoneOfferService.getPhoneOffersForPhone(phoneId);
|
---|
| 27 | }
|
---|
[f25d07e] | 28 |
|
---|
[5201690] | 29 | @GetMapping(path = "/multipleoffers")
|
---|
[ffd50db] | 30 | public List<PhoneOffer> getMultiplePhoneOffers(@RequestParam("offerIds") String offerIds){
|
---|
[5201690] | 31 | return phoneOfferService.getMultiplePhoneOffers(offerIds);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | @GetMapping(path = "/phoneoffer/shop/{shop}")
|
---|
| 35 | public List<PhoneOffer> getOffersFromShop(@PathVariable("shop") String shop){
|
---|
| 36 | return phoneOfferService.getOffersFromShop(shop);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
[e5b84dc] | 39 | @GetMapping(path = "/phoneoffer/{offerId}")
|
---|
| 40 | public PhoneOffer getPhoneOffer(@PathVariable("offerId") Long offerId){
|
---|
| 41 | return phoneOfferService.getPhoneOffer(offerId);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[775e15e] | 44 | @GetMapping(path = "/phoneoffer/{offerId}/cheaperoffers")
|
---|
| 45 | public List<PhoneOffer> getCheaperOffers(@PathVariable("offerId") Long offerId){
|
---|
| 46 | return phoneOfferService.getCheaperOffers(offerId);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | @GetMapping(path = "/shops")
|
---|
| 50 | public List<String> getShops(){
|
---|
| 51 | return phoneOfferService.getShops();
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | @GetMapping(path = "/lowestPrice")
|
---|
| 55 | public int getLowestPrice()
|
---|
| 56 | {
|
---|
| 57 | return phoneOfferService.getLowestPrice();
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | @GetMapping(path = "/highestPrice")
|
---|
| 61 | public int getHighestPrice()
|
---|
| 62 | {
|
---|
| 63 | return phoneOfferService.getHighestPrice();
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[ffd50db] | 66 |
|
---|
| 67 | @PutMapping(path = "/phoneoffer/{offerId}/addphonemodel/{phoneId}")
|
---|
| 68 | public ResponseEntity<Object> addPhoneModelToOffer(@PathVariable("offerId") Long offerId,
|
---|
| 69 | @PathVariable("phoneId") Long phoneId)
|
---|
| 70 | {
|
---|
| 71 | return phoneOfferService.addPhoneModelToOffer(offerId,phoneId);
|
---|
| 72 | }
|
---|
| 73 | @PutMapping(path = "/phoneoffer/{offerId}/changeprice/{price}")
|
---|
| 74 | public ResponseEntity<Object> changePriceForOffer(@PathVariable("offerId") Long offerId,
|
---|
| 75 | @PathVariable("price") int price)
|
---|
| 76 | {
|
---|
| 77 | return phoneOfferService.changePriceForOffer(offerId,price);
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | @PostMapping(path = "/phoneoffer/addoffer")
|
---|
| 81 | public ResponseEntity<Object> addOffer(@RequestBody PhoneOffer offer)
|
---|
| 82 | {
|
---|
| 83 | return phoneOfferService.addOffer(offer);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | @DeleteMapping(path = "/phoneoffer/deleteoffer/{offerId}")
|
---|
| 87 | public ResponseEntity<Object> deleteOffer(@PathVariable("offerId") Long offerId)
|
---|
| 88 | {
|
---|
| 89 | return phoneOfferService.deleteOffer(offerId);
|
---|
| 90 | }
|
---|
[dfd5d87] | 91 | }
|
---|