Add projection userAllEmbedded to the whoami endpoint
This commit is contained in:
parent
89ba108078
commit
71ee4b9bd9
@ -1,7 +1,7 @@
|
||||
package de.hft.geotime.controllers;
|
||||
|
||||
import de.hft.geotime.entities.TimetrackUser;
|
||||
import de.hft.geotime.entities.projections.UserWithRoleProjection;
|
||||
import de.hft.geotime.entities.projections.UserAllEmbeddedProjection;
|
||||
import de.hft.geotime.repositories.TimetrackUserRepository;
|
||||
import org.springframework.data.projection.ProjectionFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -27,9 +27,9 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/whoami")
|
||||
public UserWithRoleProjection getUsername(Authentication authentication) {
|
||||
public UserAllEmbeddedProjection getUsername(Authentication authentication) {
|
||||
TimetrackUser user = userRepository.findFirstByUsername(authentication.getName());
|
||||
return projectionFactory.createProjection(UserWithRoleProjection.class, user);
|
||||
return projectionFactory.createProjection(UserAllEmbeddedProjection.class, user);
|
||||
}
|
||||
|
||||
@PostMapping("/sign-up")
|
||||
|
@ -0,0 +1,23 @@
|
||||
package de.hft.geotime.entities.projections;
|
||||
|
||||
import de.hft.geotime.entities.Location;
|
||||
import de.hft.geotime.entities.Role;
|
||||
import de.hft.geotime.entities.TimetrackUser;
|
||||
import org.springframework.data.rest.core.config.Projection;
|
||||
|
||||
@Projection(name = "allEmbedded", types = TimetrackUser.class)
|
||||
public interface UserAllEmbeddedProjection {
|
||||
|
||||
long getId();
|
||||
|
||||
String getFirstname();
|
||||
|
||||
String getLastname();
|
||||
|
||||
String getUsername();
|
||||
|
||||
Role getRole();
|
||||
|
||||
Location getLocation();
|
||||
|
||||
}
|
@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.rest.core.config.Projection;
|
||||
|
||||
@Projection(name = "onlyLocation", types = TimetrackUser.class)
|
||||
public interface UserOnlyLocation {
|
||||
public interface UserOnlyLocationProjection {
|
||||
|
||||
@Value("#{target.location.longitude}")
|
||||
double getLongitude();
|
||||
|
Loading…
Reference in New Issue
Block a user