latest
This commit is contained in:
10
bookstore-api/.idea/workspace.xml
generated
10
bookstore-api/.idea/workspace.xml
generated
@@ -152,7 +152,7 @@
|
|||||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
|
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="563">
|
<state relative-caret-position="563">
|
||||||
<caret line="83" column="0" lean-forward="true" selection-start-line="83" selection-start-column="0" selection-end-line="83" selection-end-column="0" />
|
<caret line="104" column="60" lean-forward="false" selection-start-line="104" selection-start-column="60" selection-end-line="104" selection-end-column="60" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="imports" expanded="true" />
|
<element signature="imports" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@@ -1038,12 +1038,12 @@
|
|||||||
<workItem from="1488378219247" duration="650000" />
|
<workItem from="1488378219247" duration="650000" />
|
||||||
<workItem from="1488461561430" duration="18419000" />
|
<workItem from="1488461561430" duration="18419000" />
|
||||||
<workItem from="1488731165185" duration="30270000" />
|
<workItem from="1488731165185" duration="30270000" />
|
||||||
<workItem from="1489159532831" duration="1705000" />
|
<workItem from="1489159532831" duration="2499000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TimeTrackingManager">
|
<component name="TimeTrackingManager">
|
||||||
<option name="totallyTimeSpent" value="93987000" />
|
<option name="totallyTimeSpent" value="94781000" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="72" y="23" width="1280" height="797" extended-state="0" />
|
<frame x="72" y="23" width="1280" height="797" extended-state="0" />
|
||||||
@@ -1067,7 +1067,7 @@
|
|||||||
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32907802" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
|
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32907802" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32624114" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32624114" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Spring" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32907802" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
|
<window_info id="Spring" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32907802" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
|
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
|
||||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32229403" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32229403" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||||
@@ -1556,7 +1556,7 @@
|
|||||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
|
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="563">
|
<state relative-caret-position="563">
|
||||||
<caret line="83" column="0" lean-forward="true" selection-start-line="83" selection-start-column="0" selection-end-line="83" selection-end-column="0" />
|
<caret line="104" column="60" lean-forward="false" selection-start-line="104" selection-start-column="60" selection-end-line="104" selection-end-column="60" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="imports" expanded="true" />
|
<element signature="imports" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -84,4 +81,28 @@ public class ShoppingCartResource {
|
|||||||
|
|
||||||
return shoppingCart;
|
return shoppingCart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/removeItem")
|
||||||
|
public ResponseEntity removeItem(@RequestBody String id) {
|
||||||
|
cartItemService.removeCartItem(cartItemService.findById(Long.parseLong(id)));
|
||||||
|
|
||||||
|
return new ResponseEntity("Cart Item Removed Successfully!", HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/updateCartItem")
|
||||||
|
public ResponseEntity updateShoppingCart(
|
||||||
|
@RequestBody HashMap<String, String> mapper
|
||||||
|
) {
|
||||||
|
String cartItemId = mapper.get("cartItemId");
|
||||||
|
String qty = mapper.get("qty");
|
||||||
|
|
||||||
|
CartItem cartItem = cartItemService.findById(Long.parseLong(cartItemId));
|
||||||
|
cartItem.setQty(Integer.parseInt(qty));
|
||||||
|
|
||||||
|
cartItemService.updateCartItem(cartItem);
|
||||||
|
|
||||||
|
return new ResponseEntity("Cart Updated Successfully!", HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -39,16 +39,16 @@
|
|||||||
<form (ngSubmit)="onSubmit()" method="post">
|
<form (ngSubmit)="onSubmit()" method="post">
|
||||||
<hr/>
|
<hr/>
|
||||||
<div class="col-xs-2">
|
<div class="col-xs-2">
|
||||||
<a (click)="onSelect(cartItem.book)"><img class="img-responsive shelf-book" src="{{serverPath}}/image/book/{{cartItem.book.id}}.png" style="width:70px;" /></a>
|
<a md-button (click)="onSelect(cartItem.book)"><img class="img-responsive shelf-book" src="{{serverPath}}/image/book/{{cartItem.book.id}}.png" style="width:70px;" /></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<a (click)="onSelect(cartItem.book)"><h4>
|
<a class="pointer" (click)="onSelect(cartItem.book)"><h4>
|
||||||
{{cartItem.book.title}}</h4></a>
|
{{cartItem.book.title}}</h4></a>
|
||||||
<p *ngIf="cartItem.book.inStockNumber > 10" style="color: green;">In Stock</p>
|
<p *ngIf="cartItem.book.inStockNumber > 10" style="color: green;">In Stock</p>
|
||||||
<p *ngIf="cartItem.book.inStockNumber < 10 && cartItem.book.inStockNumber > 0" style="color: green;"> Only <span>{{cartItem.book.inStockNumber}}</span> In Stock
|
<p *ngIf="cartItem.book.inStockNumber < 10 && cartItem.book.inStockNumber > 0" style="color: green;"> Only <span>{{cartItem.book.inStockNumber}}</span> In Stock
|
||||||
</p>
|
</p>
|
||||||
<p style="color: darkred;" *ngIf="cartItem.book.inStockNumber==0">Product Unavailable</p>
|
<p style="color: darkred;" *ngIf="cartItem.book.inStockNumber==0">Product Unavailable</p>
|
||||||
<a (click)="onRemove(cartItem)">delete</a>
|
<a class="pointer" (click)="onRemoveCartItem(cartItem)">delete</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-2">
|
<div class="col-xs-2">
|
||||||
<h5 style="color: #db3208; font-size: large;">$<span [ngClass]="{'text-strike': cartItem.book.inStockNumber == 0 }"
|
<h5 style="color: #db3208; font-size: large;">$<span [ngClass]="{'text-strike': cartItem.book.inStockNumber == 0 }"
|
||||||
|
|||||||
@@ -25,7 +25,19 @@ export class ShoppingCartComponent implements OnInit {
|
|||||||
this.router.navigate(['/bookDetail', this.selectedBook.id]);
|
this.router.navigate(['/bookDetail', this.selectedBook.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
onRemoveCartItem(cartItem: CartItem) {
|
||||||
|
this.cartService.removeCartItem(cartItem.id).subscribe(
|
||||||
|
res=>{
|
||||||
|
console.log(res.text());
|
||||||
|
this.getCartItemList();
|
||||||
|
},
|
||||||
|
error=>{
|
||||||
|
console.log(error.text());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getCartItemList(){
|
||||||
this.cartService.getCartItemList().subscribe(
|
this.cartService.getCartItemList().subscribe(
|
||||||
res=>{
|
res=>{
|
||||||
this.cartItemList = res.json();
|
this.cartItemList = res.json();
|
||||||
@@ -35,6 +47,11 @@ export class ShoppingCartComponent implements OnInit {
|
|||||||
console.log(error.text());
|
console.log(error.text());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getCartItemList();
|
||||||
|
|
||||||
|
|
||||||
this.cartService.getShoppingCart().subscribe(
|
this.cartService.getShoppingCart().subscribe(
|
||||||
res=>{
|
res=>{
|
||||||
|
|||||||
@@ -37,4 +37,25 @@ export class CartService {
|
|||||||
return this.http.get(url, {headers : tokenHeader});
|
return this.http.get(url, {headers : tokenHeader});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateShoppingCart(cartItemId:number, qty:number) {
|
||||||
|
let url = AppConst.serverPath+"/cart/removeItem";
|
||||||
|
let cartItemInfo = {
|
||||||
|
"cartItemId" : cartItemId,
|
||||||
|
"qty" : qty
|
||||||
|
}
|
||||||
|
let tokenHeader = new Headers ({
|
||||||
|
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||||
|
});
|
||||||
|
return this.http.post(url, cartItemInfo, {headers : tokenHeader});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeCartItem(id:number) {
|
||||||
|
let url = AppConst.serverPath+"/cart/removeItem";
|
||||||
|
|
||||||
|
let tokenHeader = new Headers ({
|
||||||
|
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||||
|
});
|
||||||
|
return this.http.post(url, id, {headers : tokenHeader});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user