From 55d925a1d603196dc9512f37b0e93d988e7cdf90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Br=C3=A4u?= Date: Thu, 18 Apr 2019 13:52:06 +0200 Subject: [PATCH] add patch for demonstration purpose --- replace-controllers-by-spring-data-rest.patch | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 replace-controllers-by-spring-data-rest.patch diff --git a/replace-controllers-by-spring-data-rest.patch b/replace-controllers-by-spring-data-rest.patch new file mode 100644 index 0000000..7d65cb4 --- /dev/null +++ b/replace-controllers-by-spring-data-rest.patch @@ -0,0 +1,112 @@ +Index: src/main/kotlin/de/andi95/crudservicespringdata/ConferenceController.kt +=================================================================== +--- src/main/kotlin/de/andi95/crudservicespringdata/ConferenceController.kt (revision 36af50fb7863291098fd45cbd950a80778b8e672) ++++ src/main/kotlin/de/andi95/crudservicespringdata/ConferenceController.kt (revision 36af50fb7863291098fd45cbd950a80778b8e672) +@@ -1,66 +0,0 @@ +-package de.andi95.crudservicespringdata +- +-import org.springframework.beans.factory.annotation.Autowired +-import org.springframework.http.HttpStatus +-import org.springframework.http.ResponseEntity +-import org.springframework.http.ResponseEntity.created +-import org.springframework.http.ResponseEntity.noContent +-import org.springframework.http.ResponseEntity.notFound +-import org.springframework.http.ResponseEntity.ok +-import org.springframework.web.bind.annotation.DeleteMapping +-import org.springframework.web.bind.annotation.GetMapping +-import org.springframework.web.bind.annotation.PathVariable +-import org.springframework.web.bind.annotation.PostMapping +-import org.springframework.web.bind.annotation.PutMapping +-import org.springframework.web.bind.annotation.RequestBody +-import org.springframework.web.bind.annotation.RequestMapping +-import org.springframework.web.bind.annotation.RestController +-import org.springframework.web.servlet.support.ServletUriComponentsBuilder +- +-@RestController +-@RequestMapping("/conferences") +-class ConferenceController(@Autowired val conferenceRepository: ConferenceRepository) { +- +- @PostMapping +- fun `create new element`(@RequestBody conference: Conference) :ResponseEntity { +- val savedConference = conferenceRepository.save(conference) +- val uri = ServletUriComponentsBuilder.fromCurrentRequest() +- .path("/{id}") +- .buildAndExpand(savedConference.id) +- .toUri() +- return created(uri).body(savedConference) +- } +- +- @GetMapping("/{id}") +- fun `read single element`(@PathVariable id: String) :ResponseEntity { +- val conference = conferenceRepository.findById(id) +- return if (conference.isPresent) { +- ok(conference.get()) +- } else notFound().build() +- } +- +- @PutMapping("/{id}") +- fun `update single element`(@PathVariable id: String, @RequestBody conference: Conference) :ResponseEntity { +- val oldConference = conferenceRepository.findById(id) +- val savedConference = conferenceRepository.save(conference) +- return if (oldConference.isPresent) { +- ok(savedConference) +- } else { +- val uri = ServletUriComponentsBuilder.fromCurrentRequest() +- .path("/{id}") +- .buildAndExpand(savedConference.id) +- .toUri() +- created(uri).body(savedConference) +- } +- } +- +- @DeleteMapping("/{id}") +- fun `delete single element`(@PathVariable id: String) :ResponseEntity { +- val conference = conferenceRepository.findById(id) +- return if (conference.isPresent) { +- noContent().build() +- } else notFound().build() +- +- } +- +-} +\ No newline at end of file +Index: src/main/kotlin/de/andi95/crudservicespringdata/Controller.kt +=================================================================== +--- src/main/kotlin/de/andi95/crudservicespringdata/Controller.kt (revision 36af50fb7863291098fd45cbd950a80778b8e672) ++++ src/main/kotlin/de/andi95/crudservicespringdata/Controller.kt (revision 36af50fb7863291098fd45cbd950a80778b8e672) +@@ -1,14 +0,0 @@ +-package de.andi95.crudservicespringdata +- +-import org.springframework.http.ResponseEntity +-import org.springframework.web.bind.annotation.GetMapping +-import org.springframework.web.bind.annotation.RestController +- +-@RestController +-class Controller { +- +- @GetMapping("/") +- fun `return hello world`(): ResponseEntity { +- return ResponseEntity.ok("Hello World!") +- } +-} +\ No newline at end of file +Index: pom.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- pom.xml (revision 36af50fb7863291098fd45cbd950a80778b8e672) ++++ pom.xml (date 1555583271000) +@@ -22,7 +22,11 @@ + + + org.springframework.boot +- spring-boot-starter-web ++ spring-boot-starter-data-rest ++ ++ ++ org.springframework.data ++ spring-data-rest-hal-browser + + + com.fasterxml.jackson.module