[775e15e] | 1 | package finki.it.phoneluxbackend.controllers;
|
---|
| 2 | import finki.it.phoneluxbackend.entities.PhoneOffer;
|
---|
| 3 | import finki.it.phoneluxbackend.entities.User;
|
---|
| 4 | import finki.it.phoneluxbackend.services.PhoneOfferService;
|
---|
| 5 | import finki.it.phoneluxbackend.services.UserService;
|
---|
| 6 | import lombok.AllArgsConstructor;
|
---|
| 7 | import org.springframework.http.ResponseEntity;
|
---|
| 8 | import org.springframework.web.bind.annotation.*;
|
---|
| 9 |
|
---|
| 10 | import java.util.List;
|
---|
| 11 |
|
---|
| 12 | @RestController
|
---|
| 13 | @RequestMapping(path = "/user")
|
---|
| 14 | @AllArgsConstructor
|
---|
| 15 | public class UserController {
|
---|
| 16 | private final UserService userService;
|
---|
| 17 |
|
---|
| 18 | @GetMapping(path = "/{userId}/favouriteoffers")
|
---|
| 19 | public List<PhoneOffer> getFavouriteOffersForUser(@PathVariable("userId") Long userId){
|
---|
| 20 | return userService.getFavouriteOffersForUser(userId);
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | @PutMapping(path = "/{userId}/addoffer/{offerId}")
|
---|
| 24 | public ResponseEntity<Object> addOfferForUser(@PathVariable("userId") Long userId,
|
---|
| 25 | @PathVariable("offerId") Long offerId){
|
---|
| 26 | return userService.editOfferForUser(userId,offerId, "add");
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | @PutMapping(path = "/{userId}/removeoffer/{offerId}")
|
---|
| 30 | public ResponseEntity<Object> removeOfferForUser(@PathVariable("userId") Long userId,
|
---|
| 31 | @PathVariable("offerId") Long offerId){
|
---|
| 32 | return userService.editOfferForUser(userId,offerId, "remove");
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | }
|
---|