From 4af75c511a16f45e9eac9a62930961bc1841d038 Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Fri, 30 Sep 2022 05:01:07 +0000 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=9B=90=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/core/auth/auth.service.ts | 23 +++++++++++++++++++ .../beteran/component/home.component.html | 11 ++++++--- .../beteran/component/home.component.ts | 14 ++++++++--- .../member/services/member.service.ts | 5 +++- src/app/shared/models/member-info.ts | 4 ++++ 5 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 src/app/shared/models/member-info.ts diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index bbe0371..6bf381b 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -4,6 +4,8 @@ import { catchError, Observable, of, switchMap, throwError } from 'rxjs'; import { AuthUtils } from 'app/core/auth/auth.utils'; import { WebSessionStorageService } from 'app/core/web-storage/services/web-session-storage.service'; import { IdentityService } from 'app/modules/polyglot/identity/services/identity.service'; +import { MemberService } from 'app/modules/polyglot/member/services/member.service'; +import { MemberInfo } from 'app/shared/models/member-info'; @Injectable() export class AuthService { @@ -15,6 +17,7 @@ export class AuthService { constructor( private _httpClient: HttpClient, private _identityService: IdentityService, + private _memberService: MemberService, private __webSessionStorageService: WebSessionStorageService ) {} @@ -33,6 +36,21 @@ export class AuthService { localStorage.setItem('accessToken', token); } + set memberInfo(memberInfo: MemberInfo) { + const info = JSON.stringify(memberInfo); + localStorage.setItem('memberInfo', info); + } + + get memberInfo(): MemberInfo { + const info = localStorage.getItem('memberInfo') ?? ''; + let result = {} as MemberInfo; + + if (info !== '') { + result = JSON.parse(info) as MemberInfo; + } + return result; + } + // ----------------------------------------------------------------------------------------------------- // @ Public methods // ----------------------------------------------------------------------------------------------------- @@ -75,6 +93,10 @@ export class AuthService { res.getAccessToken() ); + this.memberInfo = { + username: credentials.username, + } as MemberInfo; + // Store the access token in the local storage this.accessToken = res.getAccessToken(); @@ -121,6 +143,7 @@ export class AuthService { signOut(): Observable { // Remove the access token from the local storage localStorage.removeItem('accessToken'); + localStorage.removeItem('memberInfo'); // Set the authenticated flag to false this._authenticated = false; diff --git a/src/app/modules/beteran/component/home.component.html b/src/app/modules/beteran/component/home.component.html index 18b325b..babdf3d 100644 --- a/src/app/modules/beteran/component/home.component.html +++ b/src/app/modules/beteran/component/home.component.html @@ -84,19 +84,24 @@ > 회원아이디 -
test님
+
{{ member?.getUsername() }}
보유금액
-
74,100원
+
+ {{ + member?.getMemberBalance()?.getBalanceSum() + | currency: "KRW":"symbol" + }} +
콤프
-
3,100P
+
3000P
diff --git a/src/app/modules/beteran/component/home.component.ts b/src/app/modules/beteran/component/home.component.ts index 3ee7d22..9f70e2d 100644 --- a/src/app/modules/beteran/component/home.component.ts +++ b/src/app/modules/beteran/component/home.component.ts @@ -29,6 +29,8 @@ import { environment } from 'environments/environment'; import { ModifyMemberComposeComponent } from '../compose/compose/modify-member-compose.component'; import { SlotGameComposeComponent } from '../compose/compose/slot-game-compose.component'; import { MessageComposeComponent } from '../compose/compose/message-compose.component'; +import { MemberService } from 'app/modules/polyglot/member/services/member.service'; +import { MemberModel } from 'app/modules/proto/models/member_pb'; export enum ComposeMenuType { signIn = 'SignIn', @@ -60,6 +62,7 @@ export class HomeComponent implements OnInit { liveCasinos!: Vendor[]; hotelCasinos!: Vendor[]; slotGames!: Vendor[]; + member!: MemberModel | undefined; data = { schedule: { @@ -97,12 +100,17 @@ export class HomeComponent implements OnInit { private _formBuilder: FormBuilder, private _fuseConfirmationService: FuseConfirmationService, private _vendorService: VendorService, - private __gameService: GameService, + private _gameService: GameService, + private _memberService: MemberService, private _authService: AuthService ) {} ngOnInit(): void { if (!!this.loggedIn) { + const memberInfo = this._authService.memberInfo; + this._memberService + .getMemberByUsername(memberInfo.username) + .then((res) => (this.member = res.getMember())); } this._vendorService.listVendors().then((result) => { this.liveCasinos = result @@ -229,7 +237,7 @@ export class HomeComponent implements OnInit { private async getGameByParentId( parenId: number ): Promise { - return await this.__gameService.listGames(parenId); + return await this._gameService.listGames(parenId); } private openGameWindow(url: string): void { @@ -301,7 +309,7 @@ export class HomeComponent implements OnInit { gameKey = gameList[0].getKey(); } - let r = this.__gameService + let r = this._gameService .getGameUrl(vendor.getKey(), gameKey) .then((r) => { console.log('success', r.getUrl()); diff --git a/src/app/modules/polyglot/member/services/member.service.ts b/src/app/modules/polyglot/member/services/member.service.ts index 62cd674..84950a1 100644 --- a/src/app/modules/polyglot/member/services/member.service.ts +++ b/src/app/modules/polyglot/member/services/member.service.ts @@ -64,10 +64,13 @@ export class MemberService { }); } - getMemberByUsername(): Promise { + getMemberByUsername( + username: string + ): Promise { return new Promise( (resolve, reject) => { let req = new GetMemberByUsernameRequest(); + req.setUsername(username); this.__natsService .request( diff --git a/src/app/shared/models/member-info.ts b/src/app/shared/models/member-info.ts new file mode 100644 index 0000000..0328ecf --- /dev/null +++ b/src/app/shared/models/member-info.ts @@ -0,0 +1,4 @@ +export interface MemberInfo { + memberId?: string; + username: string; +}