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.
Reference in New Issue
Block a user