This commit is contained in:
Le Deng
2017-03-08 12:34:43 -05:00
parent bed84249fe
commit e2f700216f
7 changed files with 46 additions and 18 deletions

View File

@@ -29,8 +29,8 @@
<file leaf-file-name="PaymentResource.java" pinned="false" current-in-tab="true"> <file leaf-file-name="PaymentResource.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/PaymentResource.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/PaymentResource.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="353"> <state relative-caret-position="266">
<caret line="48" column="33" lean-forward="false" selection-start-line="48" selection-start-column="33" selection-end-line="48" selection-end-column="33" /> <caret line="56" column="0" lean-forward="false" selection-start-line="56" selection-start-column="0" selection-end-line="56" selection-end-column="0" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@@ -943,16 +943,16 @@
<workItem from="1486538831944" duration="450000" /> <workItem from="1486538831944" duration="450000" />
<workItem from="1488378219247" duration="650000" /> <workItem from="1488378219247" duration="650000" />
<workItem from="1488461561430" duration="18419000" /> <workItem from="1488461561430" duration="18419000" />
<workItem from="1488731165185" duration="15539000" /> <workItem from="1488731165185" duration="16477000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="77551000" /> <option name="totallyTimeSpent" value="78489000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="23" width="1280" height="797" extended-state="0" /> <frame x="0" y="23" width="1280" height="797" extended-state="0" />
<editor active="true" /> <editor active="false" />
<layout> <layout>
<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="3" side_tool="false" content_ui="tabs" /> <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="3" side_tool="false" content_ui="tabs" />
<window_info id="Nl-Palette" 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="2" side_tool="false" content_ui="tabs" /> <window_info id="Nl-Palette" 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="2" side_tool="false" content_ui="tabs" />
@@ -965,7 +965,7 @@
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" 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="4" side_tool="false" content_ui="tabs" /> <window_info id="UI Designer" 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="4" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" 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="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" 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="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" 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="11" side_tool="false" content_ui="tabs" /> <window_info id="Messages" 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="11" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" 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="Palette&#9;" 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" />
@@ -1001,8 +1001,14 @@
<line>26</line> <line>26</line>
<properties /> <properties />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/PaymentResource.java</url>
<line>56</line>
<properties />
<option name="timeStamp" value="6" />
</line-breakpoint>
</breakpoints> </breakpoints>
<option name="time" value="6" /> <option name="time" value="7" />
</breakpoint-manager> </breakpoint-manager>
<watches-manager /> <watches-manager />
</component> </component>
@@ -1359,8 +1365,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/PaymentResource.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/PaymentResource.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="353"> <state relative-caret-position="266">
<caret line="48" column="33" lean-forward="false" selection-start-line="48" selection-start-column="33" selection-end-line="48" selection-end-column="33" /> <caret line="56" column="0" lean-forward="false" selection-start-line="56" selection-start-column="0" selection-end-line="56" selection-end-column="0" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>

View File

@@ -48,11 +48,11 @@ public class PaymentResource {
@RequestMapping(value = "/add", method = RequestMethod.POST) @RequestMapping(value = "/add", method = RequestMethod.POST)
public ResponseEntity addNewCreditCardPost( public ResponseEntity addNewCreditCardPost(
@RequestBody HashMap<String, Object> mapper, @RequestBody UserPayment userPayment,
Principal principal, Model model) { Principal principal, Model model) {
User user = userService.findByUsername(principal.getName()); User user = userService.findByUsername(principal.getName());
UserPayment userPayment = (UserPayment) mapper.get("userPayment");
UserBilling userBilling = (UserBilling) mapper.get("userBilling"); UserBilling userBilling = userPayment.getUserBilling();
userService.updateUserBilling(userBilling, userPayment, user); userService.updateUserBilling(userBilling, userPayment, user);

View File

@@ -13,6 +13,7 @@ import { NavBarComponent } from './components/nav-bar/nav-bar.component';
import { LoginService } from './services/login.service'; import { LoginService } from './services/login.service';
import { UserService } from './services/user.service'; import { UserService } from './services/user.service';
import { PaymentService } from './services/payment.service';
import { MyAccountComponent } from './components/my-account/my-account.component'; import { MyAccountComponent } from './components/my-account/my-account.component';
import { MyProfileComponent } from './components/my-profile/my-profile.component'; import { MyProfileComponent } from './components/my-profile/my-profile.component';
@@ -33,7 +34,8 @@ import { MyProfileComponent } from './components/my-profile/my-profile.component
], ],
providers: [ providers: [
LoginService, LoginService,
UserService UserService,
PaymentService
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

View File

@@ -104,7 +104,7 @@
</form> </form>
</md-tab> </md-tab>
<md-tab label="Add(Update) Credit Card"> <md-tab label="Add(Update) Credit Card">
<form (ngSubmit)="addUpdateCreditCard()" method="post"> <form (ngSubmit)="onNewPayment()" method="post">
<div class="bg-info" *ngIf="updateUserPaymentInfo">User info updated.</div> <div class="bg-info" *ngIf="updateUserPaymentInfo">User info updated.</div>
<input hidden="hidden" name="id" [(ngModel)]="userPayment.id" /> <input hidden="hidden" name="id" [(ngModel)]="userPayment.id" />
<div class="form-group"> <div class="form-group">
@@ -240,7 +240,7 @@
</div> </div>
</div> </div>
<hr/> <hr/>
<button type="submit" class="btn btn-primary btn-lg">Save All</button> <button md-raised-button type="submit" class="mat-primary">Save All</button>
</form> </form>
</md-tab> </md-tab>
</md-tab-group> </md-tab-group>

View File

@@ -3,6 +3,7 @@ import {AppConst} from '../../constants/app-const';
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {LoginService} from "../../services/login.service"; import {LoginService} from "../../services/login.service";
import {UserService} from "../../services/user.service"; import {UserService} from "../../services/user.service";
import {PaymentService} from "../../services/payment.service";
import {User} from '../../models/user'; import {User} from '../../models/user';
import {UserPayment} from '../../models/user-payment'; import {UserPayment} from '../../models/user-payment';
import {UserBilling} from '../../models/user-billing'; import {UserBilling} from '../../models/user-billing';
@@ -35,7 +36,7 @@ export class MyProfileComponent implements OnInit {
private userPaymentList: UserPayment[] = []; private userPaymentList: UserPayment[] = [];
private stateList: string[] = []; private stateList: string[] = [];
constructor (private loginService: LoginService, private userService: UserService, private router: Router){ constructor (private paymentService:PaymentService, private loginService: LoginService, private userService: UserService, private router: Router){
} }
onLogin() { onLogin() {
@@ -90,6 +91,17 @@ export class MyProfileComponent implements OnInit {
); );
} }
onNewPayment () {
this.paymentService.newPayment(this.userPayment).subscribe(
res => {
console.log(res);
},
error => {
console.log(error.text());
}
);
}
ngOnInit() { ngOnInit() {
this.loginService.checkSession().subscribe( this.loginService.checkSession().subscribe(
res => { res => {
@@ -119,5 +131,6 @@ export class MyProfileComponent implements OnInit {
this.userPayment.type=""; this.userPayment.type="";
this.userPayment.expiryMonth=""; this.userPayment.expiryMonth="";
this.userPayment.expiryYear=""; this.userPayment.expiryYear="";
this.userPayment.userBilling = this.userBilling;
} }
} }

View File

@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {AppConst} from '../constants/app-const'; import {AppConst} from '../constants/app-const';
import {Http, Headers} from '@angular/http'; import {Http, Headers} from '@angular/http';
import {UserPayment} from '../models/user-payment';
@Injectable() @Injectable()
export class PaymentService { export class PaymentService {
@@ -8,7 +9,13 @@ export class PaymentService {
constructor(private http:Http) { } constructor(private http:Http) { }
getUserPaymentlist() { newPayment(payment: UsePayment) {
let url = this.serverPath+"/payment/add";
let tokenHeader = new Headers ({
'Content-Type': 'application/json',
'x-auth-token' : localStorage.getItem("xAuthToken")
});
return this.http.post(url, JSON.stringify(payment), {headers : tokenHeader});
} }
} }