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

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

Implemented all use cases

  • Property mode set to 100644
File size: 1.9 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 @PutMapping(path = "/{userId}/editspecifications")
36 public ResponseEntity<Object> editSpecificationsForUser(@PathVariable("userId") Long userId,
37 @RequestBody String specifications){
38 return userService.editSpecificationsForUser(userId,specifications);
39 }
40
41 @GetMapping(path = "/{userId}/getspecifications")
42 public String getSpecificationsForUser(@PathVariable("userId") Long userId){
43 return userService.getSpecificationsForUser(userId);
44 }
45
46}
Note: See TracBrowser for help on using the repository browser.