Skip to content
Snippets Groups Projects
Commit 9a77c9aa authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Add /user/{id}/roomHistory endpoint for adding new entries

parent c4b87459
Branches
No related merge requests found
...@@ -2,7 +2,9 @@ package de.thm.arsnova.controller; ...@@ -2,7 +2,9 @@ package de.thm.arsnova.controller;
import de.thm.arsnova.entities.LoginCredentials; import de.thm.arsnova.entities.LoginCredentials;
import de.thm.arsnova.entities.UserProfile; import de.thm.arsnova.entities.UserProfile;
import de.thm.arsnova.services.RoomService;
import de.thm.arsnova.services.UserService; import de.thm.arsnova.services.UserService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -12,12 +14,15 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -12,12 +14,15 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(UserController.REQUEST_MAPPING) @RequestMapping(UserController.REQUEST_MAPPING)
public class UserController extends AbstractEntityController<UserProfile> { public class UserController extends AbstractEntityController<UserProfile> {
protected static final String REQUEST_MAPPING = "/user"; protected static final String REQUEST_MAPPING = "/user";
private static final String ROOM_HISTORY_MAPPING = DEFAULT_ID_MAPPING + "/roomHistory";
private UserService userService; private UserService userService;
private RoomService roomService;
public UserController(final UserService userService) { public UserController(final UserService userService, final RoomService roomService) {
super(userService); super(userService);
this.userService = userService; this.userService = userService;
this.roomService = roomService;
} }
@Override @Override
...@@ -29,4 +34,10 @@ public class UserController extends AbstractEntityController<UserProfile> { ...@@ -29,4 +34,10 @@ public class UserController extends AbstractEntityController<UserProfile> {
public void register(@RequestBody LoginCredentials loginCredentials) { public void register(@RequestBody LoginCredentials loginCredentials) {
userService.create(loginCredentials.getLoginId(), loginCredentials.getPassword()); userService.create(loginCredentials.getLoginId(), loginCredentials.getPassword());
} }
@PostMapping(ROOM_HISTORY_MAPPING)
public void postRoomHistoryEntry(@PathVariable final String id,
@RequestBody final UserProfile.RoomHistoryEntry roomHistoryEntry) {
userService.addRoomToHistory(userService.get(id), roomService.get(roomHistoryEntry.getRoomId()));
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment