From 0f700d87b013a9d79fd6a483c7a95d07decd1c78 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Tue, 19 May 2020 10:35:14 +0200 Subject: [PATCH 1/2] Adjust records endpoint name and rels, enable paging --- .../de/hft/geotime/repositories/RecordRepository.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/de/hft/geotime/repositories/RecordRepository.java b/backend/src/main/java/de/hft/geotime/repositories/RecordRepository.java index b185c6f..765b6e9 100644 --- a/backend/src/main/java/de/hft/geotime/repositories/RecordRepository.java +++ b/backend/src/main/java/de/hft/geotime/repositories/RecordRepository.java @@ -2,7 +2,16 @@ package de.hft.geotime.repositories; import de.hft.geotime.entities.TimeRecord; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; -public interface RecordRepository extends CrudRepository { +import java.util.List; + +@RepositoryRestResource( + path = "records", + itemResourceRel = "records", + collectionResourceRel = "records" +) +public interface RecordRepository extends PagingAndSortingRepository { } From 24b6ff4618e8fe2977ce47e688cc8347f4d0e735 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Tue, 19 May 2020 10:50:33 +0200 Subject: [PATCH 2/2] Make UserController a BasePathAwareController --- .../java/de/hft/geotime/controllers/UserController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/de/hft/geotime/controllers/UserController.java b/backend/src/main/java/de/hft/geotime/controllers/UserController.java index e5acae4..5f63c4f 100644 --- a/backend/src/main/java/de/hft/geotime/controllers/UserController.java +++ b/backend/src/main/java/de/hft/geotime/controllers/UserController.java @@ -4,6 +4,7 @@ import de.hft.geotime.entities.TimetrackUser; import de.hft.geotime.entities.projections.UserAllEmbeddedProjection; import de.hft.geotime.repositories.TimetrackUserRepository; import org.springframework.data.projection.ProjectionFactory; +import org.springframework.data.rest.webmvc.BasePathAwareController; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; @@ -11,11 +12,12 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.ResponseBody; import java.util.HashMap; -@RestController +@BasePathAwareController +@ResponseBody public class UserController { private final TimetrackUserRepository userRepository;