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;
|
95ea306a
Zak
Ajout css, img et...
|
10
11
|
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
|
353d9d4f
Zak
désactivation des...
|
12
|
import org.springframework.web.bind.annotation.RequestParam;
|
d0481dcb
Julien Cartigny
Support for user ...
|
13
14
15
16
17
18
19
|
@RestController
public class UserRestController {
@Resource
private UserService userService;
|
f9b4ae49
jcartign
Fix recursion in ...
|
20
|
@RequestMapping(value = "/api/users/", method = RequestMethod.GET)
|
d0481dcb
Julien Cartigny
Support for user ...
|
21
22
23
|
public List<User> listUsers() {
return userService.findAll();
}
|
f9b4ae49
jcartign
Fix recursion in ...
|
24
|
|
95ea306a
Zak
Ajout css, img et...
|
25
26
27
28
29
30
31
|
@RequestMapping(value="/api/connectedUser/",method=RequestMethod.GET)
public User connectedUser() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User usr = (User)authentication.getPrincipal();
return usr;
}
|
f9b4ae49
jcartign
Fix recursion in ...
|
32
33
34
35
|
@RequestMapping(value = "/api/users/{username}/", method = RequestMethod.GET)
public User listUsers(@PathVariable String username) {
return userService.findByUsername(username);
}
|
353d9d4f
Zak
désactivation des...
|
36
|
|
716532ee
Zak
Modifications des...
|
37
38
39
|
@RequestMapping(value = "/api/debts/", method = RequestMethod.GET)
public List<Dette> listDettes() {
return userService.findDettes();
|
353d9d4f
Zak
désactivation des...
|
40
41
|
}
|
95ea306a
Zak
Ajout css, img et...
|
42
43
44
45
46
|
@RequestMapping(value = "/api/creances/", method = RequestMethod.GET)
public List<Dette> listCreances(){
return userService.findCreances();
}
|
353d9d4f
Zak
désactivation des...
|
47
|
@RequestMapping(value = "/api/addDette/", method = RequestMethod.POST)
|
716532ee
Zak
Modifications des...
|
48
|
public Dette addDette(@RequestParam(value="username",required=false) String username,@RequestParam(value="sommeDette",required=false) String sommeDette) {
|
353d9d4f
Zak
désactivation des...
|
49
50
|
return userService.addDette(username,sommeDette);
}
|
8a362652
Zak
Ajout css, js et ...
|
51
52
53
54
55
56
|
@RequestMapping(value="/api/deleteDette/{id}",method=RequestMethod.DELETE)
public String deleteDette(@PathVariable("id") String id){
return userService.deleteDette(id);
}
|
353d9d4f
Zak
désactivation des...
|
57
58
|
}
|