@@ -21,7 +21,6 @@ $output.require("java.math.BigInteger")##
2121$output.require("java.util.Date")##
2222#end
2323$output.require($entity.dto)##
24- $output.require($entity.model)##
2524$output.require($entity.root.primaryKey)##
2625#foreach($enumAttribute in $entity.uniqueEnumAttributes.list)
2726$output.require($enumAttribute)##
@@ -43,14 +42,9 @@ $output.require("javax.inject.Inject")##
4342$output.require("org.slf4j.LoggerFactory")##
4443$output.require("org.slf4j.Logger")##
4544
46- $output.requireStatic("org.springframework.web.bind.annotation.RequestMethod.GET")##
47- $output.requireStatic("org.springframework.web.bind.annotation.RequestMethod.POST")##
48- $output.requireStatic("org.springframework.web.bind.annotation.RequestMethod.PUT")##
49- $output.requireStatic("org.springframework.web.bind.annotation.RequestMethod.DELETE")##
5045$output.require("org.springframework.web.bind.annotation.*")##
51- $output.requireStatic("org.springframework.http.MediaType.APPLICATION_JSON_VALUE")##
46+
5247$output.require("org.springframework.http.ResponseEntity")##
53- $output.require("org.springframework.web.bind.annotation.RequestBody")##
5448$output.require("org.springframework.http.HttpHeaders")##
5549$output.require("org.springframework.http.HttpStatus")##
5650
@@ -59,7 +53,7 @@ $output.require("org.springframework.http.HttpStatus")##
5953@RequestMapping("/api/${entity.model.vars}")
6054public class $output.currentClass{
6155
62- private final Logger log = LoggerFactory.getLogger(${output.currentClass}.class );
56+ private final Logger log = LoggerFactory.getLogger(getClass() );
6357
6458 @Inject
6559 private $entity.repository.type $entity.repository.var;
@@ -89,7 +83,7 @@ $output.require("java.beans.PropertyEditorSupport")##
8983 /**
9084 * Create a new ${entity.model.type}.
9185 */
92- @RequestMapping(value = "/", method = POST, produces = APPLICATION_JSON_VALUE)
86+ @PostMapping
9387 public ResponseEntity<$entity.dto.type> create(@RequestBody $entity.dto.type $entity.dto.var) throws URISyntaxException {
9488
9589 log.debug("Create $entity.dto.type : {}", $entity.dto.var);
@@ -108,8 +102,8 @@ $output.require("java.beans.PropertyEditorSupport")##
108102 /**
109103 * Find by id ${entity.model.type}.
110104 */
111- @RequestMapping(value = "/ {id}", method = GET, produces = APPLICATION_JSON_VALUE )
112- public ResponseEntity<$entity.dto.type> findById(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) throws URISyntaxException {
105+ @GetMapping(" {id}")
106+ public ResponseEntity<$entity.dto.type> findById(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) {
113107
114108 log.debug("Find by id $entity.model.type : {}", $entity.root.primaryKey.var);
115109
@@ -121,7 +115,7 @@ $output.require("java.beans.PropertyEditorSupport")##
121115 /**
122116 * Update ${entity.model.type}.
123117 */
124- @RequestMapping(value = "/", method = PUT, produces = APPLICATION_JSON_VALUE)
118+ @PutMapping
125119 public ResponseEntity<$entity.dto.type> update(@RequestBody $entity.dto.type $entity.dto.var) throws URISyntaxException {
126120
127121 log.debug("Update $entity.dto.type : {}", $entity.dto.var);
@@ -142,7 +136,7 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
142136 /**
143137 * Target url for ${attribute.var} file upload.
144138 */
145- @RequestMapping(value = "/{id}/upload/${attribute.var}", method = POST, produces = APPLICATION_JSON_VALUE )
139+ @PostMapping( "/{id}/upload/${attribute.var}")
146140 public ResponseEntity<Void> ${attribute.var}FileUpload(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var, @RequestParam("$attribute.var") MultipartFile multipartFile) {
147141
148142 log.debug("File Upload: {}", multipartFile.getName());
@@ -175,8 +169,7 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
175169 /**
176170 * File download facility for ${attribute.var}.
177171 */
178- @RequestMapping(value = "/{id}/download/${attribute.var}", method = GET)
179- @ResponseBody
172+ @GetMapping("/{id}/download/${attribute.var}")
180173 public ResponseEntity<byte[]> ${attribute.var}FileDownload(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) {
181174
182175 $entity.model.type $entity.model.var = ${entity.repository.var}.findOne($entity.root.primaryKey.var);
@@ -203,17 +196,17 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
203196 /**
204197 * Find a Page of $entity.model.type using query by example.
205198 */
206- @RequestMapping(value = "/ page", method = POST, produces = APPLICATION_JSON_VALUE )
207- public ResponseEntity<PageResponse<$entity.dto.type>> findAll(@RequestBody PageRequestByExample<$entity.dto.type> prbe) throws URISyntaxException {
199+ @PostMapping(" page")
200+ public ResponseEntity<PageResponse<$entity.dto.type>> findAll(@RequestBody PageRequestByExample<$entity.dto.type> prbe) {
208201 PageResponse<$entity.dto.type> pageResponse = ${entity.dtoservice.var}.findAll(prbe);
209202 return new ResponseEntity<>(pageResponse, new HttpHeaders(), HttpStatus.OK);
210203 }
211204
212205 /**
213206 * Auto complete support.
214207 */
215- @RequestMapping(value = "/ complete", method = POST, produces = APPLICATION_JSON_VALUE )
216- public ResponseEntity<List<$entity.dto.type>> complete(@RequestBody AutoCompleteQuery acq) throws URISyntaxException {
208+ @PostMapping(" complete")
209+ public ResponseEntity<List<$entity.dto.type>> complete(@RequestBody AutoCompleteQuery acq) {
217210
218211 List<$entity.dto.type> results = ${entity.dtoservice.var}.complete(acq.query, acq.maxResults);
219212
@@ -223,8 +216,8 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
223216 /**
224217 * Delete by id ${entity.model.type}.
225218 */
226- @RequestMapping(value = "/ {id}", method = DELETE, produces = APPLICATION_JSON_VALUE )
227- public ResponseEntity<Void> delete(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) throws URISyntaxException {
219+ @DeleteMapping(" {id}")
220+ public ResponseEntity<Void> delete(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) {
228221
229222 log.debug("Delete by id $entity.model.type : {}", $entity.root.primaryKey.var);
230223
0 commit comments