From e2f700216f611ade67efbfc9de3972a28d109abb Mon Sep 17 00:00:00 2001 From: Le Deng Date: Wed, 8 Mar 2017 12:34:43 -0500 Subject: [PATCH] latest --- bookstore-api/.idea/workspace.xml | 24 +++++++++++------- .../bookstore/resource/PaymentResource.java | 6 ++--- .../bookstore/resource/PaymentResource.class | Bin 0 -> 3030 bytes store-front/src/app/app.module.ts | 4 ++- .../my-profile/my-profile.component.html | 4 +-- .../my-profile/my-profile.component.ts | 15 ++++++++++- .../src/app/services/payment.service.ts | 11 ++++++-- 7 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 bookstore-api/target/classes/com/bookstore/resource/PaymentResource.class diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index 534a6f8..597616a 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -29,8 +29,8 @@ - - + + @@ -943,16 +943,16 @@ - + - - + @@ -965,7 +965,7 @@ - + @@ -1001,8 +1001,14 @@ 26 + + file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/PaymentResource.java + 56 + + - @@ -1359,8 +1365,8 @@ - - + + diff --git a/bookstore-api/src/main/java/com/bookstore/resource/PaymentResource.java b/bookstore-api/src/main/java/com/bookstore/resource/PaymentResource.java index fb02180..cf39483 100644 --- a/bookstore-api/src/main/java/com/bookstore/resource/PaymentResource.java +++ b/bookstore-api/src/main/java/com/bookstore/resource/PaymentResource.java @@ -48,11 +48,11 @@ public class PaymentResource { @RequestMapping(value = "/add", method = RequestMethod.POST) public ResponseEntity addNewCreditCardPost( - @RequestBody HashMap mapper, + @RequestBody UserPayment userPayment, Principal principal, Model model) { 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); diff --git a/bookstore-api/target/classes/com/bookstore/resource/PaymentResource.class b/bookstore-api/target/classes/com/bookstore/resource/PaymentResource.class new file mode 100644 index 0000000000000000000000000000000000000000..08fef8787e7ef50c8fd5fe5f3f0770529cd9a4f4 GIT binary patch literal 3030 zcmb7G>vj`W7~PYm&7~1&sFVn5OSvR1Fj_&NMYJs-N@!{WML>l~=A<1unF%vzTHyj`7Zn0-(}{ne}4ZHzy*AtMh;6U9L4e|uH(ii zZsPMK&W++0zDVNBG;X7q#2vM+BvDf9Y7(c?_zG)Dl#{rd#Jx1uabKx^oxp=69;WaJ z-=r~)Zxi?~fyWv~17CP$;cZ)0p<%jMb?bV?b+>%!dP3(j^+3PZ6PAOFUks$XV|l`) z*^#T3W65h8hVq4V4e@2yB&35y%MmL7Tv00uN$7F&e3IDZd!Do-xGi* zd^hkI!K%@$3rDU+XSy4+Enk*u%XDtZWy3S6?&bT!4=nu-!PpDMr^dEHR;qz#$)>)_ zD63Y(h#ou-`Lc!7H>GUoxA>=+<;9wK76@N16j}ys!`aZwQgK8e!*yj_!+ZPt){s)H zhW?m?flxFgyp}r+XF{p}#znSO9cVbVhdB93 zklThGsO0H=XdgFBb4BcQQ?cs$Qo|2>v)O|t%I7{A=~suHL>BsT9j1*X(qJiz8?15J zWYl4cME*3K7|c)`Q>3zF**1gUS0$36m$*(6*aUSUH(hQn^+mWJ*P)`av|1|PrPtkE zx@xFyl)~H9t{30b%aUs`_8GU-EK+x-gkqB12qnUrKWmcIH4^) z|N6))3~nLj{&+v`+KsCr!!}uzoSl_G66^Io_Io_G!sguF&nTVdcE{E;Xjl{^Mg`PU zV!Ui~6iCa~RVmTR;YhMwD(aeud0T219N#t52s_Prr}8bVK4cS1Z__a zL>S>B`H}lh<(?$Sfok2+GZutZr(*1=R`!{_ZOy^9BS;H_B^J~xe!5>)y6;YYR0Qm@ zSn0NgQ++eIN0v0r_try{{r{y}SjQBXd1p-irT*1MS1X-ov5pAv^XHeYS9(MvD7sj1k*$ zBAX$$%Q(X?#Tk?_izhgXI?ji2Txem9;vj0u<-^z-C{RA8BB9P%Mm2`VI7hvBNZkQS zDWX1j1kJ~X+|A)5N=;JZN6L(FoqL^w7s$>JtLxnGtYYJE9DiW^LH6xmaO5Q>x>00l z1Gq@9moR}VjAJ20e63}1E6S literal 0 HcmV?d00001 diff --git a/store-front/src/app/app.module.ts b/store-front/src/app/app.module.ts index 1714959..c7f4ec2 100644 --- a/store-front/src/app/app.module.ts +++ b/store-front/src/app/app.module.ts @@ -13,6 +13,7 @@ import { NavBarComponent } from './components/nav-bar/nav-bar.component'; import { LoginService } from './services/login.service'; import { UserService } from './services/user.service'; +import { PaymentService } from './services/payment.service'; import { MyAccountComponent } from './components/my-account/my-account.component'; import { MyProfileComponent } from './components/my-profile/my-profile.component'; @@ -33,7 +34,8 @@ import { MyProfileComponent } from './components/my-profile/my-profile.component ], providers: [ LoginService, - UserService + UserService, + PaymentService ], bootstrap: [AppComponent] }) diff --git a/store-front/src/app/components/my-profile/my-profile.component.html b/store-front/src/app/components/my-profile/my-profile.component.html index 12afe0e..91bf39f 100644 --- a/store-front/src/app/components/my-profile/my-profile.component.html +++ b/store-front/src/app/components/my-profile/my-profile.component.html @@ -104,7 +104,7 @@ -
+
User info updated.
@@ -240,7 +240,7 @@

- +
diff --git a/store-front/src/app/components/my-profile/my-profile.component.ts b/store-front/src/app/components/my-profile/my-profile.component.ts index 17e3d78..df6f16e 100644 --- a/store-front/src/app/components/my-profile/my-profile.component.ts +++ b/store-front/src/app/components/my-profile/my-profile.component.ts @@ -3,6 +3,7 @@ import {AppConst} from '../../constants/app-const'; import {Router} from "@angular/router"; import {LoginService} from "../../services/login.service"; import {UserService} from "../../services/user.service"; +import {PaymentService} from "../../services/payment.service"; import {User} from '../../models/user'; import {UserPayment} from '../../models/user-payment'; import {UserBilling} from '../../models/user-billing'; @@ -35,7 +36,7 @@ export class MyProfileComponent implements OnInit { private userPaymentList: UserPayment[] = []; 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() { @@ -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() { this.loginService.checkSession().subscribe( res => { @@ -119,5 +131,6 @@ export class MyProfileComponent implements OnInit { this.userPayment.type=""; this.userPayment.expiryMonth=""; this.userPayment.expiryYear=""; + this.userPayment.userBilling = this.userBilling; } } diff --git a/store-front/src/app/services/payment.service.ts b/store-front/src/app/services/payment.service.ts index 3301e9e..d51f1f5 100644 --- a/store-front/src/app/services/payment.service.ts +++ b/store-front/src/app/services/payment.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import {AppConst} from '../constants/app-const'; import {Http, Headers} from '@angular/http'; +import {UserPayment} from '../models/user-payment'; @Injectable() export class PaymentService { @@ -8,7 +9,13 @@ export class PaymentService { 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}); } } \ No newline at end of file