Skip to content

Commit

Permalink
Merge pull request #125 from ohoraming/ohoraming/FE/FIX
Browse files Browse the repository at this point in the history
Ohoraming/fe/fix
  • Loading branch information
kkn1125 authored Aug 9, 2022
2 parents a66e690 + 6ab5dab commit acb3af3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/frontend/src/apis/cart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const findCartById = (cid: string) => {

const deleteCart = (cid: string) => {
return axios
.get(`/api/cart/${cid}`)
.delete(`/api/cart/${cid}`)
.then(handleReceiveData)
.catch(handleReceiveError);
};
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/src/apis/product/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const findProductById = (pid: string) => {

const deleteProduct = (pid: string) => {
return axios
.get(`/api/product/${pid}`)
.delete(`/api/product/${pid}`)
.then(handleReceiveData)
.catch(handleReceiveError);
};
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/narang/web/entity/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@ public class Product {

@LastModifiedDate
private LocalDateTime updates;

public Product replace(Product compare) {
this.setCategory(compare.getCategory() != null ? compare.getCategory() : this.getCategory());
this.setName(compare.getName() != null ? compare.getName() : this.getName());
this.setPrice(compare.getPrice() != null ? compare.getPrice() : this.getPrice());
this.setAmount(compare.getAmount() != null ? compare.getAmount() : this.getAmount());
this.setContent(compare.getContent() != null ? compare.getContent() : this.getContent());
this.setSeller(compare.getSeller() != null ? compare.getSeller() : this.getSeller());
this.setIsSoldOut(compare.getIsSoldOut() == true ? compare.getIsSoldOut() : this.getIsSoldOut());
return this;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ public ResponseEntity<?> updateProduct(@PathVariable("pid") String id, @RequestB
Optional<Product> productOptional = productRepository.findById(id);
if (productOptional.isPresent()) {
Product productToSave = productOptional.get();
productToSave.setCategory(product.getCategory() != null ? product.getCategory() : productToSave.getCategory());
productToSave.setName(product.getName() != null ? product.getName() : productToSave.getName());
productToSave.setPrice(product.getPrice() != null ? product.getPrice() : productToSave.getPrice());
productToSave.setAmount(product.getAmount() != null ? product.getAmount() : productToSave.getAmount());
productToSave.setContent(product.getContent() != null ? product.getContent() : productToSave.getContent());
productToSave.setSeller(product.getSeller() != null ? product.getSeller() : productToSave.getSeller());
productToSave.setIsSoldOut(product.getIsSoldOut() == true ? product.getIsSoldOut() : productToSave.getIsSoldOut());
productToSave.replace(product);
productRepository.save(productToSave);
return new ResponseEntity<>(productToSave, HttpStatus.OK);
} else {
Expand Down

0 comments on commit acb3af3

Please sign in to comment.