From 83e29c172be71f44fc9be1d6ab374c121bbf508b Mon Sep 17 00:00:00 2001 From: leejinho Date: Thu, 19 Dec 2019 18:08:16 +0900 Subject: [PATCH] =?UTF-8?q?[=EB=8C=80=EC=83=81=ED=96=A5]=20=EC=9B=B9?= =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EA=B2=B0=EC=9E=AC=20=EC=B9=B4=EC=9A=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=B2=98=EB=A6=AC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../native/components/top-bar.component.ts | 7 +--- .../src/lib/apis/api.ts | 36 +++++++++++++++---- .../src/lib/services/daesang-api.service.ts | 11 ++++-- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts index 1681bb6b..41b79a3f 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts @@ -245,12 +245,7 @@ export class TopBarComponent implements OnInit, OnDestroy { this.nativeService.openDefaultBrowser(url); } getShowWebLinkbadge(link: WebLink): boolean { - const showType = [ - 'WebLinkMail', - 'WebLinkMailCnt', - 'WebLinkPayment', - 'WebLinkPaymentCnt' - ]; + const showType = ['WebLinkMail', 'WebLinkPayment']; if (showType.indexOf(link.key) > -1) { return false; diff --git a/projects/ucap-webmessenger-daesang/src/lib/apis/api.ts b/projects/ucap-webmessenger-daesang/src/lib/apis/api.ts index c9a1e1b3..14b5c357 100644 --- a/projects/ucap-webmessenger-daesang/src/lib/apis/api.ts +++ b/projects/ucap-webmessenger-daesang/src/lib/apis/api.ts @@ -9,12 +9,6 @@ export const decodeMailCount: APIDecoder = (res: any) => { const domParser = new DOMParser(); const dom: Document = domParser.parseFromString(res, 'text/xml'); - let systemName = ''; - const systemNameDom: HTMLCollection = dom.getElementsByTagName('COUNT'); - if (!!systemNameDom && systemNameDom.length > 0) { - systemName = systemNameDom[0].textContent; - } - let count = 0; const countDom: HTMLCollection = dom.getElementsByTagName('COUNT'); if (!!countDom && countDom.length > 0) { @@ -24,7 +18,35 @@ export const decodeMailCount: APIDecoder = (res: any) => { : 0; } return { - systemName, + systemName: 'mailCount', count } as MailCountResponse; }; + +export interface PaymentCountResponse { + systemName: string; + count: number; +} + +export const decodePaymentCount: APIDecoder = ( + res: any +) => { + const domParser = new DOMParser(); + const dom: Document = domParser.parseFromString(res, 'text/xml'); + + let count = 0; + const viewentriesDom: HTMLCollection = dom.getElementsByTagName( + 'viewentries' + ); + if (!!viewentriesDom && viewentriesDom.length > 0) { + count = + viewentriesDom[0].getAttribute('toplevelentries').trim().length > 0 + ? Number(viewentriesDom[0].getAttribute('toplevelentries').trim()) + : 0; + } + + return { + systemName: 'paymentCount', + count + } as PaymentCountResponse; +}; diff --git a/projects/ucap-webmessenger-daesang/src/lib/services/daesang-api.service.ts b/projects/ucap-webmessenger-daesang/src/lib/services/daesang-api.service.ts index f93e7afe..e168053c 100644 --- a/projects/ucap-webmessenger-daesang/src/lib/services/daesang-api.service.ts +++ b/projects/ucap-webmessenger-daesang/src/lib/services/daesang-api.service.ts @@ -5,7 +5,12 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { NGXLogger } from 'ngx-logger'; -import { decodeMailCount, MailCountResponse } from '../apis/api'; +import { + decodeMailCount, + MailCountResponse, + decodePaymentCount, + PaymentCountResponse +} from '../apis/api'; @Injectable({ providedIn: 'root' @@ -19,9 +24,9 @@ export class DaesangApiService { .pipe(map(res => decodeMailCount(res))); } - public retrievePaymentCount(url: string): Observable { + public retrievePaymentCount(url: string): Observable { return this.httpClient .post(url, {}, {}) - .pipe(map(res => decodeMailCount(res))); + .pipe(map(res => decodePaymentCount(res))); } }