minor formatting work
This commit is contained in:
@@ -17,39 +17,39 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/crud")
|
||||
public class CRUDController {
|
||||
|
||||
@RequestMapping(method=RequestMethod.GET)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public List<CrudInput> read(@RequestBody CrudInput crudInput) {
|
||||
List<CrudInput> returnList=new ArrayList<CrudInput>();
|
||||
returnList.add(crudInput);
|
||||
return returnList;
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@RequestMapping(method=RequestMethod.POST)
|
||||
public HttpHeaders save(@RequestBody CrudInput crudInput) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setLocation(linkTo(CRUDController.class).slash(crudInput.getTitle()).toUri());
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
HttpHeaders delete(@RequestBody CrudInput crudInput) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
void put(@PathVariable("id") long id, @RequestBody CrudInput crudInput) {
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
void patch(@PathVariable("id") long id, @RequestBody CrudInput crudInput) {
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public List<CrudInput> read(@RequestBody CrudInput crudInput) {
|
||||
List<CrudInput> returnList = new ArrayList<CrudInput>();
|
||||
returnList.add(crudInput);
|
||||
return returnList;
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public HttpHeaders save(@RequestBody CrudInput crudInput) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setLocation(linkTo(CRUDController.class).slash(crudInput.getTitle()).toUri());
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
HttpHeaders delete(@RequestBody CrudInput crudInput) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
void put(@PathVariable("id") long id, @RequestBody CrudInput crudInput) {
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
void patch(@PathVariable("id") long id, @RequestBody CrudInput crudInput) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,33 +10,32 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class CrudInput {
|
||||
|
||||
//@NotBlank
|
||||
private final String title;
|
||||
|
||||
private final String body;
|
||||
// @NotBlank
|
||||
private final String title;
|
||||
|
||||
private final List<URI> tagUris;
|
||||
private final String body;
|
||||
|
||||
@JsonCreator
|
||||
public CrudInput(@JsonProperty("title") String title,
|
||||
@JsonProperty("body") String body, @JsonProperty("tags") List<URI> tagUris) {
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
this.tagUris = tagUris == null ? Collections.<URI>emptyList() : tagUris;
|
||||
}
|
||||
private final List<URI> tagUris;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
@JsonCreator
|
||||
public CrudInput(@JsonProperty("title") String title, @JsonProperty("body") String body, @JsonProperty("tags") List<URI> tagUris) {
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
this.tagUris = tagUris == null ? Collections.<URI> emptyList() : tagUris;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@JsonProperty("tags")
|
||||
public List<URI> getTagUris() {
|
||||
return this.tagUris;
|
||||
}
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
@JsonProperty("tags")
|
||||
public List<URI> getTagUris() {
|
||||
return this.tagUris;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.example;
|
||||
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
@@ -12,11 +11,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/")
|
||||
public class IndexController {
|
||||
|
||||
@RequestMapping(method=RequestMethod.GET)
|
||||
public ResourceSupport index() {
|
||||
ResourceSupport index = new ResourceSupport();
|
||||
index.add(linkTo(CRUDController.class).withRel("crud"));
|
||||
return index;
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public ResourceSupport index() {
|
||||
ResourceSupport index = new ResourceSupport();
|
||||
index.add(linkTo(CRUDController.class).withRel("crud"));
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class SpringRestDocsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringRestDocsApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringRestDocsApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user