루징 관리 기본 데이터 뷰 진행중

This commit is contained in:
Park Byung Eun 2022-08-03 06:52:00 +00:00
parent c7e45f48f0
commit a629f3bd95
10 changed files with 386 additions and 116 deletions

View File

@ -1,14 +1,17 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { assign, cloneDeep } from 'lodash-es'; import { assign, cloneDeep } from 'lodash-es';
import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api'; import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api';
import { loosings as loosingsData } from './data'; import {
loosings as loosingsData,
loosingReports as loosingReportsData,
} from './data';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class ReportLoosingMockApi { export class ReportLoosingMockApi {
private _loosings: any[] = loosingsData; private _loosings: any[] = loosingsData;
private _loosingReports: any[] = loosingReportsData;
/** /**
* Constructor * Constructor
*/ */
@ -106,13 +109,13 @@ export class ReportLoosingMockApi {
const id = request.params.get('id'); const id = request.params.get('id');
// Clone the loosings // Clone the loosings
const loosings = cloneDeep(this._loosings); const loosingReports = cloneDeep(this._loosingReports);
// Find the loosing // Find the loosing
const loosing = loosings.find((item: any) => item.id === id); // const loosing = loosings.find((item: any) => item.id === id);
// Return the response // Return the response
return [200, loosing]; return [200, loosingReports];
}); });
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
export const loosings = [ export const loosings = [
{ {
id: '1', id: 'loosing_1',
startDate: '2022-06-01 15:38', startDate: '2022-06-01 15:38',
endDate: '2022-06-12 15:38', endDate: '2022-06-12 15:38',
registDate: '2022-06-12 15:38', registDate: '2022-06-12 15:38',
@ -10,7 +10,7 @@ export const loosings = [
loosingCount: '15', loosingCount: '15',
}, },
{ {
id: '2', id: 'loosing_2',
startDate: '2022-06-01 15:38', startDate: '2022-06-01 15:38',
endDate: '2022-06-12 15:38', endDate: '2022-06-12 15:38',
registDate: '2022-06-12 15:38', registDate: '2022-06-12 15:38',
@ -18,7 +18,7 @@ export const loosings = [
loosingCount: '16', loosingCount: '16',
}, },
{ {
id: '3', id: 'loosing_3',
startDate: '2022-06-01 15:38', startDate: '2022-06-01 15:38',
endDate: '2022-06-12 15:38', endDate: '2022-06-12 15:38',
registDate: '2022-06-12 15:38', registDate: '2022-06-12 15:38',
@ -26,3 +26,222 @@ export const loosings = [
loosingCount: '11', loosingCount: '11',
}, },
]; ];
export const loosingReports = [
{
id: 'lossingReports_1',
parentId: '0',
signinId: 'kgon1',
code: 'AAA',
depth: 0,
rank: '본사',
casinoReport: {
id: '1',
betMoneny: '123,000',
betTieMoneny: '6,000',
betCancelMoneny: '0',
validMoneny: '117,000',
betWinMoneny: '121,900',
betWinLossMoneny: '1,100',
rollingMoney: '2,340',
rollingBottomMoney: '1,755',
rollingMeMoney: '585',
loosingRate: '50%',
meMoney: '-620',
},
slotReport: {
id: '2',
betMoneny: '75,400',
betTieMoneny: '',
betCancelMoneny: '',
validMoneny: '',
betWinMoneny: '181,100',
betWinLossMoneny: '-105,700',
rollingMoney: '3,770',
rollingBottomMoney: '1,659',
rollingMeMoney: '2,111',
loosingRate: '50%',
meMoney: '-54,735',
},
},
{
id: 'lossingReports_2',
parentId: 'lossingReports_1',
signinId: 'kgon2',
code: 'AAAAA',
depth: 1,
rank: '대본',
casinoReport: {
id: '1',
betMoneny: '123,000',
betTieMoneny: '6,000',
betCancelMoneny: '0',
validMoneny: '117,000',
betWinMoneny: '121,900',
betWinLossMoneny: '1,100',
rollingMoney: '2,340',
rollingBottomMoney: '1,755',
rollingMeMoney: '585',
loosingRate: '50%',
meMoney: '-620',
},
slotReport: {
id: '2',
betMoneny: '75,400',
betTieMoneny: '',
betCancelMoneny: '',
validMoneny: '',
betWinMoneny: '181,100',
betWinLossMoneny: '-105,700',
rollingMoney: '3,770',
rollingBottomMoney: '1,659',
rollingMeMoney: '2,111',
loosingRate: '50%',
meMoney: '-54,735',
},
},
{
id: 'lossingReports_3',
parentId: 'lossingReports_2',
signinId: 'kgon2',
code: 'AAAAA',
depth: 1,
rank: '부본',
casinoReport: {
id: '3',
betMoneny: '123,000',
betTieMoneny: '6,000',
betCancelMoneny: '0',
validMoneny: '117,000',
betWinMoneny: '121,900',
betWinLossMoneny: '1,100',
rollingMoney: '2,340',
rollingBottomMoney: '1,755',
rollingMeMoney: '585',
loosingRate: '50%',
meMoney: '-620',
},
slotReport: {
id: '4',
betMoneny: '75,400',
betTieMoneny: '',
betCancelMoneny: '',
validMoneny: '',
betWinMoneny: '181,100',
betWinLossMoneny: '-105,700',
rollingMoney: '3,770',
rollingBottomMoney: '1,659',
rollingMeMoney: '2,111',
loosingRate: '50%',
meMoney: '-54,735',
},
},
{
id: 'lossingReports_4',
parentId: '0',
signinId: 'test1',
code: 'AAAB',
depth: 0,
rank: '본사',
casinoReport: {
id: '1',
betMoneny: '123,000',
betTieMoneny: '6,000',
betCancelMoneny: '0',
validMoneny: '117,000',
betWinMoneny: '121,900',
betWinLossMoneny: '1,100',
rollingMoney: '2,340',
rollingBottomMoney: '1,755',
rollingMeMoney: '585',
loosingRate: '50%',
meMoney: '-620',
},
slotReport: {
id: '2',
betMoneny: '75,400',
betTieMoneny: '',
betCancelMoneny: '',
validMoneny: '',
betWinMoneny: '181,100',
betWinLossMoneny: '-105,700',
rollingMoney: '3,770',
rollingBottomMoney: '1,659',
rollingMeMoney: '2,111',
loosingRate: '50%',
meMoney: '-54,735',
},
},
{
id: 'lossingReports_5',
parentId: 'lossingReports_4',
signinId: 'kgon2',
code: 'AAAAA',
depth: 1,
rank: '대본',
casinoReport: {
id: '1',
betMoneny: '123,000',
betTieMoneny: '6,000',
betCancelMoneny: '0',
validMoneny: '117,000',
betWinMoneny: '121,900',
betWinLossMoneny: '1,100',
rollingMoney: '2,340',
rollingBottomMoney: '1,755',
rollingMeMoney: '585',
loosingRate: '50%',
meMoney: '-620',
},
slotReport: {
id: '2',
betMoneny: '75,400',
betTieMoneny: '',
betCancelMoneny: '',
validMoneny: '',
betWinMoneny: '181,100',
betWinLossMoneny: '-105,700',
rollingMoney: '3,770',
rollingBottomMoney: '1,659',
rollingMeMoney: '2,111',
loosingRate: '50%',
meMoney: '-54,735',
},
},
{
id: 'lossingReports_6',
parentId: 'lossingReports_5',
signinId: 'kgon2',
code: 'AAAAA',
depth: 1,
rank: '부본',
casinoReport: {
id: '3',
betMoneny: '123,000',
betTieMoneny: '6,000',
betCancelMoneny: '0',
validMoneny: '117,000',
betWinMoneny: '121,900',
betWinLossMoneny: '1,100',
rollingMoney: '2,340',
rollingBottomMoney: '1,755',
rollingMeMoney: '585',
loosingRate: '50%',
meMoney: '-620',
},
slotReport: {
id: '4',
betMoneny: '75,400',
betTieMoneny: '',
betCancelMoneny: '',
validMoneny: '',
betWinMoneny: '181,100',
betWinLossMoneny: '-105,700',
rollingMoney: '3,770',
rollingBottomMoney: '1,659',
rollingMeMoney: '2,111',
loosingRate: '50%',
meMoney: '-54,735',
},
},
];

View File

@ -46,27 +46,41 @@
[dataSource]="loosingDataSource" [dataSource]="loosingDataSource"
> >
<!-- 아이디 --> <!-- 아이디 -->
<ng-container matColumnDef="userId">
<th
mat-header-cell
*matHeaderCellDef
[ngStyle]="{ display: 'none' }"
></th>
<td mat-cell *matCellDef="let info; let i = index">
<span class="font-medium text-right">
{{ info.signinId }}
</span>
</td>
</ng-container>
<ng-container matColumnDef="signinId"> <ng-container matColumnDef="signinId">
<th mat-header-cell *matHeaderCellDef [attr.rowspan]="2"> <th mat-header-cell *matHeaderCellDef [attr.rowspan]="2">
아이디 아이디
</th> </th>
<td mat-cell *matCellDef="let info; let i = index">
<span class="font-medium text-right">
{{ i + 1 }}
</span>
</td>
</ng-container> </ng-container>
<!-- 코드 --> <!-- 코드 -->
<ng-container matColumnDef="userCode">
<th
mat-header-cell
*matHeaderCellDef
[ngStyle]="{ display: 'none' }"
></th>
<td mat-cell *matCellDef="let info">
<span class="font-medium text-right">
{{ info.code }}
</span>
</td>
</ng-container>
<ng-container matColumnDef="code"> <ng-container matColumnDef="code">
<th mat-header-cell *matHeaderCellDef [attr.rowspan]="2"> <th mat-header-cell *matHeaderCellDef [attr.rowspan]="2">
코드 코드
</th> </th>
<td mat-cell *matCellDef="let info">
<span class="font-medium text-right">
{{ info.startDate }}
</span>
</td>
</ng-container> </ng-container>
<!-- 카지노루징 시작--> <!-- 카지노루징 시작-->
@ -75,7 +89,13 @@
<th mat-header-cell *matHeaderCellDef>베팅</th> <th mat-header-cell *matHeaderCellDef>베팅</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right"> <span class="font-medium text-right">
{{ info.endDate }} {{ info.casinoReport.betMoneny }}
<hr style="margin: 7px 0px" />
{{ info.casinoReport.betTieMoneny }}
<hr style="margin: 7px 0px" />
{{ info.casinoReport.betCancelMoneny }}
<hr style="margin: 7px 0px" />
{{ info.casinoReport.validMoneny }}
</span> </span>
</td> </td>
</ng-container> </ng-container>
@ -85,7 +105,7 @@
<th mat-header-cell *matHeaderCellDef>당첨</th> <th mat-header-cell *matHeaderCellDef>당첨</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.defaultCount info.casinoReport.betWinMoneny
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
@ -95,7 +115,7 @@
<th mat-header-cell *matHeaderCellDef>윈로스</th> <th mat-header-cell *matHeaderCellDef>윈로스</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.loosingCount info.casinoReport.betWinLossMoneny
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
@ -104,9 +124,13 @@
<ng-container matColumnDef="casinoRolling"> <ng-container matColumnDef="casinoRolling">
<th mat-header-cell *matHeaderCellDef>롤링</th> <th mat-header-cell *matHeaderCellDef>롤링</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">
info.loosingCount {{ info.casinoReport.rollingMoney }}
}}</span> <hr style="margin: 7px 0px" />
{{ info.casinoReport.rollingBottomMoney }}
<hr style="margin: 7px 0px" />
{{ info.casinoReport.rollingMeMoney }}
</span>
</td> </td>
</ng-container> </ng-container>
@ -115,7 +139,7 @@
<th mat-header-cell *matHeaderCellDef>루징요율</th> <th mat-header-cell *matHeaderCellDef>루징요율</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.loosingCount info.casinoReport.loosingRate
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
@ -124,7 +148,7 @@
<th mat-header-cell *matHeaderCellDef>본인</th> <th mat-header-cell *matHeaderCellDef>본인</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.loosingCount info.casinoReport.meMoney
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
@ -133,10 +157,16 @@
<!-- 슬롯루징 시작--> <!-- 슬롯루징 시작-->
<!-- 베팅 --> <!-- 베팅 -->
<ng-container matColumnDef="slotBet"> <ng-container matColumnDef="slotBet">
<th mat-header-cell *matHeaderCellDef>베팅</th> <th
mat-header-cell
*matHeaderCellDef
style="border-left: 1px solid #e0e0e0; padding-left: 30px"
>
베팅
</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right"> <span class="font-medium text-right">
{{ info.endDate }} {{ info.slotReport.betMoneny }}
</span> </span>
</td> </td>
</ng-container> </ng-container>
@ -146,7 +176,7 @@
<th mat-header-cell *matHeaderCellDef>당첨</th> <th mat-header-cell *matHeaderCellDef>당첨</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.defaultCount info.slotReport.betWinMoneny
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
@ -156,7 +186,7 @@
<th mat-header-cell *matHeaderCellDef>윈로스</th> <th mat-header-cell *matHeaderCellDef>윈로스</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.loosingCount info.slotReport.betWinLossMoneny
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
@ -165,9 +195,13 @@
<ng-container matColumnDef="slotRolling"> <ng-container matColumnDef="slotRolling">
<th mat-header-cell *matHeaderCellDef>롤링</th> <th mat-header-cell *matHeaderCellDef>롤링</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">
info.loosingCount {{ info.slotReport.rollingMoney }}
}}</span> <hr style="margin: 7px 0px" />
{{ info.slotReport.rollingBottomMoney }}
<hr style="margin: 7px 0px" />
{{ info.slotReport.rollingMeMoney }}
</span>
</td> </td>
</ng-container> </ng-container>
@ -176,7 +210,7 @@
<th mat-header-cell *matHeaderCellDef>루징요율</th> <th mat-header-cell *matHeaderCellDef>루징요율</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.loosingCount info.slotReport.loosingRate
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
@ -185,22 +219,47 @@
<th mat-header-cell *matHeaderCellDef>본인</th> <th mat-header-cell *matHeaderCellDef>본인</th>
<td mat-cell *matCellDef="let info"> <td mat-cell *matCellDef="let info">
<span class="font-medium text-right">{{ <span class="font-medium text-right">{{
info.loosingCount info.slotReport.meMoney
}}</span> }}</span>
</td> </td>
</ng-container> </ng-container>
<!-- 슬롯루징 끝--> <!-- 슬롯루징 끝-->
<!-- Star Column -->
<!-- <ng-container matColumnDef="star" stickyEnd>
<th
mat-header-cell
*matHeaderCellDef
aria-label="row actions"
[attr.rowspan]="2"
style="border-left: 1px solid #e0e0e0; padding-left: 30px"
>
&nbsp;
</th>
<td mat-cell *matCellDef="let element">
<mat-icon>more_vert</mat-icon>
</td>
</ng-container> -->
<!-- Header row second group --> <!-- Header row second group -->
<ng-container matColumnDef="header-row-casino-group"> <ng-container matColumnDef="header-row-casino-group">
<th mat-header-cell *matHeaderCellDef [attr.colspan]="6"> <th
mat-header-cell
*matHeaderCellDef
[attr.colspan]="6"
style="text-align: center"
>
카지노루징 카지노루징
</th> </th>
</ng-container> </ng-container>
<!-- Header row second group --> <!-- Header row second group -->
<ng-container matColumnDef="header-row-slot-group"> <ng-container matColumnDef="header-row-slot-group">
<th mat-header-cell *matHeaderCellDef [attr.colspan]="6"> <th
mat-header-cell
*matHeaderCellDef
[attr.colspan]="6"
style="text-align: center; border-left: 1px solid #e0e0e0"
>
슬롯루징 슬롯루징
</th> </th>
</ng-container> </ng-container>

View File

@ -20,6 +20,7 @@ import { Loosing } from '../models/loosing';
import { LoosingService } from '../services/loosing.service'; import { LoosingService } from '../services/loosing.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { LoosingReport } from '../models/loosing-report';
@Component({ @Component({
selector: 'loosing-view', selector: 'loosing-view',
@ -60,16 +61,9 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
private _unsubscribeAll: Subject<any> = new Subject<any>(); private _unsubscribeAll: Subject<any> = new Subject<any>();
headerTableColumns: string[] = [
'index',
'startDate',
'endDate',
'defaultDataTotalCount',
'loosingDataTotalCount',
'removeBtn',
];
displayedTableColumns: string[] = [ displayedTableColumns: string[] = [
'userId',
'userCode',
'casinoBet', 'casinoBet',
'casinoWin', 'casinoWin',
'casinoWinLoss', 'casinoWinLoss',
@ -103,14 +97,14 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
*/ */
ngOnInit(): void { ngOnInit(): void {
// Get the products // Get the products
this._loosingService.loosings$ this._loosingService.loosing$
.pipe(takeUntil(this._unsubscribeAll)) .pipe(takeUntil(this._unsubscribeAll))
.subscribe((loosings: Loosing[] | undefined) => { .subscribe((loosingReport: LoosingReport[] | undefined) => {
if (!loosings) { if (!loosingReport) {
return; return;
} }
this.loosingDataSource.data = loosings; this.loosingDataSource.data = loosingReport;
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
}); });

View File

@ -19,8 +19,8 @@ export const loosingRoutes: Route[] = [
{ {
path: ':id', path: ':id',
component: ViewComponent, component: ViewComponent,
// resolve: { resolve: {
// loosing: LoosingResolver, loosing: LoosingResolver,
// }, },
}, },
]; ];

View File

@ -0,0 +1,14 @@
export interface BetCalculate {
id: string;
betMoneny?: string;
betTieMoneny?: string;
betCancelMoneny?: string;
validMoneny?: string;
betWinMoneny?: string;
betWinLossMoneny?: string;
rollingMoney?: string;
rollingBottomMoney?: string;
rollingMeMoney?: string;
loosingRate?: string;
meMoney?: string;
}

View File

@ -0,0 +1,12 @@
import { BetCalculate } from './bet-calculate';
export interface LoosingReport {
id: string;
parentId: string;
signinId?: string;
code?: string;
depth?: number;
rank?: string;
casinoCalculate?: BetCalculate;
slotCalculate?: BetCalculate;
}

View File

@ -1,33 +1,7 @@
export interface Loosing { export interface Loosing {
id?: string; id?: string;
totalPartnerCount?: number; signinId?: string;
totalHoldingMoney?: number;
totalComp?: number;
total?: number;
branchCount?: number;
divisionCount?: number;
officeCount?: number;
storeCount?: number;
memberCount?: number;
nickname?: string;
accountHolder?: string;
phoneNumber?: string;
calculateType?: string;
ownCash?: number;
ownComp?: number;
ownCoupon?: number;
gameMoney?: number;
todayComp?: number;
totalDeposit?: number;
totalWithdraw?: number;
balance?: number;
startDate?: string; startDate?: string;
endDate?: string; endDate?: string;
registDate?: string; registDate?: string;
defaultCount?: string;
loosingCount?: string;
finalSigninDate?: string;
ip?: string;
state?: string;
note?: string;
} }

View File

@ -9,6 +9,7 @@ import { catchError, Observable, throwError } from 'rxjs';
import { Loosing } from '../models/loosing'; import { Loosing } from '../models/loosing';
import { LoosingPagination } from '../models/loosing-pagination'; import { LoosingPagination } from '../models/loosing-pagination';
import { LoosingReport } from '../models/loosing-report';
import { LoosingService } from '../services/loosing.service'; import { LoosingService } from '../services/loosing.service';
@Injectable({ @Injectable({
@ -36,23 +37,25 @@ export class LoosingResolver implements Resolve<any> {
resolve( resolve(
route: ActivatedRouteSnapshot, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot state: RouterStateSnapshot
): Observable<Loosing | undefined> { ): Observable<LoosingReport[] | undefined> {
return this._loosingService.getLoosingById(route.paramMap.get('id')).pipe( return this._loosingService
// Error here means the requested product is not available .getLoosingById(route.paramMap.get('id') as string)
catchError((error) => { .pipe(
// Log the error // Error here means the requested product is not available
console.error(error); catchError((error) => {
// Log the error
console.error(error);
// Get the parent url // Get the parent url
const parentUrl = state.url.split('/').slice(0, -1).join('/'); const parentUrl = state.url.split('/').slice(0, -1).join('/');
// Navigate to there // Navigate to there
this._router.navigateByUrl(parentUrl); this._router.navigateByUrl(parentUrl);
// Throw an error // Throw an error
return throwError(error); return throwError(error);
}) })
); );
} }
} }

View File

@ -14,6 +14,7 @@ import {
import { Loosing } from '../models/loosing'; import { Loosing } from '../models/loosing';
import { LoosingPagination } from '../models/loosing-pagination'; import { LoosingPagination } from '../models/loosing-pagination';
import { LoosingReport } from '../models/loosing-report';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -23,7 +24,9 @@ export class LoosingService {
private __pagination = new BehaviorSubject<LoosingPagination | undefined>( private __pagination = new BehaviorSubject<LoosingPagination | undefined>(
undefined undefined
); );
private __loosing = new BehaviorSubject<Loosing | undefined>(undefined); private __loosing = new BehaviorSubject<LoosingReport[] | undefined>(
undefined
);
private __loosings = new BehaviorSubject<Loosing[] | undefined>(undefined); private __loosings = new BehaviorSubject<Loosing[] | undefined>(undefined);
/** /**
@ -45,7 +48,7 @@ export class LoosingService {
/** /**
* Getter for loosing * Getter for loosing
*/ */
get loosing$(): Observable<Loosing | undefined> { get loosing$(): Observable<LoosingReport[] | undefined> {
return this.__loosing.asObservable(); return this.__loosing.asObservable();
} }
@ -104,27 +107,16 @@ export class LoosingService {
/** /**
* Get product by id * Get product by id
*/ */
getLoosingById(id: string | null): Observable<Loosing> { getLoosingById(id: string = '1'): Observable<LoosingReport[]> {
return this.__loosings.pipe( return this._httpClient
take(1), .get<LoosingReport[]>('api/apps/report/loosing/loosing', {
map((loosings) => { params: { id },
// Find the product
const loosing = loosings?.find((item) => item.id === id) || undefined;
// Update the product
this.__loosing.next(loosing);
// Return the product
return loosing;
}),
switchMap((product) => {
if (!product) {
return throwError('Could not found product with id of ' + id + '!');
}
return of(product);
}) })
); .pipe(
tap((response: LoosingReport[]) => {
this.__loosing.next(response);
})
);
} }
/** /**