Merge branch '50-create-record-rest-controller' into 'master'

Resolve "Create record rest controller"

Closes #50

See merge request marcel.schwarz/2020ss-qbc-geofence-timetracking!58
This commit is contained in:
Marcel Schwarz 2020-05-19 09:33:50 +00:00
commit 04d4d9563b
2 changed files with 14 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import de.hft.geotime.entities.TimetrackUser;
import de.hft.geotime.entities.projections.UserAllEmbeddedProjection; import de.hft.geotime.entities.projections.UserAllEmbeddedProjection;
import de.hft.geotime.repositories.TimetrackUserRepository; import de.hft.geotime.repositories.TimetrackUserRepository;
import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.rest.webmvc.BasePathAwareController;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication; 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.GetMapping;
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.RestController; import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap; import java.util.HashMap;
@RestController @BasePathAwareController
@ResponseBody
public class UserController { public class UserController {
private final TimetrackUserRepository userRepository; private final TimetrackUserRepository userRepository;

View File

@ -2,7 +2,16 @@ package de.hft.geotime.repositories;
import de.hft.geotime.entities.TimeRecord; import de.hft.geotime.entities.TimeRecord;
import org.springframework.data.repository.CrudRepository; 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<TimeRecord, Long> { import java.util.List;
@RepositoryRestResource(
path = "records",
itemResourceRel = "records",
collectionResourceRel = "records"
)
public interface RecordRepository extends PagingAndSortingRepository<TimeRecord, Long> {
} }