Skip to content

Commit 38e8c7d

Browse files
committed
Update productrestcontroller
1 parent cccc7dc commit 38e8c7d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

backend/webandtech/src/main/java/webapp8/webandtech/controller/api/products/ProductsRestController.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public ResponseEntity<Product> registerProduct( @Parameter(description="Object T
8989
if (productService.existsProduct(product.getTitle())) {
9090
return new ResponseEntity<Product>(product,HttpStatus.NOT_ACCEPTABLE);
9191
}
92-
product.setImg0(false);
9392
product.setImg1(false);
9493
product.setImg2(false);
94+
product.setImg3(false);
9595
productService.save(product);
9696
product = productService.getProductByTitle(product.getTitle());
9797
URI location = fromCurrentRequest().path("/{id}").buildAndExpand(product.getIdproduct()).toUri();
@@ -208,15 +208,15 @@ public ResponseEntity<Product> replaceProduct( @Parameter(description="id of Pro
208208
content = @Content
209209
)
210210
})
211-
@GetMapping("/{id}/image0")
211+
@GetMapping("/{id}/image1")
212212
public ResponseEntity<Object> getImage0( @Parameter(description="id of Product to be searched") @PathVariable int id) throws SQLException{
213213
Optional<Product> product = productService.getProductById(id);
214214
if(product.isPresent()) {
215-
if(product.get().getImage0() != null) {
216-
Resource file = new InputStreamResource(product.get().getImage0().getBinaryStream());
215+
if(product.get().getImage1() != null) {
216+
Resource file = new InputStreamResource(product.get().getImage1().getBinaryStream());
217217
return ResponseEntity.ok()
218218
.header(HttpHeaders.CONTENT_TYPE, "image/jpeg")
219-
.contentLength(product.get().getImage0().length())
219+
.contentLength(product.get().getImage1().length())
220220
.body(file);
221221
}else {
222222
return ResponseEntity.noContent().build();
@@ -246,15 +246,15 @@ public ResponseEntity<Object> getImage0( @Parameter(description="id of Product t
246246
content = @Content
247247
)
248248
})
249-
@GetMapping("/{id}/image1")
249+
@GetMapping("/{id}/image2")
250250
public ResponseEntity<Object> getImage1( @Parameter(description="id of Product to be searched") @PathVariable int id) throws SQLException{
251251
Optional<Product> product = productService.getProductById(id);
252252
if(product.isPresent()) {
253-
if(product.get().getImage1() != null) {
254-
Resource file = new InputStreamResource(product.get().getImage1().getBinaryStream());
253+
if(product.get().getImage2() != null) {
254+
Resource file = new InputStreamResource(product.get().getImage2().getBinaryStream());
255255
return ResponseEntity.ok()
256256
.header(HttpHeaders.CONTENT_TYPE, "image/jpeg")
257-
.contentLength(product.get().getImage1().length())
257+
.contentLength(product.get().getImage2().length())
258258
.body(file);
259259
}else {
260260
return ResponseEntity.noContent().build();

0 commit comments

Comments
 (0)