list_vendors is added

This commit is contained in:
병준 박 2022-08-18 07:14:27 +00:00
parent 72569d064f
commit 4b87710878
5 changed files with 85 additions and 0 deletions

View File

@ -31,6 +31,8 @@ import { MemberLevelModule } from 'app/modules/polyglot/member_level/member_leve
import { MemberModule } from 'app/modules/polyglot/member/member.module'; import { MemberModule } from 'app/modules/polyglot/member/member.module';
import { SiteModule } from 'app/modules/polyglot/site/site.module'; import { SiteModule } from 'app/modules/polyglot/site/site.module';
import { ApiModule } from 'app/modules/polyglot/api/api.module';
const routerConfig: ExtraOptions = { const routerConfig: ExtraOptions = {
preloadingStrategy: PreloadAllModules, preloadingStrategy: PreloadAllModules,
scrollPositionRestoration: 'enabled', scrollPositionRestoration: 'enabled',
@ -70,6 +72,8 @@ const routerConfig: ExtraOptions = {
MemberLevelModule.forRoot(), MemberLevelModule.forRoot(),
MemberModule.forRoot(), MemberModule.forRoot(),
SiteModule.forRoot(), SiteModule.forRoot(),
ApiModule.forRoot(),
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })

View File

@ -54,6 +54,7 @@ import {
ListMembersResponse, ListMembersResponse,
} from 'app/modules/proto/c2se/member_pb'; } from 'app/modules/proto/c2se/member_pb';
import { Pagination } from 'app/modules/proto/protobuf/pagination_pb'; import { Pagination } from 'app/modules/proto/protobuf/pagination_pb';
import { ApiService } from 'app/modules/polyglot/api/services/api.service';
@Component({ @Component({
selector: 'partner-list', selector: 'partner-list',
templateUrl: './list.component.html', templateUrl: './list.component.html',
@ -119,6 +120,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
private _activatedRoute: ActivatedRoute, private _activatedRoute: ActivatedRoute,
private _partnerService: PartnerService, private _partnerService: PartnerService,
private __memberService: MemberService, private __memberService: MemberService,
private __apiService: ApiService,
private router: Router, private router: Router,
private _matDialog: MatDialog private _matDialog: MatDialog
@ -190,6 +192,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
}); });
this.__apiService
.listBanks()
.then((l) => {
console.log('list', l.getVendorsList());
})
.catch((e) => {
console.log('error', e);
});
} }
/** /**

View File

@ -0,0 +1,16 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { SERVICES } from './services';
@NgModule({})
export class ApiRootModule {}
@NgModule({})
export class ApiModule {
public static forRoot(): ModuleWithProviders<ApiRootModule> {
return {
ngModule: ApiRootModule,
providers: [...SERVICES],
};
}
}

View File

@ -0,0 +1,49 @@
import { Injectable } from '@angular/core';
import { NatsService } from 'app/core/nats/services/nats.service';
import { Error } from 'app/modules/proto/protobuf/rpc_pb';
import {
ListVendorsRequest,
ListVendorsResponse,
} from 'app/modules/proto/c2se/api/vendor_pb';
import { SUBJECT_LIST_VENDORS } from 'app/modules/proto/c2se/backend/api/vendor_pb';
@Injectable({
providedIn: 'root',
})
export class ApiService {
/**
* Constructor
*/
constructor(private __natsService: NatsService) {}
// -----------------------------------------------------------------------------------------------------
// @ Accessors
// -----------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
listBanks(): Promise<ListVendorsResponse.Result> {
return new Promise<ListVendorsResponse.Result>((resolve, reject) => {
let req = new ListVendorsRequest();
this.__natsService
.request<ListVendorsResponse.Result>(
SUBJECT_LIST_VENDORS,
req.serializeBinary(),
ListVendorsResponse.deserializeBinary
)
.then((result) => {
console.log('success', result, result.getVendorsList());
return resolve(result);
})
.catch((e: Error) => {
console.log('failed', e);
reject(e);
});
});
}
}

View File

@ -0,0 +1,5 @@
import { Type } from '@angular/core';
import { ApiService } from './api.service';
export const SERVICES: Type<any>[] = [ApiService];