회원 등록 연동

This commit is contained in:
Park Byung Eun 2022-08-12 09:28:56 +00:00
parent a6a54e68e6
commit 9bf22f83d3
5 changed files with 120 additions and 71 deletions

View File

@ -22,6 +22,7 @@ import {
startWith, startWith,
Subject, Subject,
switchMap, switchMap,
take,
takeUntil, takeUntil,
timer, timer,
} from 'rxjs'; } from 'rxjs';
@ -32,7 +33,10 @@ import { Partner } from '../models/partner';
import { PartnerPagination } from '../models/partner-pagination'; import { PartnerPagination } from '../models/partner-pagination';
import { PartnerService } from '../services/partner.service'; import { PartnerService } from '../services/partner.service';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { RegistComposeComponent } from '../compose/regist-compose.component'; import {
RegistComposeComponent,
RegistComposeResult,
} from '../compose/regist-compose.component';
import { CashComposeComponent } from '../compose/cash-compose.component'; import { CashComposeComponent } from '../compose/cash-compose.component';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -240,12 +244,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
__onClickRegist(event: MouseEvent, partner: MemberModel): void { __onClickRegist(event: MouseEvent, partner: MemberModel): void {
const dialogRef = this._matDialog.open(RegistComposeComponent, { const dialogRef = this._matDialog.open(RegistComposeComponent, {
data: { title: '대본 등록하기', parent: partner, sites: this.sites }, data: { title: '대본 등록', parent: partner, sites: this.sites },
}); });
dialogRef.afterClosed().subscribe((result) => { dialogRef
console.log('Compose dialog was closed!'); .afterClosed()
}); .pipe(take(1))
.subscribe((result: RegistComposeResult) => {
console.log('Compose dialog was closed: ', result);
});
} }
__onClickCash(event: MouseEvent): void { __onClickCash(event: MouseEvent): void {
const dialogRef = this._matDialog.open(CashComposeComponent, { const dialogRef = this._matDialog.open(CashComposeComponent, {

View File

@ -3,7 +3,7 @@
<div <div
class="flex flex-0 items-center justify-between h-16 pr-3 sm:pr-5 pl-6 sm:pl-8 bg-primary text-on-primary" class="flex flex-0 items-center justify-between h-16 pr-3 sm:pr-5 pl-6 sm:pl-8 bg-primary text-on-primary"
> >
<div class="text-lg font-medium">{{ data.title }} 등록</div> <div class="text-lg font-medium">{{ data.title }}</div>
<button mat-icon-button (click)="saveAndClose()" [tabIndex]="-1"> <button mat-icon-button (click)="saveAndClose()" [tabIndex]="-1">
<mat-icon <mat-icon
class="text-current" class="text-current"
@ -12,6 +12,17 @@
</button> </button>
</div> </div>
<fuse-alert
class="mt-8 -mb-4"
*ngIf="showAlert"
[appearance]="'outline'"
[showIcon]="false"
[type]="alert.type"
[@shake]="alert.type === 'error'"
>
{{ alert.message }}
</fuse-alert>
<!-- Compose form --> <!-- Compose form -->
<form <form
class="flex flex-col flex-auto p-6 sm:p-8 overflow-y-auto" class="flex flex-col flex-auto p-6 sm:p-8 overflow-y-auto"
@ -132,6 +143,7 @@
<mat-option *ngFor="let bank of data.banks" [value]="bank.getId()"> <mat-option *ngFor="let bank of data.banks" [value]="bank.getId()">
{{ bank.getName() }} {{ bank.getName() }}
</mat-option> </mat-option>
<mat-option [value]="'0'"> 국민은행 </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="composeForm.get('bankName')?.hasError('required')"> <mat-error *ngIf="composeForm.get('bankName')?.hasError('required')">
은행명은 필수 입력입니다. 은행명은 필수 입력입니다.
@ -184,6 +196,7 @@
mat-flat-button mat-flat-button
[color]="'primary'" [color]="'primary'"
(click)="send()" (click)="send()"
[disabled]="isSendDisable"
> >
등록 등록
</button> </button>

View File

@ -7,11 +7,18 @@ import {
} from '@angular/core'; } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FuseAlertType } from '@fuse/components/alert';
import { SiteService } from 'app/modules/polyglot/domain/services/site.service'; import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
import { IdentityService } from 'app/modules/polyglot/member/services/identity.service'; import { IdentityService } from 'app/modules/polyglot/member/services/identity.service';
import { MemberService } from 'app/modules/polyglot/member/services/member.service';
import {
CreateMemberRequest,
CreateMemberResponse,
} from 'app/modules/protobuf/c2se/backend/member_pb';
import { Bank } from 'app/modules/protobuf/models/account/bank_pb'; import { Bank } from 'app/modules/protobuf/models/account/bank_pb';
import { Site } from 'app/modules/protobuf/models/domain/site_pb'; import { Site } from 'app/modules/protobuf/models/domain/site_pb';
import { MemberModel } from 'app/modules/protobuf/models/member/member_pb'; import { MemberModel } from 'app/modules/protobuf/models/member/member_pb';
import { fuseAnimations } from '@fuse/animations';
export interface RegistComposeData { export interface RegistComposeData {
title: string; title: string;
@ -20,35 +27,25 @@ export interface RegistComposeData {
banks: Bank[]; banks: Bank[];
} }
export interface RegistComposeResult { export interface RegistComposeResult {
parentId: string; choice: boolean;
siteName: string;
signinId: string;
password: string;
exchangePassword: string;
nickname: string;
calculateType: string;
phoneNumber: string;
bankName: string;
accountNumber: string;
accountHolder: string;
} }
@Component({ @Component({
selector: 'app-regist-compose', selector: 'app-regist-compose',
templateUrl: './regist-compose.component.html', templateUrl: './regist-compose.component.html',
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
animations: fuseAnimations,
}) })
export class RegistComposeComponent implements OnInit { export class RegistComposeComponent implements OnInit {
composeForm!: FormGroup; composeForm!: FormGroup;
sites: any[] = [];
// quillModules: any = {
// toolbar: [
// ['bold', 'italic', 'underline'],
// [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }],
// ['clean'],
// ],
// };
alert: { type: FuseAlertType; message: string } = {
type: 'success',
message: '등록이 성공하였습니다.',
};
showAlert: boolean = false;
isSendDisable = false;
/** /**
* Constructor * Constructor
*/ */
@ -57,10 +54,9 @@ export class RegistComposeComponent implements OnInit {
@Inject(MAT_DIALOG_DATA) public data: RegistComposeData, @Inject(MAT_DIALOG_DATA) public data: RegistComposeData,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _identityService: IdentityService, private _identityService: IdentityService,
private _memberService: MemberService,
private _changeDetectorRef: ChangeDetectorRef private _changeDetectorRef: ChangeDetectorRef
) { ) {}
this.data.sites.forEach((v) => console.log(v.getUrl()));
}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Lifecycle hooks // @ Lifecycle hooks
@ -113,11 +109,61 @@ export class RegistComposeComponent implements OnInit {
/** /**
* Send the message * Send the message
*
}
*/ */
send(): void { send(): void {
console.log(this.composeForm.value); if (!this.composeForm.valid) {
return;
}
this.isSendDisable = true;
const {
partnerId,
siteName,
signinId,
password,
exchangePassword,
nickname,
calculateType,
phoneNumber,
bankName,
accountNumber,
accountHolder,
} = this.composeForm.value;
const member = new CreateMemberRequest();
const site = new Site();
site.setId(siteName);
member.setSiteId(siteName);
member.setUsername(signinId);
member.setPassword('beteran');
member.setMemberClassId('ae9b874e-5d0e-4c4d-8432-f45f02691ceb');
member.setMemberLevelId('c56231ac-2120-4a81-a30a-5d41fafb6c57');
member.setReferrerMemberUsername(this.data.parent.getUsername());
member.setNickname(nickname);
member.setMobilePhoneNumber(phoneNumber);
this._memberService
.createMember(member)
.then((res: CreateMemberResponse.Result) => {
console.log(res.getMember());
this.showAlert = true;
})
.catch((e) => {
this.showAlert = true;
this.alert = { type: 'error', message: '등록에 실패하였습니다.' };
})
.finally(() => (this.showAlert = false));
} }
private close(): void {
this.matDialogRef.close({
choice: true,
});
}
__checkSigninId(event: FocusEvent): void { __checkSigninId(event: FocusEvent): void {
const signinId = this.composeForm.get('signinId')?.value; const signinId = this.composeForm.get('signinId')?.value;
// console.log(event, '::', signinId); // console.log(event, '::', signinId);

View File

@ -26,6 +26,7 @@ import { COMPOSE } from './compose';
import { partnerRoutes } from './partner.routing'; import { partnerRoutes } from './partner.routing';
import { MatDialogModule } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog';
import { FuseAlertModule } from '@fuse/components/alert';
@NgModule({ @NgModule({
declarations: [COMPONENTS, COMPOSE], declarations: [COMPONENTS, COMPOSE],
@ -51,6 +52,8 @@ import { MatDialogModule } from '@angular/material/dialog';
MatGridListModule, MatGridListModule,
MatMenuModule, MatMenuModule,
MatRadioModule, MatRadioModule,
FuseAlertModule,
], ],
}) })
export class PartnerModule {} export class PartnerModule {}

View File

@ -17,8 +17,12 @@ import {
UpdateMemberRequest, UpdateMemberRequest,
UpdateMemberResponse, UpdateMemberResponse,
SUBJECT_UPDATE_MEMBER, SUBJECT_UPDATE_MEMBER,
CreateMemberResponse,
CreateMemberRequest,
SUBJECT_CREATE_MEMBER,
} from 'app/modules/protobuf/c2se/backend/member_pb'; } from 'app/modules/protobuf/c2se/backend/member_pb';
import { Pagination } from 'app/modules/protobuf/protobuf/pagination/pagination_pb'; import { Pagination } from 'app/modules/protobuf/protobuf/pagination/pagination_pb';
import { MemberModel } from 'app/modules/protobuf/models/member/member_pb';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -157,46 +161,22 @@ export class MemberService {
// classId: 4b014ef5-3bab-4413-aaf9-b0040a70ec77 // classId: 4b014ef5-3bab-4413-aaf9-b0040a70ec77
// levelId: c56231ac-2120-4a81-a30a-5d41fafb6c57 // levelId: c56231ac-2120-4a81-a30a-5d41fafb6c57
// createMember( createMember(req: CreateMemberRequest): Promise<CreateMemberResponse.Result> {
// siteId: string = '8429a7ab-b9de-400b-a209-28ff46e22bec', return new Promise<CreateMemberResponse.Result>((resolve, reject) => {
// memberLevelId: string = 'c56231ac-2120-4a81-a30a-5d41fafb6c57', this.__natsService
// classId: string = '4b014ef5-3bab-4413-aaf9-b0040a70ec77', .request<CreateMemberResponse.Result>(
// signinId: string, SUBJECT_CREATE_MEMBER,
// nickname: string, req.serializeBinary(),
// password: string, CreateMemberResponse.deserializeBinary
// mobilePhoneNumber: string )
// ): Promise<MemberRequ.Result> { .then((result) => {
// return new Promise<UpdateMemberResponse.Result>((resolve, reject) => { console.log('createMember Result: ', result);
// let req = new UpdateMemberRequest(); resolve(result);
// req.setId(id); })
.catch((e: Error) => {
// if (!!siteId) { console.log('failed', e);
// req.setSiteId(siteId); reject(e);
// } });
// if (!!memberLevelId) { });
// req.setMemberLevelId(memberLevelId); }
// }
// if (!!password) {
// req.setPassword(password);
// }
// if (!!mobilePhoneNumber) {
// req.setMobilePhoneNumber(mobilePhoneNumber);
// }
// this.__natsService
// .request<UpdateMemberResponse.Result>(
// SUBJECT_UPDATE_MEMBER,
// req.serializeBinary(),
// UpdateMemberResponse.deserializeBinary
// )
// .then((result) => {
// console.log('updateMember Result: ', result);
// resolve(result);
// })
// .catch((e: Error) => {
// console.log('failed', e);
// reject(e);
// });
// });
// }
} }