Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ohoraming/fe/fix #125

Merged
merged 6 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 내용은 replaceIfNotNull 함수로 교체하였음. 이슈 #113 참조

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