game model modify

This commit is contained in:
byung eun park 2019-10-26 17:46:28 +09:00
parent de2ec9e203
commit fc63ed127a
13 changed files with 130 additions and 63 deletions

View File

@ -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<BetHistory> {
private _objectStore: BetHistory[] = [];
private _ObjectsSubject$ = new BehaviorSubject<BetHistory[]>([]);
export class BetHistoryDataSource extends DataSource<BettingHistory> {
private _objectStore: BettingHistory[] = [];
private _ObjectsSubject$ = new BehaviorSubject<BettingHistory[]>([]);
private _loadingSubject$ = new BehaviorSubject<boolean>(false);
public loading$ = this._loadingSubject$.asObservable();
public formg: FormGroup;
constructor(private betHistoryService: BetHistoryService) {
constructor(private betHistoryService: BettingHistoryService) {
super();
}
connect(collectionViewer: CollectionViewer): Observable<BetHistory[]> {
connect(collectionViewer: CollectionViewer): Observable<BettingHistory[]> {
// 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<BetHistory> {
// );
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 = <FormArray>this.formg.get('formarray');
res.forEach(r => fa.push(this.createRowFormGroup(r)));
@ -92,7 +102,7 @@ export class BetHistoryDataSource extends DataSource<BetHistory> {
// 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<BetHistory> {
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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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];

View File

@ -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<any>(`${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<any>(`${this.apiBaseUrl}/league/${id}`, {
@ -59,7 +59,7 @@ export class LeagueService {
sevenName,
engCountry,
korCountry,
sportsEntities
sportsType
})
.pipe(
map(res => {

View File

@ -0,0 +1,5 @@
export enum BettingResultName {
WINNING = 'WINNING',
FAILURE = 'FAILURE',
INVALIDITY = 'INVALIDITY'
}

View File

@ -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;
}