From 119ebac6ed236e4a359ac780348d0f1e684dd15c Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Wed, 10 Aug 2022 08:05:23 +0000 Subject: [PATCH] MemberService is added --- .../partner/components/list.component.ts | 2 + .../modules/polyglot/member/services/index.ts | 3 +- .../member/services/member.service.ts | 100 ++++++++++++++++++ .../protobuf/c2se/backend/member_pb.d.ts | 6 ++ .../protobuf/c2se/backend/member_pb.js | 8 ++ 5 files changed, 118 insertions(+), 1 deletion(-) diff --git a/src/app/modules/admin/member/partner/components/list.component.ts b/src/app/modules/admin/member/partner/components/list.component.ts index b64aed4..4a8429d 100644 --- a/src/app/modules/admin/member/partner/components/list.component.ts +++ b/src/app/modules/admin/member/partner/components/list.component.ts @@ -38,6 +38,7 @@ import { RegistComposeComponent } from '../compose/regist-compose.component'; import { MatDialog } from '@angular/material/dialog'; import { SiteService } from 'app/modules/polyglot/domain/services/site.service'; import { Site } from 'app/modules/protobuf/models/domain/site_pb'; +import { MembeerService } from 'app/modules/polyglot/member/services/member.service'; @Component({ selector: 'partner-list', templateUrl: './list.component.html', @@ -91,6 +92,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { private _fuseConfirmationService: FuseConfirmationService, private _formBuilder: FormBuilder, private _partnerService: PartnerService, + private __memberService: MembeerService, private _siteService: SiteService, private router: Router, private _matDialog: MatDialog diff --git a/src/app/modules/polyglot/member/services/index.ts b/src/app/modules/polyglot/member/services/index.ts index ffc107a..654ad70 100644 --- a/src/app/modules/polyglot/member/services/index.ts +++ b/src/app/modules/polyglot/member/services/index.ts @@ -1,5 +1,6 @@ import { Type } from '@angular/core'; import { IdentityService } from './identity.service'; +import { MembeerService } from './member.service'; -export const SERVICES: Type[] = [IdentityService]; +export const SERVICES: Type[] = [IdentityService, MembeerService]; diff --git a/src/app/modules/polyglot/member/services/member.service.ts b/src/app/modules/polyglot/member/services/member.service.ts index e69de29..e91988a 100644 --- a/src/app/modules/polyglot/member/services/member.service.ts +++ b/src/app/modules/polyglot/member/services/member.service.ts @@ -0,0 +1,100 @@ +import { Injectable } from '@angular/core'; +import { NatsService } from 'app/core/nats/services/nats.service'; +import * as nats from 'nats.ws'; + +import { Error } from 'app/modules/protobuf/protobuf/rpc/error_pb'; + +import { + ListMembersRequest, + ListMembersResponse, + GetMemberByUsernameRequest, + GetMemberByUsernameResponse, + GetMemberRequest, + GetMemberResponse, + SUBJECT_LIST_MEMBERS, + SUBJECT_GET_MEMBER, + SUBJECT_GET_MEMBER_BY_USERNAME, +} from 'app/modules/protobuf/c2se/backend/member_pb'; + +@Injectable({ + providedIn: 'root', +}) +export class MembeerService { + /** + * Constructor + */ + constructor(private __natsService: NatsService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Accessors + // ----------------------------------------------------------------------------------------------------- + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + listMembers(): Promise { + return new Promise((resolve, reject) => { + let req = new ListMembersRequest(); + + this.__natsService + .request( + SUBJECT_LIST_MEMBERS, + req.serializeBinary(), + ListMembersResponse.deserializeBinary + ) + .then((result) => { + console.log('success', result, result.getMembersList()); + resolve(result); + }) + .catch((e: Error) => { + console.log('failed', e); + reject(e); + }); + }); + } + + getMember(id: string): Promise { + return new Promise((resolve, reject) => { + let req = new GetMemberRequest(); + req.setId(id); + + this.__natsService + .request( + SUBJECT_GET_MEMBER, + req.serializeBinary(), + GetMemberResponse.deserializeBinary + ) + .then((result) => { + console.log('success', result, result.getMember()); + resolve(result); + }) + .catch((e: Error) => { + console.log('failed', e); + reject(e); + }); + }); + } + + getMemberByUsername(): Promise { + return new Promise( + (resolve, reject) => { + let req = new GetMemberByUsernameRequest(); + + this.__natsService + .request( + SUBJECT_GET_MEMBER_BY_USERNAME, + req.serializeBinary(), + GetMemberByUsernameResponse.deserializeBinary + ) + .then((result) => { + resolve(result); + }) + .catch((e: Error) => { + console.log('failed', e); + reject(e); + }); + } + ); + } +} diff --git a/src/app/modules/protobuf/c2se/backend/member_pb.d.ts b/src/app/modules/protobuf/c2se/backend/member_pb.d.ts index 14b9021..bd4b725 100644 --- a/src/app/modules/protobuf/c2se/backend/member_pb.d.ts +++ b/src/app/modules/protobuf/c2se/backend/member_pb.d.ts @@ -8,6 +8,12 @@ import * as protobuf_pagination_search_pb from '../../protobuf/pagination/search import * as protobuf_pagination_sort_pb from '../../protobuf/pagination/sort_pb'; import * as models_member_member_pb from '../../models/member/member_pb'; +export const SUBJECT_LIST_MEMBERS: string; + +export const SUBJECT_GET_MEMBER: string; + +export const SUBJECT_GET_MEMBER_BY_USERNAME: string; + export class ListMembersRequest extends jspb.Message { hasPagination(): boolean; clearPagination(): void; diff --git a/src/app/modules/protobuf/c2se/backend/member_pb.js b/src/app/modules/protobuf/c2se/backend/member_pb.js index 4a07652..3746120 100644 --- a/src/app/modules/protobuf/c2se/backend/member_pb.js +++ b/src/app/modules/protobuf/c2se/backend/member_pb.js @@ -72,6 +72,14 @@ goog.exportSymbol( null, global ); + +proto.bet.beteran.c2se.backend.member.SUBJECT_LIST_MEMBERS = + "bet.beteran.c2se.backend.member.ListMembers"; +proto.bet.beteran.c2se.backend.member.SUBJECT_GET_MEMBER = + "bet.beteran.c2se.backend.member.GetMember"; +proto.bet.beteran.c2se.backend.member.SUBJECT_GET_MEMBER_BY_USERNAME = + "bet.beteran.c2se.backend.member.GetMemberByUsername"; + /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a