Merge branch 'feature/BETERAN-BACKEND-APP-BROWSER-init' of https://gitlab.loafle.net/bet/beteran-backend-app-browser into feature/BETERAN-BACKEND-APP-BROWSER-init

This commit is contained in:
병준 박 2022-08-25 06:32:37 +00:00
commit 28142c3da7
6 changed files with 252 additions and 132 deletions

View File

@ -356,7 +356,7 @@
<ng-container *ngSwitchCase="'bankInfo'"> <ng-container *ngSwitchCase="'bankInfo'">
<form class="flex flex-col w-full" [formGroup]="memberBankForm"> <form class="flex flex-col w-full" [formGroup]="memberBankForm">
<div class="flex"> <div class="flex">
<mat-form-field class="w-1/2 pr-2"> <mat-form-field class="w-1/3 pr-2">
<mat-label>환전 비밀번호</mat-label> <mat-label>환전 비밀번호</mat-label>
<input <input
id="exchangePw" id="exchangePw"
@ -364,16 +364,35 @@
[formControlName]="'exchangePw'" [formControlName]="'exchangePw'"
/> />
</mat-form-field> </mat-form-field>
<mat-form-field class="w-1/2 pr-2"> <mat-form-field class="w-1/3 pr-2">
<mat-label>환전 비밀번호 확인</mat-label>
<input
id="exchangePwConfirm"
matInput
[formControlName]="'exchangePwConfirm'"
/>
</mat-form-field>
<div class="w-1/3 pr-2 mt-8">
<button
mat-flat-button
[color]="'primary'"
(click)="__changeExcahngePassword()"
>
비밀번호 수정
</button>
</div>
</div>
<div class="flex">
<mat-form-field class="w-1/3 pr-2">
<mat-label>은행명</mat-label> <mat-label>은행명</mat-label>
<mat-select <mat-select
[formControlName]="'bankId'" [formControlName]="'bankName'"
placeholder="은행 선택" placeholder="은행 선택"
> >
<mat-option <mat-option
*ngFor="let bank of banks" *ngFor="let bank of banks"
[value]="bank.getId()" [value]="bank.getName()"
> >
{{ bank.getName() }} {{ bank.getName() }}
</mat-option> </mat-option>
@ -387,9 +406,7 @@
은행명은 필수 입력입니다. 은행명은 필수 입력입니다.
</mat-error> --> </mat-error> -->
</mat-form-field> </mat-form-field>
</div> <mat-form-field class="w-1/3 pr-2">
<div class="flex">
<mat-form-field class="w-1/2 pr-2">
<mat-label>계좌번호</mat-label> <mat-label>계좌번호</mat-label>
<input <input
type="text" type="text"
@ -397,7 +414,7 @@
[formControlName]="'accountNumber'" [formControlName]="'accountNumber'"
/> />
</mat-form-field> </mat-form-field>
<mat-form-field class="w-1/2 pr-2"> <mat-form-field class="w-1/3 pr-2">
<mat-label>예금주</mat-label> <mat-label>예금주</mat-label>
<input <input
id="accountHolder" id="accountHolder"

View File

@ -54,6 +54,13 @@ import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseAlertType } from '@fuse/components/alert'; import { FuseAlertType } from '@fuse/components/alert';
import { MatSelectChange } from '@angular/material/select'; import { MatSelectChange } from '@angular/material/select';
import { ListMemberLevelsResponse } from 'app/modules/proto/c2se/member_level_pb'; import { ListMemberLevelsResponse } from 'app/modules/proto/c2se/member_level_pb';
import {
UpdateMemberBankAccountForExchangePasswordRequest,
UpdateMemberBankAccountRequest,
} from 'app/modules/proto/c2se/member_bank_account_pb';
import { MemberBankAccountService } from 'app/modules/polyglot/member_bank_account/services/member_bank_account.service';
import { ListBanksResponse } from 'app/modules/proto/c2se/bank_pb';
import { ListMemberClassesResponse } from 'app/modules/proto/c2se/member_class_pb';
@Component({ @Component({
selector: 'user-view', selector: 'user-view',
@ -159,7 +166,8 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
private _memberService: MemberService, private _memberService: MemberService,
private _memberLevelService: MemberLevelService, private _memberLevelService: MemberLevelService,
private _bankService: BankService, private _bankService: BankService,
private _siteService: SiteService private _siteService: SiteService,
private _memberBankAccountService: MemberBankAccountService
) {} ) {}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -190,10 +198,11 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
}); });
this.memberBankForm = this._formBuilder.group({ this.memberBankForm = this._formBuilder.group({
bankId: [''], bankName: [''],
accountNumber: [''], accountNumber: [''],
accountHolder: [''], accountHolder: [''],
exchangePw: [''], exchangePw: [''],
exchangePwConfirm: [''],
description: [''], description: [''],
}); });
@ -292,19 +301,20 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
}); });
/* this._memberLevelService.listMemberLevels().then((result) => { /* this._bankService.listBanks().then((result) => {
this.memberLevels = result this.memberBankForm.get('bankName')?.value;
.getMemberLevelsList()
.filter((v) => !!v.getShow()); this.memberBankForm.patchValue({
bankName: this.currentMember?.getBankAccount()?.getBank()?.getName(),
accountNumber: this.currentMember?.getBankAccount()?.getAccountNumber(),
accountHolder: this.currentMember?.getBankAccount()?.getName(),
description: this.currentMember?.getBankAccount()?.getMemo(),
});
this.memberDefaultForm
.get('levelName')
?.setValue(this.currentMember?.getMemberLevel()?.getName());
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
this.banks = result.getBanksList();
}); */ }); */
this._bankService
.listBanks()
.then((result) => (this.banks = result.getBanksList()));
this._activatedRoute.data.subscribe((data) => { this._activatedRoute.data.subscribe((data) => {
let member: GetMemberResponse.Result = data['member']; let member: GetMemberResponse.Result = data['member'];
@ -319,16 +329,28 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
signinPw: '', signinPw: '',
exchangePw: '', exchangePw: '',
mobilePhoneNumber: this.currentMember?.getMobilePhoneNumber(), mobilePhoneNumber: this.currentMember?.getMobilePhoneNumber(),
levelName: this.currentMember?.getMemberLevel()?.getId(), levelName: this.currentMember?.getMemberLevel()?.getName(),
state: this.currentMember?.getState(), state: this.currentMember?.getState(),
nickname: this.currentMember?.getNickname(), nickname: this.currentMember?.getNickname(),
bankId: this.currentMember?.getBankAccount()?.getId(),
}); });
let listMemberLevelsResult: ListMemberLevelsResponse.Result = let listMemberLevelsResult: ListMemberLevelsResponse.Result =
data['listMemberLevels']; data['listMemberLevels'];
this.memberLevels = listMemberLevelsResult.getMemberLevelsList(); this.memberLevels = listMemberLevelsResult.getMemberLevelsList();
let listMemberClassesResult: ListMemberClassesResponse.Result =
data['listMemberClasses'];
let listbanksResult: ListBanksResponse.Result = data['listMemberBanks'];
this.banks = listbanksResult.getBanksList();
this.memberBankForm.patchValue({
bankName: this.currentMember?.getBankAccount()?.getBank()?.getName(),
accountNumber: this.currentMember?.getBankAccount()?.getAccountNumber(),
accountHolder: this.currentMember?.getBankAccount()?.getName(),
description: this.currentMember?.getBankAccount()?.getMemo(),
});
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
}); });
@ -388,7 +410,32 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
switch (this.selectedPanel) { switch (this.selectedPanel) {
case 'accountInfo': case 'accountInfo':
{ this.modifyMemberDefaultInfo();
break;
case 'bankInfo':
this.modifyMemberBankAccountInfo();
break;
case 'settleInfo':
break;
case 'gameInfo':
break;
case 'historyInfo':
break;
default:
break;
}
}
private modifyMemberDefaultInfo(): void {
if (!this.currentMember?.getId()) {
return;
}
const req = new UpdateMemberRequest();
req.setId(this.currentMember?.getId());
const { const {
username, username,
signinPw, signinPw,
@ -405,9 +452,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
} = this.memberDefaultForm.value; } = this.memberDefaultForm.value;
if (!!levelName && levelName !== '') { if (!!levelName && levelName !== '') {
const level = this.memberLevels.find( const level = this.memberLevels.find((v) => v.getName() === levelName);
(v) => v.getName() === levelName
);
if (!!level) req.setMemberLevelId(level?.getId()); if (!!level) req.setMemberLevelId(level?.getId());
} }
if (!!mobilePhoneNumber && mobilePhoneNumber !== '') { if (!!mobilePhoneNumber && mobilePhoneNumber !== '') {
@ -417,42 +462,57 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
const site = this.sites.find((v) => v.getUrl() === siteUrl); const site = this.sites.find((v) => v.getUrl() === siteUrl);
if (!!site) req.setSiteId(site.getId()); if (!!site) req.setSiteId(site.getId());
} }
this._memberService
.updateMember(req)
.then((result) => {
console.log(result);
this.showAlert('success', '수정이 완료되었습니다.');
})
.catch((resson) => {
this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.');
})
.finally(() => this.closeChangePasswordAlert());
} }
break; private modifyMemberBankAccountInfo(): void {
case 'bankInfo':
{
if (!this.memberBankForm.valid) { if (!this.memberBankForm.valid) {
return; return;
} }
const { exchangePw, accountHolder, accountNumber, description } = const {
this.memberBankForm.value; exchangePw,
exchangePwConfirm,
bankName,
accountHolder,
accountNumber,
description,
} = this.memberBankForm.value;
const bank = new UpdateMemberRequest.BankAccount();
const bankId = this.currentMember?.getBankAccount()?.getId(); const bankId = this.currentMember?.getBankAccount()?.getId();
if (!!bankId) { const bankReq = new UpdateMemberBankAccountRequest();
bank.setId(bankId); const bankFind = this.banks.find((v) => v.getName() === bankName);
bank.setAccountNumber(accountNumber);
bank.setName(accountHolder); if (!bankId || !bankFind) {
} console.log('Error bankId undefined or bankFind undefined');
req.setBankAccount(bank); return;
} }
break; bankReq.setAccountNumber(accountNumber);
case 'settleInfo': bankReq.setBankId(bankFind?.getId());
break; bankReq.setId(bankId);
case 'gameInfo': bankReq.setMemo(description);
break; bankReq.setName(accountHolder);
case 'historyInfo':
break;
default:
break;
}
this._memberService.updateMember(req).then((result) => {
console.log(result);
});
}
this._memberBankAccountService
.updateMemberBankAccount(bankReq)
.then((result) => {
this.showAlert('success', '수정이 완료되었습니다.');
})
.catch((reson) => {
this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.');
})
.finally(() => this.closeChangePasswordAlert());
}
/** /**
* Navigate to the panel * Navigate to the panel
* *
@ -531,6 +591,49 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
}); });
} }
__changeExcahngePassword(): void {
const password = this.memberBankForm.get('exchangePw')?.value as string;
const passwordConfirm = this.memberBankForm.get('exchangePwConfirm')
?.value as string;
if (!password || !passwordConfirm) {
this.showAlert('error', '비밀번호를 입력하세요.');
this.closeChangePasswordAlert();
return;
}
if (password !== passwordConfirm) {
this.showAlert('error', '비밀번호가 일치하지 않습니다.');
this.closeChangePasswordAlert();
return;
}
const dialogRef = this._fuseConfirmationService.open(
this.passwordConfirmConfigForm.value
);
/* const dialogRef = this._matDialog.open(AddComposeComponent); */
dialogRef.afterClosed().subscribe((result) => {
if (result === 'confirmed') {
const req = new UpdateMemberBankAccountForExchangePasswordRequest();
req.setExchangePassword(password);
req.setId(this.currentMember!.getId());
this._memberBankAccountService
.updateMemberBankAccountForExchangePassword(req)
.then((result) => {
this.showAlert('success', '비밀번호가 수정 되었습니다.');
})
.catch((reson) => {
this.showAlert('error', '패스워드 변경이 실패하였습니다.');
})
.finally(() => this.closeChangePasswordAlert());
}
});
}
onSelectionChangeLanguage(event: MatSelectChange) { onSelectionChangeLanguage(event: MatSelectChange) {
const state = event.value; const state = event.value;
@ -567,6 +670,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
type, type,
message, message,
}; };
this._changeDetectorRef.markForCheck();
} }
private closeChangePasswordAlert(): void { private closeChangePasswordAlert(): void {

View File

@ -0,0 +1,50 @@
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
Resolve,
Router,
RouterStateSnapshot,
} from '@angular/router';
import { BankService } from 'app/modules/polyglot/bank/services/bank.service';
import { MemberClassService } from 'app/modules/polyglot/member_class/services/member_class.service';
import {
ListBanksRequest,
ListBanksResponse,
} from 'app/modules/proto/c2se/bank_pb';
import {
ListMemberClassesRequest,
ListMemberClassesResponse,
} from 'app/modules/proto/c2se/member_class_pb';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class ListMemberBanksResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private _router: Router, private __bankService: BankService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<ListBanksResponse.Result>
| Promise<ListBanksResponse.Result>
| ListBanksResponse.Result {
return this.__bankService.listBanks();
}
}

View File

@ -161,57 +161,3 @@ export class MemberResolver implements Resolve<any> {
return this._memberService.getMember(memberId!); return this._memberService.getMember(memberId!);
} }
} }
export class SitesResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private __siteService: SiteService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<ListSitesResponse.Result>
| Promise<ListSitesResponse.Result>
| ListSitesResponse.Result {
return this.__siteService.listSites();
}
}
export class BanksResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private _bankService: BankService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<ListBanksResponse.Result>
| Promise<ListBanksResponse.Result>
| ListBanksResponse.Result {
return this._bankService.listBanks();
}
}

View File

@ -2,6 +2,7 @@ import { Route } from '@angular/router';
import { ListComponent } from 'app/modules/admin/member/user/components/list.component'; import { ListComponent } from 'app/modules/admin/member/user/components/list.component';
import { ViewComponent } from 'app/modules/admin/member/user/components/view.component'; import { ViewComponent } from 'app/modules/admin/member/user/components/view.component';
import { ListMemberBanksResolver } from './resolvers/member-bank.resolver';
import { ListMemberClassesResolver } from './resolvers/member-class.resolver'; import { ListMemberClassesResolver } from './resolvers/member-class.resolver';
import { ListMemberLevelsResolver } from './resolvers/member-level.resolver'; import { ListMemberLevelsResolver } from './resolvers/member-level.resolver';
@ -15,6 +16,7 @@ export const userRoutes: Route[] = [
listmembers: ListMemberResolver, listmembers: ListMemberResolver,
listMemberClasses: ListMemberClassesResolver, listMemberClasses: ListMemberClassesResolver,
listMemberLevels: ListMemberLevelsResolver, listMemberLevels: ListMemberLevelsResolver,
listMemberBanks: ListMemberBanksResolver,
}, },
}, },
{ {

View File

@ -16,6 +16,7 @@ import {
GetMemberBankAccountResponse, GetMemberBankAccountResponse,
GetMemberBankAccountRequest, GetMemberBankAccountRequest,
UpdateMemberBankAccountForExchangePasswordResponse, UpdateMemberBankAccountForExchangePasswordResponse,
UpdateMemberBankAccountForExchangePasswordRequest,
} from 'app/modules/proto/c2se/member_bank_account_pb'; } from 'app/modules/proto/c2se/member_bank_account_pb';
import { import {
SUBJECT_LIST_MEMBER_BANK_ACCOUNTS, SUBJECT_LIST_MEMBER_BANK_ACCOUNTS,
@ -112,11 +113,11 @@ export class MemberBankAccountService {
); );
} }
updateMemberBankAccount(): Promise<UpdateMemberBankAccountResponse.Result> { updateMemberBankAccount(
req: UpdateMemberBankAccountRequest
): Promise<UpdateMemberBankAccountResponse.Result> {
return new Promise<UpdateMemberBankAccountResponse.Result>( return new Promise<UpdateMemberBankAccountResponse.Result>(
(resolve, reject) => { (resolve, reject) => {
let req = new UpdateMemberBankAccountRequest();
this.__natsService this.__natsService
.request<UpdateMemberBankAccountResponse.Result>( .request<UpdateMemberBankAccountResponse.Result>(
SUBJECT_UPDATE_MEMBER_BANK_ACCOUNT, SUBJECT_UPDATE_MEMBER_BANK_ACCOUNT,
@ -135,11 +136,11 @@ export class MemberBankAccountService {
); );
} }
updateMemberBankAccountForExchangePassword(): Promise<UpdateMemberBankAccountForExchangePasswordResponse.Result> { updateMemberBankAccountForExchangePassword(
req: UpdateMemberBankAccountForExchangePasswordRequest
): Promise<UpdateMemberBankAccountForExchangePasswordResponse.Result> {
return new Promise<UpdateMemberBankAccountForExchangePasswordResponse.Result>( return new Promise<UpdateMemberBankAccountForExchangePasswordResponse.Result>(
(resolve, reject) => { (resolve, reject) => {
let req = new UpdateMemberBankAccountForExchangePasswordResponse();
this.__natsService this.__natsService
.request<UpdateMemberBankAccountForExchangePasswordResponse.Result>( .request<UpdateMemberBankAccountForExchangePasswordResponse.Result>(
SUBJECT_UPDATE_MEMBER_BANK_ACCOUNT_FOR_EXCHANGE_PASSWORD, SUBJECT_UPDATE_MEMBER_BANK_ACCOUNT_FOR_EXCHANGE_PASSWORD,