latest
This commit is contained in:
16
bookstore-api/.idea/workspace.xml
generated
16
bookstore-api/.idea/workspace.xml
generated
@@ -235,8 +235,8 @@
|
||||
<file leaf-file-name="ShoppingCartResource.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="33">
|
||||
<caret line="37" column="27" lean-forward="true" selection-start-line="37" selection-start-column="27" selection-end-line="37" selection-end-column="27" />
|
||||
<state relative-caret-position="348">
|
||||
<caret line="74" column="27" lean-forward="false" selection-start-line="74" selection-start-column="27" selection-end-line="74" selection-end-column="27" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@@ -311,8 +311,8 @@
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/UserResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/Book.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/CartResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/BookResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@@ -1112,12 +1112,12 @@
|
||||
<workItem from="1488378219247" duration="650000" />
|
||||
<workItem from="1488461561430" duration="18419000" />
|
||||
<workItem from="1488731165185" duration="30270000" />
|
||||
<workItem from="1489159532831" duration="1079000" />
|
||||
<workItem from="1489159532831" duration="1369000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="93361000" />
|
||||
<option name="totallyTimeSpent" value="93651000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="72" y="23" width="1280" height="797" extended-state="0" />
|
||||
@@ -1141,7 +1141,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="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="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="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" />
|
||||
@@ -1628,8 +1628,8 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="33">
|
||||
<caret line="37" column="27" lean-forward="true" selection-start-line="37" selection-start-column="27" selection-end-line="37" selection-end-column="27" />
|
||||
<state relative-caret-position="348">
|
||||
<caret line="74" column="27" lean-forward="false" selection-start-line="74" selection-start-column="27" selection-end-line="74" selection-end-column="27" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.bookstore.resource;
|
||||
|
||||
import com.bookstore.domain.Book;
|
||||
import com.bookstore.domain.CartItem;
|
||||
import com.bookstore.domain.ShoppingCart;
|
||||
import com.bookstore.domain.User;
|
||||
import com.bookstore.service.BookService;
|
||||
import com.bookstore.service.CartItemService;
|
||||
import com.bookstore.service.ShoppingCartService;
|
||||
import com.bookstore.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by z00382545 on 3/10/17.
|
||||
@@ -35,6 +38,9 @@ public class ShoppingCartResource {
|
||||
@Autowired
|
||||
private CartItemService cartItemService;
|
||||
|
||||
@Autowired
|
||||
private ShoppingCartService shoppingCartService;
|
||||
|
||||
@RequestMapping("/add")
|
||||
public ResponseEntity addItem(
|
||||
@RequestBody HashMap<String, String> mapper,
|
||||
@@ -55,4 +61,17 @@ public class ShoppingCartResource {
|
||||
return new ResponseEntity("Book Added Successfully!", HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/getCart")
|
||||
public List<CartItem> shoppingCart(Principal principal) {
|
||||
User user = userService.findByUsername(principal.getName());
|
||||
ShoppingCart shoppingCart = user.getShoppingCart();
|
||||
|
||||
List<CartItem> cartItemList = cartItemService.findByShoppingCart(shoppingCart);
|
||||
|
||||
shoppingCartService.updateShoppingCart(shoppingCart);
|
||||
|
||||
|
||||
return cartItemList;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -54,6 +54,7 @@ export class BookDetailComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.qty=1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<form (ngSubmit)="onSubmit()" method="post">
|
||||
<hr/>
|
||||
<div class="col-xs-2">
|
||||
<a (click)="onSelect(cartItem.book)"><img class="img-responsive shelf-book" th:src="#{adminPath}+@{/image/book/}+${cartItem.book.id}+'.png'" style="width:70px;" /></a>
|
||||
<a (click)="onSelect(cartItem.book)"><img class="img-responsive shelf-book" src="{{serverPath}}/image/book/{{cartItem.book.id}}.png" style="width:70px;" /></a>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<a (click)="onSelect(cartItem.book)"><h4>
|
||||
@@ -57,7 +57,7 @@
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input hidden="hidden" name="id" [(ngModel)]="cartItem.id" />
|
||||
<input id="cartItem.id" th:name="qty" [disabled]="cartItem.book.inStockNumber==0" class="form-control cartItemQty" [(ngModel)]="cartItem.qty" />
|
||||
<input id="cartItem.id" name="qty" [disabled]="cartItem.book.inStockNumber==0" class="form-control cartItemQty" [(ngModel)]="cartItem.qty" />
|
||||
<button style="display:none;" id="'update-item-'cartItem.id" type="submit" class="btn btn-warning btn-xs">Update
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
|
||||
import {AppConst} from '../../constants/app-const';
|
||||
import {Book} from '../../models/book';
|
||||
import {Router} from "@angular/router";
|
||||
import {CartService} from '../../services/cart.service';
|
||||
import {CartItem} from '../../models/cart-item';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -12,8 +14,9 @@ import {Router} from "@angular/router";
|
||||
export class ShoppingCartComponent implements OnInit {
|
||||
private serverPath = AppConst.serverPath;
|
||||
private selectedBook: Book;
|
||||
private cartItemList: CartItem[] = [];
|
||||
|
||||
constructor(private router:Router) { }
|
||||
constructor(private router:Router, private cartService: CartService) { }
|
||||
|
||||
onSelect(book:Book) {
|
||||
this.selectedBook = book;
|
||||
@@ -21,6 +24,15 @@ export class ShoppingCartComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.cartService.getCart().subscribe(
|
||||
res=>{
|
||||
console.log(res.json());
|
||||
this.cartItemList = res.json();
|
||||
},
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,4 +19,13 @@ export class CartService {
|
||||
return this.http.post(url, cartItemInfo, {headers : tokenHeader});
|
||||
}
|
||||
|
||||
getCart() {
|
||||
let url = AppConst.serverPath+"/cart/getCart";
|
||||
|
||||
let tokenHeader = new Headers ({
|
||||
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||
});
|
||||
return this.http.get(url, {headers : tokenHeader});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user