Commit d0481dcb391a11aa2720ea98c9b367ff71f12499

Authored by Julien Cartigny
1 parent a8656157

Support for user REST controller

src/main/java/fr/plil/sio/web/mvc/UserRestController.java 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +package fr.plil.sio.web.mvc;
  2 +
  3 +import org.springframework.web.bind.annotation.RequestMapping;
  4 +import org.springframework.web.bind.annotation.RequestMethod;
  5 +import org.springframework.web.bind.annotation.RestController;
  6 +
  7 +import javax.annotation.Resource;
  8 +import java.util.List;
  9 +
  10 +@RestController
  11 +public class UserRestController {
  12 +
  13 + @Resource
  14 + private UserService userService;
  15 +
  16 + @RequestMapping(value = "/users/", method = RequestMethod.GET)
  17 + public List<User> listUsers() {
  18 + return userService.findAll();
  19 + }
  20 +}
0 21 \ No newline at end of file
... ...
src/main/java/fr/plil/sio/web/mvc/UserService.java
1 1 package fr.plil.sio.web.mvc;
2 2  
  3 +import java.util.List;
  4 +
3 5 public interface UserService {
4 6  
5 7 User createUser(String username, String password);
6 8  
7 9 User findByUsername(String username);
  10 +
  11 + List<User> findAll();
8 12 }
... ...
src/main/java/fr/plil/sio/web/mvc/UserServiceImpl.java
... ... @@ -6,6 +6,7 @@ import org.springframework.transaction.annotation.Transactional;
6 6  
7 7 import javax.annotation.Resource;
8 8 import java.util.HashSet;
  9 +import java.util.List;
9 10 import java.util.Set;
10 11  
11 12 @Service("userService")
... ... @@ -37,4 +38,9 @@ public class UserServiceImpl implements UserService {
37 38 public User findByUsername(String username) {
38 39 return userRepository.findByUsername(username);
39 40 }
  41 +
  42 + @Override
  43 + public List<User> findAll() {
  44 + return userRepository.findAll();
  45 + }
40 46 }
... ...