@@ -21,6 +21,7 @@ $output.require("java.math.BigInteger")##
21
21
$output.require("java.util.Date")##
22
22
#end
23
23
$output.require($entity.dto)##
24
+ $output.require($entity.model)##
24
25
$output.require($entity.root.primaryKey)##
25
26
#foreach($enumAttribute in $entity.uniqueEnumAttributes.list)
26
27
$output.require($enumAttribute)##
@@ -42,9 +43,14 @@ $output.require("javax.inject.Inject")##
42
43
$output.require("org.slf4j.LoggerFactory")##
43
44
$output.require("org.slf4j.Logger")##
44
45
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")##
45
50
$output.require("org.springframework.web.bind.annotation.*")##
46
-
51
+ $output.requireStatic("org.springframework.http.MediaType.APPLICATION_JSON_VALUE")##
47
52
$output.require("org.springframework.http.ResponseEntity")##
53
+ $output.require("org.springframework.web.bind.annotation.RequestBody")##
48
54
$output.require("org.springframework.http.HttpHeaders")##
49
55
$output.require("org.springframework.http.HttpStatus")##
50
56
@@ -53,7 +59,7 @@ $output.require("org.springframework.http.HttpStatus")##
53
59
@RequestMapping("/api/${entity.model.vars}")
54
60
public class $output.currentClass{
55
61
56
- private final Logger log = LoggerFactory.getLogger(getClass() );
62
+ private final Logger log = LoggerFactory.getLogger(${output.currentClass}.class );
57
63
58
64
@Inject
59
65
private $entity.repository.type $entity.repository.var;
@@ -83,7 +89,7 @@ $output.require("java.beans.PropertyEditorSupport")##
83
89
/**
84
90
* Create a new ${entity.model.type}.
85
91
*/
86
- @PostMapping
92
+ @RequestMapping(value = "/", method = POST, produces = APPLICATION_JSON_VALUE)
87
93
public ResponseEntity<$entity.dto.type> create(@RequestBody $entity.dto.type $entity.dto.var) throws URISyntaxException {
88
94
89
95
log.debug("Create $entity.dto.type : {}", $entity.dto.var);
@@ -102,8 +108,8 @@ $output.require("java.beans.PropertyEditorSupport")##
102
108
/**
103
109
* Find by id ${entity.model.type}.
104
110
*/
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 {
107
113
108
114
log.debug("Find by id $entity.model.type : {}", $entity.root.primaryKey.var);
109
115
@@ -115,7 +121,7 @@ $output.require("java.beans.PropertyEditorSupport")##
115
121
/**
116
122
* Update ${entity.model.type}.
117
123
*/
118
- @PutMapping
124
+ @RequestMapping(value = "/", method = PUT, produces = APPLICATION_JSON_VALUE)
119
125
public ResponseEntity<$entity.dto.type> update(@RequestBody $entity.dto.type $entity.dto.var) throws URISyntaxException {
120
126
121
127
log.debug("Update $entity.dto.type : {}", $entity.dto.var);
@@ -136,7 +142,7 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
136
142
/**
137
143
* Target url for ${attribute.var} file upload.
138
144
*/
139
- @PostMapping( "/{id}/upload/${attribute.var}")
145
+ @RequestMapping(value = "/{id}/upload/${attribute.var}", method = POST, produces = APPLICATION_JSON_VALUE )
140
146
public ResponseEntity<Void> ${attribute.var}FileUpload(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var, @RequestParam("$attribute.var") MultipartFile multipartFile) {
141
147
142
148
log.debug("File Upload: {}", multipartFile.getName());
@@ -169,7 +175,8 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
169
175
/**
170
176
* File download facility for ${attribute.var}.
171
177
*/
172
- @GetMapping("/{id}/download/${attribute.var}")
178
+ @RequestMapping(value = "/{id}/download/${attribute.var}", method = GET)
179
+ @ResponseBody
173
180
public ResponseEntity<byte[]> ${attribute.var}FileDownload(@PathVariable $entity.root.primaryKey.type $entity.root.primaryKey.var) {
174
181
175
182
$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")##
196
203
/**
197
204
* Find a Page of $entity.model.type using query by example.
198
205
*/
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 {
201
208
PageResponse<$entity.dto.type> pageResponse = ${entity.dtoservice.var}.findAll(prbe);
202
209
return new ResponseEntity<>(pageResponse, new HttpHeaders(), HttpStatus.OK);
203
210
}
204
211
205
212
/**
206
213
* Auto complete support.
207
214
*/
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 {
210
217
211
218
List<$entity.dto.type> results = ${entity.dtoservice.var}.complete(acq.query, acq.maxResults);
212
219
@@ -216,8 +223,8 @@ $output.require("org.springframework.web.bind.annotation.RequestParam")##
216
223
/**
217
224
* Delete by id ${entity.model.type}.
218
225
*/
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 {
221
228
222
229
log.debug("Delete by id $entity.model.type : {}", $entity.root.primaryKey.var);
223
230
0 commit comments