[5201690] | 1 | package finki.it.phoneluxbackend.controllers;
|
---|
| 2 |
|
---|
| 3 | import finki.it.phoneluxbackend.entities.PhoneOffer;
|
---|
| 4 | import finki.it.phoneluxbackend.services.PhoneOfferService;
|
---|
| 5 | import lombok.AllArgsConstructor;
|
---|
| 6 | import org.apache.coyote.Response;
|
---|
| 7 | import org.springframework.http.MediaType;
|
---|
| 8 | import org.springframework.http.ResponseEntity;
|
---|
| 9 | import org.springframework.web.bind.annotation.*;
|
---|
| 10 |
|
---|
| 11 | @RestController
|
---|
| 12 | @RequestMapping(path = "/admin")
|
---|
| 13 | @AllArgsConstructor
|
---|
| 14 | public class AdminController {
|
---|
| 15 | private PhoneOfferService phoneOfferService;
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | @PutMapping(path = "/editoffer/{offerId}", consumes = {
|
---|
| 19 | MediaType.APPLICATION_JSON_VALUE,
|
---|
| 20 | MediaType.APPLICATION_XML_VALUE
|
---|
| 21 | }, produces = {
|
---|
| 22 | MediaType.APPLICATION_JSON_VALUE,
|
---|
| 23 | MediaType.APPLICATION_XML_VALUE
|
---|
| 24 | })
|
---|
[ffd50db] | 25 | public ResponseEntity<Object> editOffer(@PathVariable("offerId") Long offerId, @RequestBody PhoneOffer editedOffer)
|
---|
| 26 | {
|
---|
[5201690] | 27 |
|
---|
| 28 | return phoneOfferService.editOffer(offerId,editedOffer);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | @PutMapping(path = "/validateoffer/{offerId}")
|
---|
| 32 | public ResponseEntity<Object> validateOffer(@PathVariable("offerId") Long offerId){
|
---|
| 33 | return phoneOfferService.validateOffer(offerId);
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | @GetMapping(path = "/editoffer/{offerId}")
|
---|
| 38 | public ResponseEntity<Object> getOffer(@PathVariable("offerId") Long offerId){
|
---|
| 39 | return ResponseEntity.ok().body(phoneOfferService.getPhoneOffer(offerId));
|
---|
| 40 | }
|
---|
| 41 | }
|
---|