From 79f2c4250c3b9f59626008ba755545fcae6ed61f Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Fri, 12 Aug 2022 04:49:02 +0000 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=9B=90=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/components/view.component.html | 8 +- .../member/user/components/view.component.ts | 16 +++- .../member/services/member.service.ts | 91 +++++++++++++++++++ 3 files changed, 113 insertions(+), 2 deletions(-) diff --git a/src/app/modules/admin/member/user/components/view.component.html b/src/app/modules/admin/member/user/components/view.component.html index 3dd0443..6eb5c6b 100644 --- a/src/app/modules/admin/member/user/components/view.component.html +++ b/src/app/modules/admin/member/user/components/view.component.html @@ -478,7 +478,13 @@ An error occurred, try again! - + diff --git a/src/app/modules/admin/member/user/components/view.component.ts b/src/app/modules/admin/member/user/components/view.component.ts index 812d458..f4aee34 100644 --- a/src/app/modules/admin/member/user/components/view.component.ts +++ b/src/app/modules/admin/member/user/components/view.component.ts @@ -34,6 +34,7 @@ import { UserService } from '../services/user.service'; import { ActivatedRoute } from '@angular/router'; import { GetMemberResponse } from 'app/modules/protobuf/c2se/backend/member_pb'; import { MemberModel } from 'app/modules/protobuf/models/member/member_pb'; +import { MemberService } from 'app/modules/polyglot/member/services/member.service'; @Component({ selector: 'user-view', @@ -82,7 +83,8 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { private _changeDetectorRef: ChangeDetectorRef, private _fuseConfirmationService: FuseConfirmationService, private _formBuilder: FormBuilder, - private _userService: UserService + private _userService: UserService, + private _memberService: MemberService ) {} // ----------------------------------------------------------------------------------------------------- @@ -204,4 +206,16 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { __trackByFn(index: number, item: any): any { return item.id || index; } + + __modifyMember(): void { + const valueForm = this.memberViewForm.value; + console.log('v: ', valueForm); + this._memberService.updateMember( + this.selectedUser!.getId(), + this.selectedUser!.getSite()!.getId(), + this.selectedUser!.getMemberLevel()!.getId(), + 'beteran', + valueForm.phoneNumber + ); + } } diff --git a/src/app/modules/polyglot/member/services/member.service.ts b/src/app/modules/polyglot/member/services/member.service.ts index 09f6a8e..a694a0a 100644 --- a/src/app/modules/polyglot/member/services/member.service.ts +++ b/src/app/modules/polyglot/member/services/member.service.ts @@ -14,6 +14,9 @@ import { SUBJECT_LIST_MEMBERS, SUBJECT_GET_MEMBER, SUBJECT_GET_MEMBER_BY_USERNAME, + UpdateMemberRequest, + UpdateMemberResponse, + SUBJECT_UPDATE_MEMBER, } from 'app/modules/protobuf/c2se/backend/member_pb'; import { Pagination } from 'app/modules/protobuf/protobuf/pagination/pagination_pb'; @@ -108,4 +111,92 @@ export class MemberService { } ); } + + updateMember( + id: string, + siteId: string, + memberLevelId: string, + password: string, + mobilePhoneNumber: string + ): Promise { + return new Promise((resolve, reject) => { + let req = new UpdateMemberRequest(); + req.setId(id); + + if (!!siteId) { + req.setSiteId(siteId); + } + if (!!memberLevelId) { + req.setMemberLevelId(memberLevelId); + } + if (!!password) { + req.setPassword(password); + } + if (!!mobilePhoneNumber) { + req.setMobilePhoneNumber(mobilePhoneNumber); + } + + this.__natsService + .request( + 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); + }); + }); + } + + // siteId: 8429a7ab-b9de-400b-a209-28ff46e22bec + // classId: 4b014ef5-3bab-4413-aaf9-b0040a70ec77 + // levelId: c56231ac-2120-4a81-a30a-5d41fafb6c57 + + // createMember( + // siteId: string = '8429a7ab-b9de-400b-a209-28ff46e22bec', + // memberLevelId: string = 'c56231ac-2120-4a81-a30a-5d41fafb6c57', + // classId: string = '4b014ef5-3bab-4413-aaf9-b0040a70ec77', + // signinId: string, + // nickname: string, + // password: string, + // mobilePhoneNumber: string + // ): Promise { + // return new Promise((resolve, reject) => { + // let req = new UpdateMemberRequest(); + // req.setId(id); + + // if (!!siteId) { + // req.setSiteId(siteId); + // } + // if (!!memberLevelId) { + // req.setMemberLevelId(memberLevelId); + // } + // if (!!password) { + // req.setPassword(password); + // } + // if (!!mobilePhoneNumber) { + // req.setMobilePhoneNumber(mobilePhoneNumber); + // } + + // this.__natsService + // .request( + // 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); + // }); + // }); + // } }