Ignore:
Timestamp:
10/01/22 22:57:41 (2 years ago)
Author:
Marko <Marko@…>
Branches:
master
Children:
47f4eaf
Parents:
fd5b100
Message:

Added few methods in PhoneOffer service

Location:
phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers/AdminController.java

    rfd5b100 rffd50db  
    2323            MediaType.APPLICATION_XML_VALUE
    2424    })
    25     public ResponseEntity<Object> editOffer(@PathVariable("offerId") Long offerId, @RequestBody PhoneOffer editedOffer){
     25    public ResponseEntity<Object> editOffer(@PathVariable("offerId") Long offerId, @RequestBody PhoneOffer editedOffer)
     26    {
    2627
    2728        return phoneOfferService.editOffer(offerId,editedOffer);
  • phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers/PhoneController.java

    rfd5b100 rffd50db  
    66import finki.it.phoneluxbackend.services.PhoneService;
    77import lombok.AllArgsConstructor;
     8import org.apache.coyote.Response;
    89import org.springframework.beans.factory.annotation.Autowired;
     10import org.springframework.http.MediaType;
     11import org.springframework.http.ResponseEntity;
    912import org.springframework.web.bind.annotation.*;
    1013
     
    5053    }
    5154
     55    @GetMapping(path = "/totaloffers/{phoneModel}")
     56    public Long getTotalOffersForPhone(@PathVariable("phoneModel") String phoneModel){
     57        return phoneService.getTotalOffersForPhone(phoneModel);
     58    }
     59
     60    @PutMapping(path = "/settotaloffers/{phoneId}/{totaloffers}")
     61    public ResponseEntity<Object> setTotalOffersForPhone(@PathVariable("phoneId") Long phoneId,
     62                                                         @PathVariable("totaloffers") int totaloffers){
     63        return phoneService.setTotalOffersForPhone(phoneId,totaloffers);
     64    }
     65
     66    @PutMapping(path = "/setlowestprice/{phoneId}/{lowestPrice}")
     67    public ResponseEntity<Object> setLowestPriceForPhone(@PathVariable("phoneId") Long phoneId,
     68                                                         @PathVariable("lowestPrice") int lowestPrice){
     69        return phoneService.setLowestPriceForPhone(phoneId,lowestPrice);
     70    }
     71
     72    @PutMapping(path = "/setimageurl/{phoneId}", consumes = {
     73            MediaType.APPLICATION_JSON_VALUE,
     74            MediaType.APPLICATION_XML_VALUE
     75    }, produces = {
     76            MediaType.APPLICATION_JSON_VALUE,
     77            MediaType.APPLICATION_XML_VALUE
     78    })
     79    public ResponseEntity<Object> setImageUrlForPhone(@PathVariable("phoneId") Long phoneId,
     80                                                         @RequestBody String newImageUrl){
     81        return phoneService.setImageUrlForPhone(phoneId,newImageUrl);
     82    }
     83
     84
    5285}
  • phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers/PhoneOfferController.java

    rfd5b100 rffd50db  
    77import lombok.AllArgsConstructor;
    88import org.springframework.beans.factory.annotation.Autowired;
     9import org.springframework.http.ResponseEntity;
    910import org.springframework.web.bind.annotation.*;
    1011
     
    1617    private final PhoneOfferService phoneOfferService;
    1718
     19
     20    @GetMapping(path = "/alloffers")
     21    public List<PhoneOffer> getAllOffers(){
     22        return phoneOfferService.getAllOffers();
     23    }
    1824    @GetMapping(path = "/phones/offers/{phoneId}")
    1925    public List<PhoneOffer> getOffersForPhone(@PathVariable("phoneId") Long phoneId){
     
    2228
    2329    @GetMapping(path = "/multipleoffers")
    24     public List<PhoneOffer> getPhoneOffer(@RequestParam("offerIds") String offerIds){
     30    public List<PhoneOffer> getMultiplePhoneOffers(@RequestParam("offerIds") String offerIds){
    2531        return phoneOfferService.getMultiplePhoneOffers(offerIds);
    2632    }
     
    5864    }
    5965
     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    }
    6091}
Note: See TracChangeset for help on using the changeset viewer.