From fc63ed127a650805ae0ba5fad78f2e370d871cde Mon Sep 17 00:00:00 2001 From: byung eun park Date: Sat, 26 Oct 2019 17:46:28 +0900 Subject: [PATCH] game model modify --- .../game/component/bet-history.data-source.ts | 74 +++++++++++-------- src/modules/game/model/bet-history.model.ts | 13 ---- .../game/model/betting-history.model.ts | 14 ++++ src/modules/game/model/league.model.ts | 4 +- src/modules/game/model/mini-game.model.ts | 15 ++++ .../game/model/sports-event-result.model.ts | 12 +++ src/modules/game/model/sports-event.model.ts | 21 ++++++ src/modules/game/model/sports-team.model.ts | 10 +++ ...yservice.ts => betting-history.service.ts} | 4 +- src/modules/game/service/index.ts | 4 +- src/modules/game/service/league.service.ts | 8 +- src/modules/game/type/betting-result.type.ts | 5 ++ .../sports-name.type.ts} | 9 +-- 13 files changed, 130 insertions(+), 63 deletions(-) delete mode 100644 src/modules/game/model/bet-history.model.ts create mode 100644 src/modules/game/model/betting-history.model.ts create mode 100644 src/modules/game/model/mini-game.model.ts create mode 100644 src/modules/game/model/sports-event-result.model.ts create mode 100644 src/modules/game/model/sports-event.model.ts create mode 100644 src/modules/game/model/sports-team.model.ts rename src/modules/game/service/{bet-historyservice.ts => betting-history.service.ts} (87%) create mode 100644 src/modules/game/type/betting-result.type.ts rename src/modules/game/{model/sports.model.ts => type/sports-name.type.ts} (55%) diff --git a/src/app/pages/games/game/component/bet-history.data-source.ts b/src/app/pages/games/game/component/bet-history.data-source.ts index 3548e90..f6d2c0e 100644 --- a/src/app/pages/games/game/component/bet-history.data-source.ts +++ b/src/app/pages/games/game/component/bet-history.data-source.ts @@ -5,63 +5,73 @@ import { map } from 'rxjs/operators'; import { CollectionViewer } from '@angular/cdk/collections'; -import { BetHistory } from 'src/modules/game/model/bet-history.model'; -import { BetHistoryService } from 'src/modules/game/service/bet-historyservice'; +import { BettingHistory } from 'src/modules/game/model/betting-history.model'; +import { BettingHistoryService } from 'src/modules/game/service/betting-history.service'; import { FormControl, FormGroup, Validators, FormArray } from '@angular/forms'; +import { BettingResultName } from 'src/modules/game/type/betting-result.type'; -const ELEMENT_DATA: BetHistory[] = [ +const ELEMENT_DATA: BettingHistory[] = [ { id: 1, - thumbNail: '/images/thumbname/1.jpg', - title: '오픈기념 이벤트', - imageWidth: 200, - imageHeight: 200, - imageX: 100, - imageY: 100, - openStatus: true, + league: 1, + sportsEvents: null, + user: 1, + moneyLog: 20000, + bettingMoney: 10000, + predictMoney: 100, + realMoney: 11111, + bettingResult: BettingResultName.FAILURE, + createdBy: 1, + updatedBy: 1, updatedAt: null, createdAt: null }, { id: 2, - thumbNail: '/images/thumbname/2.jpg', - title: '첫충전 이벤트', - imageWidth: 200, - imageHeight: 200, - imageX: 100, - imageY: 100, - openStatus: true, + league: 1, + sportsEvents: null, + user: 1, + moneyLog: 20000, + bettingMoney: 10000, + predictMoney: 100, + realMoney: 11111, + bettingResult: BettingResultName.FAILURE, + createdBy: 1, + updatedBy: 1, updatedAt: null, createdAt: null }, { id: 3, - thumbNail: '/images/thumbname/3.jpg', - title: '친구초대 이벤트', - imageWidth: 200, - imageHeight: 200, - imageX: 100, - imageY: 100, - openStatus: true, + league: 1, + sportsEvents: null, + user: 1, + moneyLog: 20000, + bettingMoney: 10000, + predictMoney: 100, + realMoney: 11111, + bettingResult: BettingResultName.FAILURE, + createdBy: 1, + updatedBy: 1, updatedAt: null, createdAt: null } ]; -export class BetHistoryDataSource extends DataSource { - private _objectStore: BetHistory[] = []; - private _ObjectsSubject$ = new BehaviorSubject([]); +export class BetHistoryDataSource extends DataSource { + private _objectStore: BettingHistory[] = []; + private _ObjectsSubject$ = new BehaviorSubject([]); private _loadingSubject$ = new BehaviorSubject(false); public loading$ = this._loadingSubject$.asObservable(); public formg: FormGroup; - constructor(private betHistoryService: BetHistoryService) { + constructor(private betHistoryService: BettingHistoryService) { super(); } - connect(collectionViewer: CollectionViewer): Observable { + connect(collectionViewer: CollectionViewer): Observable { // return this.fixBonusService.getAll().pipe( // map(res => { // res.forEach(m => this._objectStore.push(m as FixBonus)); @@ -73,7 +83,7 @@ export class BetHistoryDataSource extends DataSource { // ); return of(ELEMENT_DATA).pipe( map(res => { - res.forEach(m => this._objectStore.push(m as BetHistory)); + res.forEach(m => this._objectStore.push(m as BettingHistory)); this._ObjectsSubject$.next(this._objectStore); let fa = this.formg.get('formarray'); res.forEach(r => fa.push(this.createRowFormGroup(r))); @@ -92,7 +102,7 @@ export class BetHistoryDataSource extends DataSource { // openStatus: true, // updatedAt: null, // createdAt: null - createRowFormGroup(r: BetHistory): FormGroup { + createRowFormGroup(r: BettingHistory): FormGroup { let f = new FormGroup({ title: this.createNewFormContorl(r, 'title'), imageWidth: this.createNewFormContorl(r, 'imageWidth'), @@ -104,7 +114,7 @@ export class BetHistoryDataSource extends DataSource { return f; } - createNewFormContorl(r: BetHistory, propName: string): FormControl { + createNewFormContorl(r: BettingHistory, propName: string): FormControl { let m = new FormControl(r[propName], Validators.required); m.valueChanges.subscribe(val => { r[propName] = val; diff --git a/src/modules/game/model/bet-history.model.ts b/src/modules/game/model/bet-history.model.ts deleted file mode 100644 index c841317..0000000 --- a/src/modules/game/model/bet-history.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { DateAudit } from 'src/modules/common/data/model/audit'; - -export interface BetHistory extends DateAudit { - id?: number; - thumbNail?: string; - title?: string; - imageWidth?: number; - imageHeight?: number; - imageX?: number; - imageY?: number; - openStatus?: boolean; - popupEffect?: number; -} diff --git a/src/modules/game/model/betting-history.model.ts b/src/modules/game/model/betting-history.model.ts new file mode 100644 index 0000000..d53ee27 --- /dev/null +++ b/src/modules/game/model/betting-history.model.ts @@ -0,0 +1,14 @@ +import { UserDateAuditEntity } from 'src/modules/common/data/model/audit'; +import { SportsEvent } from './sports-event.model'; +import { BettingResultName } from '../type/betting-result.type'; +export interface BettingHistory extends UserDateAuditEntity { + id?: number; + league?: number; + sportsEvents?: SportsEvent[]; + user?: number; + moneyLog?: number; + bettingMoney?: number; + predictMoney?: number; + realMoney?: number; + bettingResult?: BettingResultName; +} diff --git a/src/modules/game/model/league.model.ts b/src/modules/game/model/league.model.ts index d1a2cd2..11f59c1 100644 --- a/src/modules/game/model/league.model.ts +++ b/src/modules/game/model/league.model.ts @@ -1,5 +1,5 @@ import { DateAudit } from 'src/modules/common/data/model/audit'; -import { Sports } from './sports.model'; +import { SportsTypeName } from '../type/sports-name.type'; export interface League extends DateAudit { id?: number; @@ -8,5 +8,5 @@ export interface League extends DateAudit { sevenName?: string; engCountry?: string; korCountry?: string; - sportsEntities?: Sports[]; + sportsType?: SportsTypeName; } diff --git a/src/modules/game/model/mini-game.model.ts b/src/modules/game/model/mini-game.model.ts new file mode 100644 index 0000000..0b5ad93 --- /dev/null +++ b/src/modules/game/model/mini-game.model.ts @@ -0,0 +1,15 @@ +import { UserDateAuditEntity } from 'src/modules/common/data/model/audit'; + +export interface MiniGame extends UserDateAuditEntity { + id?: number; + drawName?: string; + awayName?: string; + miniGameType?: string; + miniGameRound?: number; + resultStatus?: number; + bettingStatus?: number; + matchDateTime?: Date; + homeOdds?: number; + drawOdds?: number; + awayOdds?: number; +} diff --git a/src/modules/game/model/sports-event-result.model.ts b/src/modules/game/model/sports-event-result.model.ts new file mode 100644 index 0000000..3124808 --- /dev/null +++ b/src/modules/game/model/sports-event-result.model.ts @@ -0,0 +1,12 @@ +import { DateAudit } from 'src/modules/common/data/model/audit'; + +export interface SportsEventResult extends DateAudit { + id?: number; + sportsEvent?: number; + status?: number; + homeFullTimeScore?: number; + homeFinalScore?: number; + awayFullTimeScore?: number; + awayFinalScore?: number; + scoreInfo?: object; +} diff --git a/src/modules/game/model/sports-event.model.ts b/src/modules/game/model/sports-event.model.ts new file mode 100644 index 0000000..f0b49c8 --- /dev/null +++ b/src/modules/game/model/sports-event.model.ts @@ -0,0 +1,21 @@ +import { DateAudit } from 'src/modules/common/data/model/audit'; + +export interface SportsEvent extends DateAudit { + id?: number; + matchDateTime?: Date; + resultStatus?: number; + bettingStatus?: number; + gameWay?: number; + gameType?: number; + parseStatus?: number; + sportsEngName?: string; + sportsKorName?: string; + matchEtc?: string; + league?: number; + homeTeam?: string; + awayTeam?: string; + homeOdds?: number; + drawOdds?: number; + awayOdds?: number; + optionOdds?: number; +} diff --git a/src/modules/game/model/sports-team.model.ts b/src/modules/game/model/sports-team.model.ts new file mode 100644 index 0000000..62f5fe6 --- /dev/null +++ b/src/modules/game/model/sports-team.model.ts @@ -0,0 +1,10 @@ +import { DateAudit } from 'src/modules/common/data/model/audit'; +import { SportsTypeName } from '../type/sports-name.type'; + +export interface SportsTeam extends DateAudit { + id?: number; + engName?: string; + korName?: string; + countryCode?: string; + sportsType?: SportsTypeName; +} diff --git a/src/modules/game/service/bet-historyservice.ts b/src/modules/game/service/betting-history.service.ts similarity index 87% rename from src/modules/game/service/bet-historyservice.ts rename to src/modules/game/service/betting-history.service.ts index bd386f2..af039a3 100644 --- a/src/modules/game/service/bet-historyservice.ts +++ b/src/modules/game/service/betting-history.service.ts @@ -3,7 +3,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; -import { BetHistory } from '../model/bet-history.model'; +import { BettingHistory } from '../model/betting-history.model'; import { API_BASE_URL } from 'src/modules/common/type/injection-token.type'; import { Page } from 'src/modules/common/data/model/page'; import { FormArray } from '@angular/forms'; @@ -11,7 +11,7 @@ import { FormArray } from '@angular/forms'; @Injectable({ providedIn: 'root' }) -export class BetHistoryService { +export class BettingHistoryService { constructor( @Inject(API_BASE_URL) private apiBaseUrl: string, private httpClient: HttpClient diff --git a/src/modules/game/service/index.ts b/src/modules/game/service/index.ts index 2a787af..f1697e2 100644 --- a/src/modules/game/service/index.ts +++ b/src/modules/game/service/index.ts @@ -1,3 +1,3 @@ import { LeagueService } from './league.service'; -import { BetHistoryService } from './bet-historyservice'; -export const SERVICES = [LeagueService, BetHistoryService]; +import { BettingHistoryService } from './betting-history.service'; +export const SERVICES = [LeagueService, BettingHistoryService]; diff --git a/src/modules/game/service/league.service.ts b/src/modules/game/service/league.service.ts index 2d03f23..5ab3927 100644 --- a/src/modules/game/service/league.service.ts +++ b/src/modules/game/service/league.service.ts @@ -23,7 +23,7 @@ export class LeagueService { const sevenName = league.sevenName; const engCountry = league.engCountry; const korCountry = league.korCountry; - const sportsEntities = league.sportsEntities; + const sportsType = league.sportsType; return this.httpClient .post(`${this.apiBaseUrl}/league`, { @@ -32,7 +32,7 @@ export class LeagueService { sevenName, engCountry, korCountry, - sportsEntities + sportsType }) .pipe( map(res => { @@ -49,7 +49,7 @@ export class LeagueService { const sevenName = league.sevenName; const engCountry = league.engCountry; const korCountry = league.korCountry; - const sportsEntities = league.sportsEntities; + const sportsType = league.sportsType; return this.httpClient .put(`${this.apiBaseUrl}/league/${id}`, { @@ -59,7 +59,7 @@ export class LeagueService { sevenName, engCountry, korCountry, - sportsEntities + sportsType }) .pipe( map(res => { diff --git a/src/modules/game/type/betting-result.type.ts b/src/modules/game/type/betting-result.type.ts new file mode 100644 index 0000000..a2725f5 --- /dev/null +++ b/src/modules/game/type/betting-result.type.ts @@ -0,0 +1,5 @@ +export enum BettingResultName { + WINNING = 'WINNING', + FAILURE = 'FAILURE', + INVALIDITY = 'INVALIDITY' +} diff --git a/src/modules/game/model/sports.model.ts b/src/modules/game/type/sports-name.type.ts similarity index 55% rename from src/modules/game/model/sports.model.ts rename to src/modules/game/type/sports-name.type.ts index 24c84b7..879e1ca 100644 --- a/src/modules/game/model/sports.model.ts +++ b/src/modules/game/type/sports-name.type.ts @@ -1,6 +1,4 @@ -import { DateAudit } from 'src/modules/common/data/model/audit'; - -export enum SportsName { +export enum SportsTypeName { SOCCER = 'SOCCER', BASEBALL = 'BASEBALL', BASKET_BALL = 'BASKET_BALL', @@ -10,8 +8,3 @@ export enum SportsName { VALLEY_BALL = 'VALLEY_BALL', HAND_BALL = 'HAND_BALL' } - -export interface Sports extends DateAudit { - id?: number; - name?: SportsName; -}