|
32 | 32 | import org.springframework.web.multipart.MultipartFile;
|
33 | 33 | import org.springframework.web.util.UriComponentsBuilder;
|
34 | 34 |
|
| 35 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
35 | 36 | import com.pier.business.validation.ProductIntegrityChecker;
|
36 | 37 | import com.pier.rest.model.Flavor;
|
37 | 38 | import com.pier.rest.model.Product;
|
@@ -175,10 +176,10 @@ public ResponseEntity<?> updateProduct(@PathVariable Long id, @RequestBody Produ
|
175 | 176 |
|
176 | 177 | @PreAuthorize("hasRole('ADMIN')")
|
177 | 178 | @RequestMapping(value="setprice/{id}",method=RequestMethod.PUT)
|
178 |
| - public ResponseEntity<?> updatePrice(@PathVariable Long id, @RequestBody String price){ |
| 179 | + public ResponseEntity<?> updatePrice(@PathVariable Long id, @RequestBody ObjectNode json){ |
179 | 180 | Product product=this.dao.find(id);
|
180 | 181 | try{
|
181 |
| - |
| 182 | + String price=json.get("price").textValue(); |
182 | 183 | product.setPrice(new BigDecimal(price));
|
183 | 184 | dao.update(product);
|
184 | 185 | }catch(NullPointerException e){
|
@@ -217,7 +218,7 @@ public ResponseEntity<?> handleFileUpload( @RequestPart("file") MultipartFile fi
|
217 | 218 | String filePath = uploadsDir + name;
|
218 | 219 | File destination = new File(filePath);
|
219 | 220 | file.transferTo(destination);
|
220 |
| - return new ResponseEntity<String>("success",HttpStatus.NO_CONTENT); |
| 221 | + return new ResponseEntity<String>(""+id,HttpStatus.OK); |
221 | 222 | } catch (Exception e) {
|
222 | 223 |
|
223 | 224 | return new ResponseEntity<String>(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
0 commit comments