latest
This commit is contained in:
32
bookstore-api/.idea/workspace.xml
generated
32
bookstore-api/.idea/workspace.xml
generated
@@ -26,7 +26,7 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="Book.java" pinned="false" current-in-tab="true">
|
||||
<file leaf-file-name="Book.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/Book.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="270">
|
||||
@@ -110,11 +110,11 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="BookResource.java" pinned="false" current-in-tab="false">
|
||||
<file leaf-file-name="BookResource.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/BookResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="197">
|
||||
<caret line="88" column="12" lean-forward="false" selection-start-line="88" selection-start-column="12" selection-end-line="88" selection-end-column="80" />
|
||||
<state relative-caret-position="-967">
|
||||
<caret line="41" column="36" lean-forward="false" selection-start-line="41" selection-start-column="36" selection-end-line="41" selection-end-column="36" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@@ -176,7 +176,6 @@
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/utility/MailConstructor.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/service/impl/BookServiceImpl.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/service/BookService.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/BookResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/ShoppingCart.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/UserPayment.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/UserBilling.java" />
|
||||
@@ -185,6 +184,7 @@
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/UserShipping.java" />
|
||||
<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/BookResource.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@@ -982,12 +982,12 @@
|
||||
<workItem from="1486538831944" duration="450000" />
|
||||
<workItem from="1488378219247" duration="650000" />
|
||||
<workItem from="1488461561430" duration="18419000" />
|
||||
<workItem from="1488731165185" duration="27199000" />
|
||||
<workItem from="1488731165185" duration="28617000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="89211000" />
|
||||
<option name="totallyTimeSpent" value="90629000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="82" y="23" width="1280" height="797" extended-state="0" />
|
||||
@@ -1010,7 +1010,7 @@
|
||||
<window_info id="Palette	" 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="6" 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="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="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32624114" sideWeight="0.5" order="2" 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.33" sideWeight="0.5" order="8" 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" />
|
||||
@@ -1328,14 +1328,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/BookResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="197">
|
||||
<caret line="88" column="12" lean-forward="false" selection-start-line="88" selection-start-column="12" selection-end-line="88" selection-end-column="80" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/service/impl/ShippingAddressServiceImpl.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="135">
|
||||
@@ -1396,5 +1388,13 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/BookResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-967">
|
||||
<caret line="41" column="36" lean-forward="false" selection-start-line="41" selection-start-column="36" selection-end-line="41" selection-end-column="36" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.bookstore.resource;
|
||||
|
||||
import com.bookstore.domain.Book;
|
||||
import com.bookstore.domain.User;
|
||||
import com.bookstore.service.BookService;
|
||||
import com.bookstore.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -12,12 +14,15 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.websocket.server.PathParam;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.Principal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,6 +38,9 @@ public class BookResource {
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping(value = "/add/image", method = RequestMethod.POST)
|
||||
public ResponseEntity upload(
|
||||
@RequestParam("id") Long id,
|
||||
@@ -115,6 +123,18 @@ public class BookResource {
|
||||
return book;
|
||||
}
|
||||
|
||||
@RequestMapping("/{id}")
|
||||
public ResponseEntity bookDetail(@PathVariable("id") Long id, Principal principal) {
|
||||
if (principal != null) {
|
||||
String username = principal.getName();
|
||||
User user = userService.findByUsername(username);
|
||||
}
|
||||
|
||||
Book book = bookService.findOne(id);
|
||||
|
||||
return new ResponseEntity("Book Found!", HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove", method = RequestMethod.POST)
|
||||
public ResponseEntity remove(
|
||||
@RequestBody String id, Model model
|
||||
|
||||
BIN
bookstore-api/src/main/resources/static/image/book/21.png
Normal file
BIN
bookstore-api/src/main/resources/static/image/book/21.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 529 KiB |
BIN
bookstore-api/target/classes/static/image/book/21.png
Normal file
BIN
bookstore-api/target/classes/static/image/book/21.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 529 KiB |
@@ -22,6 +22,7 @@ import { BookService } from './services/book.service';
|
||||
import { MyAccountComponent } from './components/my-account/my-account.component';
|
||||
import { MyProfileComponent } from './components/my-profile/my-profile.component';
|
||||
import { BookListComponent } from './components/book-list/book-list.component';
|
||||
import { BookDetailComponent } from './components/book-detail/book-detail.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -31,7 +32,8 @@ import { BookListComponent } from './components/book-list/book-list.component';
|
||||
NavBarComponent,
|
||||
MyAccountComponent,
|
||||
MyProfileComponent,
|
||||
BookListComponent
|
||||
BookListComponent,
|
||||
BookDetailComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {HomeComponent} from './components/home/home.component';
|
||||
import {MyAccountComponent} from './components/my-account/my-account.component';
|
||||
import {MyProfileComponent} from './components/my-profile/my-profile.component';
|
||||
import {BookListComponent} from './components/book-list/book-list.component';
|
||||
|
||||
import {BookDetailComponent} from './components/book-detail/book-detail.component';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
@@ -31,6 +31,10 @@ const appRoutes: Routes = [
|
||||
{
|
||||
path: 'bookList',
|
||||
component: BookListComponent
|
||||
},
|
||||
{
|
||||
path: 'bookDetail/:id',
|
||||
component: BookDetailComponent
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<div class="container" style="margin-top: 20px;">
|
||||
<div class="row">
|
||||
<div class="col-xs-8">
|
||||
<h2 class="section-headline"><span>All Books</span></h2>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<a href="#"><img src="{{serverPath}}/image/logo.png" class="img-responsive"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<hr style="position: absolute; width:100%; height:6px; background-color: #333; z-index: -1; margin-top: -80px;"/>
|
||||
<img class="img-responsive" src="{{serverPath}}/image/wood.png" style="margin-top: -75px;"/>
|
||||
|
||||
<div class="row">
|
||||
<div class="row" style="margin-top: 120px;">
|
||||
<div class="col-xs-3">
|
||||
<a routerLink="/bookList" routerLinkActive="active">Back to book list</a>
|
||||
<br />
|
||||
<img class="img-responsive" src="{{serverPath}}/image/book/{{book.id}}.png"/>
|
||||
</div>
|
||||
<div class="col-xs-9">
|
||||
<h3><span *ngIf="addBookSuccess" style="color: forestgreen"><i class="fa fa-check" aria-hidden="true" style="color: forestgreen"></i>Added to cart.</span></h3>
|
||||
<h3><span *ngIf="notEnoughStock" style="color: red">Oops, only <span>{{book.inStockNumber}}</span> In Stock.</span></h3>
|
||||
<h3>{{book.title}}</h3>
|
||||
<div class="row">
|
||||
<div class="col-xs-5">
|
||||
<h5><strong>Author:</strong> <span>{{book.author}}</span></h5>
|
||||
<p><strong>Publisher:</strong> <span>{{book.publisher}}</span></p>
|
||||
<p><strong>Publication Date:</strong> <span>{{book.publicationDate}}</span></p>
|
||||
<p><strong>Language:</strong> <span>{{book.language}}</span></p>
|
||||
<p><strong>Category:</strong> <span>{{book.category}}</span></p>
|
||||
<p><strong><span>{{book.format}}</span>:</strong> <span>{{book.numberOfPages}}</span> pages</p>
|
||||
<p><strong>ISBN:</strong> <span>{{book.isbn}}</span></p>
|
||||
<p><strong>Shipping Weight:</strong> <span>{{book.shippingWeight}}</span> ounces</p>
|
||||
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<div class="panel panel-default" style="border-width: 5px; margin-top: 20px;">
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<h4>Our Price: <span style="color: #db3208;">$<span
|
||||
>{{book.ourPrice | number : '1.2-2'}}</span></span></h4>
|
||||
<p>List Price: <span style="text-decoration: line-through;">$<span
|
||||
>{{book.listPrice | number : '1.2-2'}}</span></span></p>
|
||||
<p>You Save: $<span
|
||||
>{{book.listPrice-book.ourPrice | number : '1.2-2'}}</span>
|
||||
</p>
|
||||
<span>Qty: </span>
|
||||
<select [(ngModel)]="qty" class="browser-default" style="width: 50px;display: inline;">
|
||||
<option *ngFor="let x of numberList" [ngValue]="x" >{{x}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<h4 *ngIf="book.inStockNumber>10" style="color: green;">In Stock</h4>
|
||||
<h4 *ngIf="book.inStockNumber<10 && book.inStockNumber>0"
|
||||
style="color: green;"> Only <span>{{book.inStockNumber}}</span> In
|
||||
Stock</h4>
|
||||
<h4 *ngIf="book.inStockNumber==0" style="color: darkred;">Unavailable</h4>
|
||||
<button [disabled]="book.inStockNumber==0" type="submit" class="btn btn-warning"
|
||||
style="color: black;border:1px solid black; padding: 10px 40px 10px 40px;">
|
||||
Add to Cart
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<p>{{book.description}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,28 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { BookDetailComponent } from './book-detail.component';
|
||||
|
||||
describe('BookDetailComponent', () => {
|
||||
let component: BookDetailComponent;
|
||||
let fixture: ComponentFixture<BookDetailComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ BookDetailComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BookDetailComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||
import {Book} from "../../models/book";
|
||||
import {BookService} from "../../services/book.service";
|
||||
import {Params, ActivatedRoute,Router} from "@angular/router";
|
||||
import {Http} from "@angular/http";
|
||||
import {AppConst} from '../../constants/app-const';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-detail',
|
||||
templateUrl: './book-detail.component.html',
|
||||
styleUrls: ['./book-detail.component.css']
|
||||
})
|
||||
export class BookDetailComponent implements OnInit {
|
||||
|
||||
private bookId: number;
|
||||
private book: Book = new Book();
|
||||
private serverPath = AppConst.serverPath;
|
||||
private numberList: number[]=[1,2,3,4,5,6,7,8,9];
|
||||
private qty:number;
|
||||
|
||||
private addBookSuccess:boolean = false;
|
||||
private notEnoughStock:boolean = false;
|
||||
|
||||
constructor(private bookService: BookService, private route: ActivatedRoute, private router:Router) {
|
||||
this.route.params.forEach((params: Params) => {
|
||||
this.bookId = Number.parseInt(params['id']);
|
||||
});
|
||||
|
||||
this.bookService.getBook(this.bookId).subscribe(
|
||||
res => {
|
||||
this.book=res.json();
|
||||
},
|
||||
error => console.log(error)
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,8 +12,8 @@ import {AppConst} from '../../constants/app-const';
|
||||
})
|
||||
export class BookListComponent implements OnInit {
|
||||
|
||||
public filterQuery = "";
|
||||
public rowsOnPage = 10;
|
||||
public filterQuery = "";
|
||||
public rowsOnPage = 10;
|
||||
|
||||
private selectedBook : Book;
|
||||
private bookList: Book[];
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {Headers, Http} from "@angular/http";
|
||||
import {AppConst} from '../constants/app-const';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class BookService {
|
||||
@@ -7,7 +9,15 @@ export class BookService {
|
||||
constructor(private http: Http) { }
|
||||
|
||||
getBookList() {
|
||||
let url = "http://localhost:8181/book/bookList";
|
||||
let url = AppConst.serverPath+"/book/bookList";
|
||||
let tokenHeader = new Headers ({
|
||||
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||
});
|
||||
return this.http.get(url, {headers : tokenHeader});
|
||||
}
|
||||
|
||||
getBook(id:number) {
|
||||
let url = AppConst.serverPath+"/book/"+id;
|
||||
let tokenHeader = new Headers ({
|
||||
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user