Blame view

src/main/java/fr/plil/sio/web/mvc/UserRestController.java 1.34 KB
d0481dcb   Julien Cartigny   Support for user ...
1
2
  package fr.plil.sio.web.mvc;
  
f9b4ae49   jcartign   Fix recursion in ...
3
  import org.springframework.web.bind.annotation.PathVariable;
d0481dcb   Julien Cartigny   Support for user ...
4
5
6
7
8
9
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  
  import javax.annotation.Resource;
  import java.util.List;
353d9d4f   Zak   désactivation des...
10
  import org.springframework.web.bind.annotation.RequestParam;
d0481dcb   Julien Cartigny   Support for user ...
11
12
13
14
15
16
17
  
  @RestController
  public class UserRestController {
  
      @Resource
      private UserService userService;
  
f9b4ae49   jcartign   Fix recursion in ...
18
      @RequestMapping(value = "/api/users/", method = RequestMethod.GET)
d0481dcb   Julien Cartigny   Support for user ...
19
20
21
      public List<User> listUsers() {
          return userService.findAll();
      }
f9b4ae49   jcartign   Fix recursion in ...
22
23
24
25
26
  
      @RequestMapping(value = "/api/users/{username}/", method = RequestMethod.GET)
      public User listUsers(@PathVariable String username) {
          return userService.findByUsername(username);
      }
353d9d4f   Zak   désactivation des...
27
28
29
30
31
32
33
34
35
36
37
38
  
      @RequestMapping(value = "/api/debts/{username}/", method = RequestMethod.GET)
      public List<Dette> listDettes(@PathVariable String username) {
          return userService.findDettesByUsername(username);
      }
  
      @RequestMapping(value = "/api/addDette/", method = RequestMethod.POST)
      public boolean addDette(@RequestParam(value="username",required=false) String username,@RequestParam(value="sommeDette",required=false) String sommeDette) {
          return userService.addDette(username,sommeDette);
      }
  
  }