+ 본사:
+ {{ __getCalculateRollingRate(info, MAIN_OFFICE_ID) }}
- 대본100P
+ 대본: {{ __getCalculateRollingRate(info, BRANCH_ID) }}
- 부본100P
+ 부본: {{ __getCalculateRollingRate(info, DIVISION_ID) }}
- 총판120P
+ 총판: {{ __getCalculateRollingRate(info, OFFICE_ID) }}
- 매장100P
-
- 회원100p
+ 매장: {{ __getCalculateRollingRate(info, STORE_ID) }}
{{ info.getCreatedAt() | date: "yyyy-MM-dd HH:mm" }}
diff --git a/src/app/modules/admin/game/casino/components/list.component.ts b/src/app/modules/admin/game/casino/components/list.component.ts
index 8160db0..57ee8ce 100644
--- a/src/app/modules/admin/game/casino/components/list.component.ts
+++ b/src/app/modules/admin/game/casino/components/list.component.ts
@@ -33,10 +33,13 @@ import { FuseConfirmationService } from '@fuse/services/confirmation';
import { Casino } from '../models/casino';
import { CasinoPagination } from '../models/casino-pagination';
import { CasinoService } from '../services/casino.service';
-import { ActivatedRoute } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { ListBettingHistoryResponse } from 'app/modules/proto/c2se/api/betting_pb';
import { BettingHistoryModel } from 'app/modules/proto/models/api/betting_pb';
-import { MemberModel } from 'app/modules/proto/models/member_pb';
+import {
+ MemberModel,
+ ParentMemberModel,
+} from 'app/modules/proto/models/member_pb';
import { ListMembersResponse } from 'app/modules/proto/c2se/member_pb';
import { environment } from 'environments/environment';
@@ -80,11 +83,13 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
listMember!: MemberModel[];
- mainOfficeId = environment.constants.classeIds.mainOffice;
- branchId = environment.constants.classeIds.branch;
- divisionId = environment.constants.classeIds.division;
- officeId = environment.constants.classeIds.office;
- storeId = environment.constants.classeIds.store;
+ MAIN_OFFICE_ID = environment.constants.classeIds.mainOffice;
+ BRANCH_ID = environment.constants.classeIds.branch;
+ DIVISION_ID = environment.constants.classeIds.division;
+ OFFICE_ID = environment.constants.classeIds.office;
+ STORE_ID = environment.constants.classeIds.store;
+
+ title: string = '';
__isSearchOpened = false;
isLoading = false;
@@ -100,6 +105,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
*/
constructor(
private _changeDetectorRef: ChangeDetectorRef,
+ private _router: Router,
private _activatedRoute: ActivatedRoute,
private _fuseConfirmationService: FuseConfirmationService,
private _formBuilder: FormBuilder,
@@ -114,6 +120,22 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
* On init
*/
ngOnInit(): void {
+ const url = this._router.url;
+ const startIdx = url.lastIndexOf('/');
+ const target = url.substring(startIdx + 1);
+
+ switch (target) {
+ case 'evolution':
+ this.title = '에볼루션배팅리스트';
+ break;
+ case 'casino':
+ this.title = '카지노배팅리스트';
+ break;
+
+ default:
+ break;
+ }
+
// Get the pagination
this._casinoService.pagination$
.pipe(takeUntil(this._unsubscribeAll))
@@ -138,6 +160,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
const listBettingHistory =
listBettingHistoryResult.getBettingHistoryList();
+
this.bettingHistorys$ = of(listBettingHistory);
this.__casinoTotalCount = listBettingHistoryResult.getTotalCount();
@@ -244,22 +267,94 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
return !!type ? 'Y' : 'N';
}
- __getMemberSettlementByParentId(
- parentId: string,
- type: string
- ): MemberModel | undefined {
- const parentMember = this.__getMemberByParentId(parentId);
- if (!!parentMember && parentMember.getMemberClass()?.getId() === type) {
- return parentMember;
+ __getCalculateRollingRate(
+ info: BettingHistoryModel,
+ classId: string
+ ): string {
+ let result: string = '';
+
+ if (info.getBettingType() === 'turn_win') {
+ return result;
}
- return this.__getMemberSettlementByParentId(parentId, type);
+
+ const parentClassId = info
+ .getMember()
+ ?.getParentMember()
+ ?.getMemberClass()
+ ?.getId();
+ const gameCategoryeType = info.getGameCategory();
+ const gameType = info.getGameType().toLocaleLowerCase();
+ const isBaccarat = gameType.includes('baccarat');
+ const isRoulette = gameType.includes('isRoulette');
+
+ let targetMember: MemberModel | ParentMemberModel | undefined;
+
+ let rate = 0;
+
+ if (classId === parentClassId) {
+ targetMember = info.getMember()?.getParentMember();
+ } else {
+ targetMember = this.__getMemberByParentMemberAndClassId(
+ info.getMember()?.getParentMember(),
+ classId
+ );
+ }
+
+ // casino & baccarat
+ // casino & craps
+ // casino & roulette
+ // casino & instantroulette
+
+ if (gameCategoryeType === 'casino') {
+ if (!!isBaccarat) {
+ rate =
+ targetMember?.getMemberSettlementSetting()?.getRateCasinoBacara() ||
+ 0;
+ } else if (!!isRoulette) {
+ rate =
+ targetMember?.getMemberSettlementSetting()?.getRateCasinoRoulette() ||
+ 0;
+ } else {
+ targetMember?.getMemberSettlementSetting()?.getRateCasino() || 0;
+ }
+ } else if (gameCategoryeType === 'slot') {
+ rate = targetMember?.getMemberSettlementSetting()?.getRateSlot() || 0;
+ } else {
+ rate = 0;
+ }
+
+ const betCash = info.getCash();
+ const point = betCash * (rate / 100);
+
+ result = `${targetMember?.getUsername()}(${rate}% ${point}P)`;
+
+ return result;
}
- __getMemberByParentId(parentId: string): MemberModel | undefined {
- const findMember = this.listMember.find((v) => v.getId() === parentId);
+ __getMemberByParentMemberAndClassId(
+ parentMember: ParentMemberModel | undefined,
+ classId: string
+ ): ParentMemberModel | undefined {
+ if (!parentMember) {
+ return;
+ }
- return findMember;
+ const pp = this.listMember.find((v) => v.getId() === parentMember.getId());
+
+ if (
+ !!pp &&
+ !!pp.getParentMember()?.getMemberClass() &&
+ pp.getParentMember()?.getMemberClass()?.getId() === classId
+ ) {
+ return pp.getParentMember();
+ } else {
+ return this.__getMemberByParentMemberAndClassId(
+ pp?.getParentMember(),
+ classId
+ );
+ }
}
+
__getMemberByUsername(username: string): MemberModel | undefined {
const findMember = this.listMember.find(
(v) => v.getUsername() === username
diff --git a/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts b/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts
index 01255b9..202b87a 100644
--- a/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts
+++ b/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts
@@ -86,8 +86,6 @@ export class CasinosResolver implements Resolve
{
pagination: CasinoPagination;
casinos: Casino[];
}> {
- console.log('state.children: ', state.url);
-
return this._casinoService.getCasinos();
}
}
@@ -130,17 +128,14 @@ export class ListCasinosResolver implements Resolve {
switch (target) {
case 'evolution':
+ route.data;
+
vendorIds = environment.constants.venderIds.evolutionCasino;
break;
case 'casino':
vendorIds = environment.constants.venderIds.casinos;
break;
- case 'slot':
- vendorIds = environment.constants.venderIds.slots;
- break;
- case 'powerball':
- break;
default:
break;
}
diff --git a/src/app/modules/admin/game/evolution/components/index.ts b/src/app/modules/admin/game/evolution/components/index.ts
deleted file mode 100644
index 04759eb..0000000
--- a/src/app/modules/admin/game/evolution/components/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { ListComponent } from './list.component';
-
-export const COMPONENTS = [ListComponent];
diff --git a/src/app/modules/admin/game/evolution/components/list.component.html b/src/app/modules/admin/game/evolution/components/list.component.html
deleted file mode 100644
index d459d81..0000000
--- a/src/app/modules/admin/game/evolution/components/list.component.html
+++ /dev/null
@@ -1,334 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
기간
-
- 2022-06-01 00:00 ~ 2022-06-21 23:59 까지
-
-
- 총 유효배팅 | 배팅금액
-
-
816,335원 | 816,335원
-
- 당첨 | 취소 | 배팅-당첨-취소
-
-
717,335원 | 0원 98,847
-
- 본사롤링 | 대본롤링 | 부본롤링 | 총판 롤링 | 매장롤링 | 회원롤링
-
-
- 6,335원 | 1,663원 | 1,633원 | 2,304원 | 5,544원 | 6,119원
-
-
롤링합계
-
3,9041원
-
-
-
-
-
-
-
-
-
-
-
-
- 0; else noUser">
-
-
-
-
상위
-
- 게임코드ID
-
- 사이트ID
-
- 닉네임
-
-
- 게임사이름
-
- 게임 이름
-
- 배팅고유코드
-
-
- 배팅
-
- 당첨
-
- 손익
-
-
- 배팅 전
-
- 배팅 후
-
- 최종금액
-
-
베팅
-
- 데이터
-
- 콤프
-
-
롤링
-
- 배팅시간
-
- 등록시간
-
-
-
-
-
-
-
- {{ info.highRank }}
-
-
- {{ info.gameId }}
-
- {{ info.signinId }}
-
- {{ info.nickname }}
-
-
- {{ info.vendorName }}
-
- {{ info.gameName }}
-
- {{ info.bettingId }}
-
-
- {{ info.betMoney }}
-
- {{ info.betWinMoney }}
-
- {{ info.betProfitLossMoney }}
-
-
- {{ info.betBeforeMoney }}
-
- {{ info.betAfterMoney }}
-
- {{ info.totalMoney }}
-
-
-
- {{
- betHistory.pickBetType
- }}
- {{
- betHistory.betMoney
- }}
- {{
- betHistory.betWinMoney
- }}
-
-
-
-
-
- {{ info.comp }}
-
-
-
- 본사: {{ info.mainInfo.name }}({{
- info.mainInfo.commissionRate
- }},{{ info.mainInfo.point }})
-
- 대본: {{ info.branchInfo.name }}({{
- info.branchInfo.commissionRate
- }},{{ info.branchInfo.point }})
-
- 부본: {{ info.divisionInfo.name }}({{
- info.divisionInfo.commissionRate
- }},{{ info.divisionInfo.point }})
-
- 총판: {{ info.officeInfo.name }}({{
- info.officeInfo.commissionRate
- }},{{ info.officeInfo.point }})
-
- 매장: {{ info.storeInfo.name }}({{
- info.storeInfo.commissionRate
- }},{{ info.storeInfo.point }})
-
-
- {{ info.bettingregistrationDate }}
-
- {{ info.registrationDate }}
-
-
-
-
-
-
-
-
-
-
-
-
- There are no data!
-
-
-
-
-
diff --git a/src/app/modules/admin/game/evolution/components/list.component.ts b/src/app/modules/admin/game/evolution/components/list.component.ts
deleted file mode 100644
index b83ab3d..0000000
--- a/src/app/modules/admin/game/evolution/components/list.component.ts
+++ /dev/null
@@ -1,202 +0,0 @@
-import {
- AfterViewInit,
- ChangeDetectionStrategy,
- ChangeDetectorRef,
- Component,
- OnDestroy,
- OnInit,
- ViewChild,
- ViewEncapsulation,
-} from '@angular/core';
-import {
- FormBuilder,
- FormControl,
- FormGroup,
- Validators,
-} from '@angular/forms';
-import { MatCheckboxChange } from '@angular/material/checkbox';
-import { MatPaginator } from '@angular/material/paginator';
-import { MatSort } from '@angular/material/sort';
-import {
- debounceTime,
- map,
- merge,
- Observable,
- Subject,
- switchMap,
- takeUntil,
-} from 'rxjs';
-import { fuseAnimations } from '@fuse/animations';
-import { FuseConfirmationService } from '@fuse/services/confirmation';
-
-import { Evolution } from '../models/evolution';
-import { EvolutionPagination } from '../models/evolution-pagination';
-import { EvolutionService } from '../services/evolution.service';
-
-@Component({
- selector: 'evolution-list',
- templateUrl: './list.component.html',
- styles: [
- /* language=SCSS */
- `
- .evolution-grid {
- /* 상부 유저 게임 금액 최종 */
- grid-template-columns: 80px 100px 150px 80px 80px auto 100px 150px 120px;
- @screen sm {
- /* 상부 유저 게임 금액 최종 배팅 */
- grid-template-columns: 80px 100px 150px 80px 80px auto 100px 150px 120px;
- }
-
- @screen md {
- /* 상부 유저 게임 금액 최종 배팅 데이터 콤프 */
- grid-template-columns: 80px 100px 150px 80px 80px auto 100px 150px 120px;
- }
-
- @screen lg {
- /* 상부 유저 게임 금액 최종 배팅 데이터&콤프 롤링 배팅시간 */
- grid-template-columns: 80px 100px 150px 60px 60px auto 80px 150px 120px;
- }
- }
- `,
- ],
- encapsulation: ViewEncapsulation.None,
- changeDetection: ChangeDetectionStrategy.OnPush,
- animations: fuseAnimations,
-})
-export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
- @ViewChild(MatPaginator) private _paginator!: MatPaginator;
- @ViewChild(MatSort) private _sort!: MatSort;
-
- evolutions$!: Observable;
-
- __isSearchOpened = false;
- isLoading = false;
- searchInputControl = new FormControl();
- selectedEvolution?: Evolution;
- pagination?: EvolutionPagination;
-
- private _unsubscribeAll: Subject = new Subject();
-
- /**
- * Constructor
- */
- constructor(
- private _changeDetectorRef: ChangeDetectorRef,
- private _fuseConfirmationService: FuseConfirmationService,
- private _formBuilder: FormBuilder,
- private _evolutionService: EvolutionService
- ) {}
-
- // -----------------------------------------------------------------------------------------------------
- // @ Lifecycle hooks
- // -----------------------------------------------------------------------------------------------------
-
- /**
- * On init
- */
- ngOnInit(): void {
- // Get the pagination
- this._evolutionService.pagination$
- .pipe(takeUntil(this._unsubscribeAll))
- .subscribe((pagination: EvolutionPagination | undefined) => {
- // Update the pagination
- this.pagination = pagination;
-
- // Mark for check
- this._changeDetectorRef.markForCheck();
- });
-
- // Get the products
- this.evolutions$ = this._evolutionService.evolutions$;
- }
-
- /**
- * After view init
- */
- ngAfterViewInit(): void {
- if (this._sort && this._paginator) {
- // Set the initial sort
- this._sort.sort({
- id: 'signinId',
- start: 'asc',
- disableClear: true,
- });
-
- // Mark for check
- this._changeDetectorRef.markForCheck();
-
- // If the evolution changes the sort order...
- this._sort.sortChange
- .pipe(takeUntil(this._unsubscribeAll))
- .subscribe(() => {
- // Reset back to the first page
- this._paginator.pageIndex = 0;
- });
-
- // Get products if sort or page changes
- merge(this._sort.sortChange, this._paginator.page)
- .pipe(
- switchMap(() => {
- this.isLoading = true;
- return this._evolutionService.getEvolutions(
- this._paginator.pageIndex,
- this._paginator.pageSize,
- this._sort.active,
- this._sort.direction
- );
- }),
- map(() => {
- this.isLoading = false;
- })
- )
- .subscribe();
- }
- }
-
- /**
- * On destroy
- */
- ngOnDestroy(): void {
- // Unsubscribe from all subscriptions
- this._unsubscribeAll.next(null);
- this._unsubscribeAll.complete();
- }
-
- // -----------------------------------------------------------------------------------------------------
- // @ Public methods
- // -----------------------------------------------------------------------------------------------------
-
- // -----------------------------------------------------------------------------------------------------
- // @ Private methods
- // -----------------------------------------------------------------------------------------------------
-
- /**
- * Create product
- */
- __createProduct(): void {}
-
- /**
- * Toggle product details
- *
- * @param productId
- */
- __toggleDetails(productId: string): void {}
-
- /**
- * toggle the search
- * Used in 'bar'
- */
- __onClickSearch(): void {
- this.__isSearchOpened = !this.__isSearchOpened;
- }
-
- /**
- * Track by function for ngFor loops
- *
- * @param index
- * @param item
- */
- __trackByFn(index: number, item: any): any {
- return item.id || index;
- }
-}
diff --git a/src/app/modules/admin/game/evolution/evolution.module.ts b/src/app/modules/admin/game/evolution/evolution.module.ts
deleted file mode 100644
index fe061f3..0000000
--- a/src/app/modules/admin/game/evolution/evolution.module.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { NgModule } from '@angular/core';
-import { RouterModule } from '@angular/router';
-
-import { MatButtonModule } from '@angular/material/button';
-import { MatFormFieldModule } from '@angular/material/form-field';
-import { MatIconModule } from '@angular/material/icon';
-import { MatInputModule } from '@angular/material/input';
-import { MatPaginatorModule } from '@angular/material/paginator';
-import { MatProgressBarModule } from '@angular/material/progress-bar';
-import { MatSortModule } from '@angular/material/sort';
-import { MatSelectModule } from '@angular/material/select';
-import { MatDatepickerModule } from '@angular/material/datepicker';
-import { MatMomentDateModule } from '@angular/material-moment-adapter';
-
-import { TranslocoModule } from '@ngneat/transloco';
-
-import { SharedModule } from 'app/shared/shared.module';
-
-import { COMPONENTS } from './components';
-
-import { evolutionRoutes } from './evolution.routing';
-
-@NgModule({
- declarations: [COMPONENTS],
- imports: [
- TranslocoModule,
- SharedModule,
- RouterModule.forChild(evolutionRoutes),
-
- MatButtonModule,
- MatFormFieldModule,
- MatIconModule,
- MatInputModule,
- MatPaginatorModule,
- MatProgressBarModule,
- MatSortModule,
- MatSelectModule,
- MatDatepickerModule,
- MatMomentDateModule,
- ],
-})
-export class EvolutionModule {}
diff --git a/src/app/modules/admin/game/evolution/evolution.routing.ts b/src/app/modules/admin/game/evolution/evolution.routing.ts
deleted file mode 100644
index 78500d7..0000000
--- a/src/app/modules/admin/game/evolution/evolution.routing.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Route } from '@angular/router';
-
-import { ListComponent } from './components/list.component';
-
-import { EvolutionsResolver } from './resolvers/evolution.resolver';
-
-export const evolutionRoutes: Route[] = [
- {
- path: '',
- component: ListComponent,
- resolve: {
- deposits: EvolutionsResolver,
- },
- },
-];
diff --git a/src/app/modules/admin/game/evolution/models/evolution-pagination.ts b/src/app/modules/admin/game/evolution/models/evolution-pagination.ts
deleted file mode 100644
index d1bff25..0000000
--- a/src/app/modules/admin/game/evolution/models/evolution-pagination.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export interface EvolutionPagination {
- length: number;
- size: number;
- page: number;
- lastPage: number;
- startIndex: number;
- endIndex: number;
-}
diff --git a/src/app/modules/admin/game/evolution/models/evolution.ts b/src/app/modules/admin/game/evolution/models/evolution.ts
deleted file mode 100644
index 2924b20..0000000
--- a/src/app/modules/admin/game/evolution/models/evolution.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-export interface Evolution {
- id: string;
- signinId?: string;
- highRank?: string;
- gameId?: string;
- nickname?: string;
- vendorName?: string;
- gameName?: string;
- bettingId?: string;
- betStatus?: string;
- betMoney?: string;
- betWinMoney?: string;
- betBeforeMoney?: string;
- betProfitLossMoney?: string;
- betAfterMoney?: string;
- totalMoney?: string;
- comp?: string;
- betHistorys?: [
- {
- pickBetType?: string;
- betMoney?: string;
- betWinMoney?: string;
- }
- ];
- mainInfo?: {
- name?: string;
- commissionRate?: string;
- point?: string;
- };
- branchInfo?: {
- name?: string;
- commissionRate?: string;
- point?: string;
- };
- divisionInfo?: {
- name?: string;
- commissionRate?: string;
- point?: string;
- };
- officeInfo?: {
- name?: string;
- commissionRate?: string;
- point?: string;
- };
- storeInfo?: {
- name?: string;
- commissionRate?: string;
- point?: string;
- };
- bettingregistrationDate?: string;
- registrationDate?: string;
-}
diff --git a/src/app/modules/admin/game/evolution/resolvers/evolution.resolver.ts b/src/app/modules/admin/game/evolution/resolvers/evolution.resolver.ts
deleted file mode 100644
index 4fc4dd8..0000000
--- a/src/app/modules/admin/game/evolution/resolvers/evolution.resolver.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import { Injectable } from '@angular/core';
-import {
- ActivatedRouteSnapshot,
- Resolve,
- Router,
- RouterStateSnapshot,
-} from '@angular/router';
-import { catchError, Observable, throwError } from 'rxjs';
-
-import { Evolution } from '../models/evolution';
-import { EvolutionPagination } from '../models/evolution-pagination';
-import { EvolutionService } from '../services/evolution.service';
-
-@Injectable({
- providedIn: 'root',
-})
-export class EvolutionResolver implements Resolve {
- /**
- * Constructor
- */
- constructor(
- private _evolutionService: EvolutionService,
- private _router: Router
- ) {}
-
- // -----------------------------------------------------------------------------------------------------
- // @ Public methods
- // -----------------------------------------------------------------------------------------------------
-
- /**
- * Resolver
- *
- * @param route
- * @param state
- */
- resolve(
- route: ActivatedRouteSnapshot,
- state: RouterStateSnapshot
- ): Observable {
- return this._evolutionService
- .getEvolutionById(route.paramMap.get('id'))
- .pipe(
- // Error here means the requested product is not available
- catchError((error) => {
- // Log the error
- console.error(error);
-
- // Get the parent url
- const parentUrl = state.url.split('/').slice(0, -1).join('/');
-
- // Navigate to there
- this._router.navigateByUrl(parentUrl);
-
- // Throw an error
- return throwError(error);
- })
- );
- }
-}
-
-@Injectable({
- providedIn: 'root',
-})
-export class EvolutionsResolver implements Resolve {
- /**
- * Constructor
- */
- constructor(private _evolutionService: EvolutionService) {}
-
- // -----------------------------------------------------------------------------------------------------
- // @ Public methods
- // -----------------------------------------------------------------------------------------------------
-
- /**
- * Resolver
- *
- * @param route
- * @param state
- */
- resolve(
- route: ActivatedRouteSnapshot,
- state: RouterStateSnapshot
- ): Observable<{
- pagination: EvolutionPagination;
- evolutions: Evolution[];
- }> {
- return this._evolutionService.getEvolutions();
- }
-}
diff --git a/src/app/modules/admin/game/evolution/services/evolution.service.ts b/src/app/modules/admin/game/evolution/services/evolution.service.ts
deleted file mode 100644
index 396f0f7..0000000
--- a/src/app/modules/admin/game/evolution/services/evolution.service.ts
+++ /dev/null
@@ -1,156 +0,0 @@
-import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
-import {
- BehaviorSubject,
- filter,
- map,
- Observable,
- of,
- switchMap,
- take,
- tap,
- throwError,
-} from 'rxjs';
-
-import { Evolution } from '../models/evolution';
-import { EvolutionPagination } from '../models/evolution-pagination';
-
-@Injectable({
- providedIn: 'root',
-})
-export class EvolutionService {
- // Private
- private __pagination = new BehaviorSubject(
- undefined
- );
- private __evolution = new BehaviorSubject(undefined);
- private __evolutions = new BehaviorSubject(
- undefined
- );
-
- /**
- * Constructor
- */
- constructor(private _httpClient: HttpClient) {}
-
- // -----------------------------------------------------------------------------------------------------
- // @ Accessors
- // -----------------------------------------------------------------------------------------------------
-
- /**
- * Getter for pagination
- */
- get pagination$(): Observable {
- return this.__pagination.asObservable();
- }
-
- /**
- * Getter for evolution
- */
- get evolution$(): Observable {
- return this.__evolution.asObservable();
- }
-
- /**
- * Getter for evolutions
- */
- get evolutions$(): Observable {
- return this.__evolutions.asObservable();
- }
-
- // -----------------------------------------------------------------------------------------------------
- // @ Public methods
- // -----------------------------------------------------------------------------------------------------
-
- /**
- * Get evolutions
- *
- *
- * @param page
- * @param size
- * @param sort
- * @param order
- * @param search
- */
- getEvolutions(
- page: number = 0,
- size: number = 10,
- sort: string = 'nickname',
- order: 'asc' | 'desc' | '' = 'asc',
- search: string = ''
- ): Observable<{
- pagination: EvolutionPagination;
- evolutions: Evolution[];
- }> {
- return this._httpClient
- .get<{ pagination: EvolutionPagination; evolutions: Evolution[] }>(
- 'api/apps/game/evolution/evolutions',
- {
- params: {
- page: '' + page,
- size: '' + size,
- sort,
- order,
- search,
- },
- }
- )
- .pipe(
- tap((response) => {
- this.__pagination.next(response.pagination);
- this.__evolutions.next(response.evolutions);
- })
- );
- }
-
- /**
- * Get product by id
- */
- getEvolutionById(id: string | null): Observable {
- return this.__evolutions.pipe(
- take(1),
- map((evolutions) => {
- // Find the product
- const evolution =
- evolutions?.find((item) => item.id === id) || undefined;
-
- // Update the product
- this.__evolution.next(evolution);
-
- // Return the product
- return evolution;
- }),
- switchMap((product) => {
- if (!product) {
- return throwError('Could not found product with id of ' + id + '!');
- }
-
- return of(product);
- })
- );
- }
-
- /**
- * Create product
- */
- createEvolution(): Observable {
- return this.evolutions$.pipe(
- take(1),
- switchMap((evolutions) =>
- this._httpClient
- .post('api/apps/game/evolution/product', {})
- .pipe(
- map((newEvolution) => {
- // Update the evolutions with the new product
- if (!!evolutions) {
- this.__evolutions.next([newEvolution, ...evolutions]);
- }
-
- // Return the new product
- return newEvolution;
- })
- )
- )
- );
- }
-}