source: phonelux-backend/src/main/java/finki/it/phoneluxbackend/controllers/UserController.java@ 775e15e

Last change on this file since 775e15e was 775e15e, checked in by Marko <Marko@…>, 22 months ago

Added more controllers

  • Property mode set to 100644
File size: 1.4 KB
Line 
1package finki.it.phoneluxbackend.controllers;
2import finki.it.phoneluxbackend.entities.PhoneOffer;
3import finki.it.phoneluxbackend.entities.User;
4import finki.it.phoneluxbackend.services.PhoneOfferService;
5import finki.it.phoneluxbackend.services.UserService;
6import lombok.AllArgsConstructor;
7import org.springframework.http.ResponseEntity;
8import org.springframework.web.bind.annotation.*;
9
10import java.util.List;
11
12@RestController
13@RequestMapping(path = "/user")
14@AllArgsConstructor
15public 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}
Note: See TracBrowser for help on using the repository browser.