mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-03-04 12:20:21 +00:00
Finish API services
This commit is contained in:
parent
2abedc99f9
commit
0db8a7f439
18 changed files with 243 additions and 23 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
import { Games } from '../../games/entities/Games';
|
||||
import { Players } from '../../entities/Players';
|
||||
import { Players } from '../../players/entities/Players';
|
||||
|
||||
@Index('games_pk', [ 'id' ], { unique: true })
|
||||
@Index('game_detail_uuid_key', [ 'uuid' ], { unique: true })
|
||||
|
|
@ -12,7 +13,7 @@ export class GameDetail {
|
|||
@Column('text', { name: 'player_name' })
|
||||
playerName: string;
|
||||
|
||||
@Column('numeric', { name: 'stat_overwrite' })
|
||||
@Column('numeric', { name: 'stat_overwrite', select: false })
|
||||
statOverwrite: string;
|
||||
|
||||
@Column('text', { name: 'map' })
|
||||
|
|
@ -40,7 +41,7 @@ export class GameDetail {
|
|||
@JoinColumn([ { name: 'game_id', referencedColumnName: 'gameId' } ])
|
||||
game: Games;
|
||||
|
||||
// @ManyToOne(() => Players, (players) => players.gameDetails)
|
||||
// @JoinColumn([ { name: 'player_guid', referencedColumnName: 'playerGuid' } ])
|
||||
// playerGuid: Players;
|
||||
@ManyToOne(() => Players, (players) => players.gameDetails)
|
||||
@JoinColumn([ { name: 'player_guid', referencedColumnName: 'playerGuid' } ])
|
||||
playerGuid: Players;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { GameService } from './game.service';
|
||||
|
||||
@Controller('game')
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import { GameService } from './game.service';
|
|||
import { GameDetail } from './entities/GameDetail';
|
||||
import { Games } from '../games/entities/Games';
|
||||
|
||||
import { Players } from '../players/entities/Players';
|
||||
|
||||
@Module({
|
||||
imports: [ TypeOrmModule.forFeature([ Games, GameDetail ]), ConfigModule ],
|
||||
imports: [ TypeOrmModule.forFeature([ Games, GameDetail, Players ]), ConfigModule ],
|
||||
controllers: [ GameController ],
|
||||
providers: [ GameService ]
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { ConfigService } from '@nestjs/config';
|
|||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Connection, Repository } from 'typeorm';
|
||||
|
||||
import { Games } from '../games/entities/Games';
|
||||
import { GameDetail } from './entities/GameDetail';
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -10,11 +11,15 @@ export class GameService {
|
|||
constructor(
|
||||
private readonly connection: Connection,
|
||||
private readonly configService: ConfigService,
|
||||
@InjectRepository(Games) private readonly gamesRepository: Repository<Games>,
|
||||
@InjectRepository(GameDetail) private readonly gameRepository: Repository<GameDetail>
|
||||
) {}
|
||||
|
||||
async findOne(gameId: string) {
|
||||
const game = await this.gameRepository.find({ where: { gameId: gameId } });
|
||||
const game = await this.gameRepository.find({
|
||||
relations: [ 'game', 'playerGuid' ],
|
||||
where: [ { game: { gameId: gameId } } ]
|
||||
});
|
||||
if (!game) {
|
||||
throw new NotFoundException(`Game ID: ${gameId} not found`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue