source: phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers/PhoneOfferController.java

Last change on this file was ffd50db, checked in by Marko <Marko@…>, 2 years ago

Added few methods in PhoneOffer service

  • Property mode set to 100644
File size: 3.2 KB
Line 
1package finki.it.phoneluxbackend.controllers;
2
3import finki.it.phoneluxbackend.entities.Phone;
4import finki.it.phoneluxbackend.entities.PhoneOffer;
5import finki.it.phoneluxbackend.services.PhoneOfferService;
6import finki.it.phoneluxbackend.services.PhoneService;
7import lombok.AllArgsConstructor;
8import org.springframework.beans.factory.annotation.Autowired;
9import org.springframework.http.ResponseEntity;
10import org.springframework.web.bind.annotation.*;
11
12import java.util.List;
13
14@RestController
15@AllArgsConstructor
16public class PhoneOfferController {
17 private final PhoneOfferService phoneOfferService;
18
19
20 @GetMapping(path = "/alloffers")
21 public List<PhoneOffer> getAllOffers(){
22 return phoneOfferService.getAllOffers();
23 }
24 @GetMapping(path = "/phones/offers/{phoneId}")
25 public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){
26 return phoneOfferService.getPhoneOffersForPhone(phoneId);
27 }
28
29 @GetMapping(path = "/multipleoffers")
30 public List<PhoneOffer> getMultiplePhoneOffers(@RequestParam("offerIds") String offerIds){
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
39 @GetMapping(path = "/phoneoffer/{offerId}")
40 public PhoneOffer getPhoneOffer(@PathVariable("offerId") Long offerId){
41 return phoneOfferService.getPhoneOffer(offerId);
42 }
43
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
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 }
91}
Note: See TracBrowser for help on using the repository browser.