WIP
This commit is contained in:
parent
7ae7522359
commit
92e93c80e8
1 changed files with 8 additions and 2 deletions
|
@ -4,8 +4,8 @@ import static ch.usi.inf.sa4.sanmarinoes.smarthut.utils.Utils.toList;
|
||||||
|
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.GuestPermissionsRequest;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.GuestPermissionsRequest;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException;
|
||||||
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.EagerUserRepository;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.UserRepository;
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
@ -18,13 +18,19 @@ import org.springframework.web.bind.annotation.*;
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
public class GuestController {
|
public class GuestController {
|
||||||
|
|
||||||
@Autowired private UserRepository userRepository;
|
@Autowired private EagerUserRepository userRepository;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public List<User> findAll() {
|
public List<User> findAll() {
|
||||||
return toList(userRepository.findAll());
|
return toList(userRepository.findAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/hosts")
|
||||||
|
public List<User> findHosts(final Principal principal) {
|
||||||
|
final User u = userRepository.findByUsername(principal.getName());
|
||||||
|
return toList(u.getHosts());
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/guest")
|
@PostMapping("/guest")
|
||||||
public User addUserAsGuest(@RequestParam("userId") long id, final Principal principal)
|
public User addUserAsGuest(@RequestParam("userId") long id, final Principal principal)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
|
|
Loading…
Reference in a new issue