@@ -21,6 +21,7 @@ $output.require("java.math.BigInteger")##
2121$output.require("java.util.Date")##
2222#end
2323$output.require($entity.dto)##
24+ $output.require($entity.model)##
2425$output.require($entity.root.primaryKey)##
2526#foreach($enumAttribute in $entity.uniqueEnumAttributes.list)
2627$output.require($enumAttribute)##
@@ -42,9 +43,14 @@ $output.require("javax.inject.Inject")##
4243$output.require("org.slf4j.LoggerFactory")##
4344$output.require("org.slf4j.Logger")##
4445
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")##
4550$output.require("org.springframework.web.bind.annotation.*")##
46-
51+ $output.requireStatic("org.springframework.http.MediaType.APPLICATION_JSON_VALUE")##
4752$output.require("org.springframework.http.ResponseEntity")##
53+ $output.require("org.springframework.web.bind.annotation.RequestBody")##
4854$output.require("org.springframework.http.HttpHeaders")##
4955$output.require("org.springframework.http.HttpStatus")##
5056
@@ -53,7 +59,7 @@ $output.require("org.springframework.http.HttpStatus")##
5359@RequestMapping("/api/${entity.model.vars}")
5460public class $output.currentClass{
5561
56- private final Logger log = LoggerFactory.getLogger(getClass() );
62+ private final Logger log = LoggerFactory.getLogger(${output.currentClass}.class );
5763
5864 @Inject
5965 private $entity.repository.type $entity.repository.var;
@@ -83,7 +89,7 @@ $output.require("java.beans.PropertyEditorSupport")##
8389 /**
8490 * Create a new ${entity.model.type}.
8591 */
86- @PostMapping
92+ @RequestMapping(value = "/", method = POST, produces = APPLICATION_JSON_VALUE)
8793 public ResponseEntity<$entity.dto.type> create(@RequestBody $entity.dto.type $entity.dto.var) throws URISyntaxException {
8894
8995 log.debug("Create $entity.dto.type : {}", $entity.dto.var);
@@ -102,8 +108,8 @@ $output.require("java.beans.PropertyEditorSupport")##
102108 /**
103109 * Find by id ${entity.model.type}.
104110 */
105- @GetMapping(" {id}")
106- public ResponseEntity<$entity.dto.type> findById(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) {
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 {
107113
108114 log.debug("Find by id $entity.model.type : {}", $entity.root.primaryKey.var);
109115
@@ -115,7 +121,7 @@ $output.require("java.beans.PropertyEditorSupport")##
115121 /**
116122 * Update ${entity.model.type}.
117123 */
118- @PutMapping
124+ @RequestMapping(value = "/", method = PUT, produces = APPLICATION_JSON_VALUE)
119125 public ResponseEntity<$entity.dto.type> update(@RequestBody $entity.dto.type $entity.dto.var) throws URISyntaxException {
120126
121127 log.debug("Update $entity.dto.type : {}", $entity.dto.var);
@@ -136,7 +142,7 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
136142 /**
137143 * Target url for ${attribute.var} file upload.
138144 */
139- @PostMapping( "/{id}/upload/${attribute.var}")
145+ @RequestMapping(value = "/{id}/upload/${attribute.var}", method = POST, produces = APPLICATION_JSON_VALUE )
140146 public ResponseEntity<Void> ${attribute.var}FileUpload(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var, @RequestParam("$attribute.var") MultipartFile multipartFile) {
141147
142148 log.debug("File Upload: {}", multipartFile.getName());
@@ -169,7 +175,8 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
169175 /**
170176 * File download facility for ${attribute.var}.
171177 */
172- @GetMapping("/{id}/download/${attribute.var}")
178+ @RequestMapping(value = "/{id}/download/${attribute.var}", method = GET)
179+ @ResponseBody
173180 public ResponseEntity<byte[]> ${attribute.var}FileDownload(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) {
174181
175182 $entity.model.type $entity.model.var = ${entity.repository.var}.findOne($entity.root.primaryKey.var);
@@ -196,17 +203,17 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
196203 /**
197204 * Find a Page of $entity.model.type using query by example.
198205 */
199- @PostMapping(" page")
200- public ResponseEntity<PageResponse<$entity.dto.type>> findAll(@RequestBody PageRequestByExample<$entity.dto.type> prbe) {
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 {
201208 PageResponse<$entity.dto.type> pageResponse = ${entity.dtoservice.var}.findAll(prbe);
202209 return new ResponseEntity<>(pageResponse, new HttpHeaders(), HttpStatus.OK);
203210 }
204211
205212 /**
206213 * Auto complete support.
207214 */
208- @PostMapping(" complete")
209- public ResponseEntity<List<$entity.dto.type>> complete(@RequestBody AutoCompleteQuery acq) {
215+ @RequestMapping(value = "/ complete", method = POST, produces = APPLICATION_JSON_VALUE )
216+ public ResponseEntity<List<$entity.dto.type>> complete(@RequestBody AutoCompleteQuery acq) throws URISyntaxException {
210217
211218 List<$entity.dto.type> results = ${entity.dtoservice.var}.complete(acq.query, acq.maxResults);
212219
@@ -216,8 +223,8 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
216223 /**
217224 * Delete by id ${entity.model.type}.
218225 */
219- @DeleteMapping(" {id}")
220- public ResponseEntity<Void> delete(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) {
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 {
221228
222229 log.debug("Delete by id $entity.model.type : {}", $entity.root.primaryKey.var);
223230
0 commit comments