From ea1a5fc7f2a44bd99da9ef9a2a7e3fed3b25f4d0 Mon Sep 17 00:00:00 2001 From: Samuli Virtapohja <l4721@student.jamk.fi> Date: Mon, 17 Jun 2019 12:52:14 +0300 Subject: [PATCH] getting dis --- package-lock.json | 5 +---- src/game/game.entity.ts | 2 +- src/game/game.module.ts | 2 +- src/user/user.module.ts | 3 ++- src/user/user.service.ts | 11 +++++++++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index d6db2b3..e1b770f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3335,14 +3335,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3361,7 +3359,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } diff --git a/src/game/game.entity.ts b/src/game/game.entity.ts index d7c42c9..5d36417 100644 --- a/src/game/game.entity.ts +++ b/src/game/game.entity.ts @@ -6,7 +6,7 @@ import { OneToMany, Timestamp, } from 'typeorm'; -import { PersonEntity } from 'src/user/user.entity'; +import { PersonEntity } from '../user/user.entity'; // table that stores all created games @Entity('Game') diff --git a/src/game/game.module.ts b/src/game/game.module.ts index e6a23cf..5926f1c 100644 --- a/src/game/game.module.ts +++ b/src/game/game.module.ts @@ -4,7 +4,7 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { GameController } from './game.controller'; import { GameService } from './game.service'; import { GameEntity, FactionEntity, Game_PersonEntity } from './game.entity'; -import { PersonEntity } from 'src/user/user.entity'; +import { PersonEntity } from '../user/user.entity'; @Module({ imports: [TypeOrmModule.forFeature([GameEntity, FactionEntity, Game_PersonEntity, PersonEntity])], diff --git a/src/user/user.module.ts b/src/user/user.module.ts index 1dcd767..6cb77a7 100644 --- a/src/user/user.module.ts +++ b/src/user/user.module.ts @@ -4,9 +4,10 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { UserController } from './user.controller'; import { UserService } from './user.service'; import { PersonEntity} from './user.entity'; +import { GameEntity } from '../game/game.entity'; @Module({ - imports: [TypeOrmModule.forFeature([PersonEntity])], + imports: [TypeOrmModule.forFeature([PersonEntity, GameEntity])], controllers: [UserController], providers: [UserService], }) diff --git a/src/user/user.service.ts b/src/user/user.service.ts index 840d832..fb1b637 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -4,10 +4,17 @@ import { InjectRepository } from "@nestjs/typeorm"; import { PersonEntity } from './user.entity'; import { UserDTO } from './user.dto'; +import { GameEntity } from '../game/game.entity'; +import { GameDTO } from '../game/game.dto'; @Injectable() export class UserService { - constructor(@InjectRepository(PersonEntity) private userRepository: Repository<PersonEntity>){} + constructor( + @InjectRepository(PersonEntity) + private userRepository: Repository<PersonEntity>, + @InjectRepository(GameEntity) + private gameRepository: Repository<GameEntity> + ){} async register(data: UserDTO) { const { name } = data; @@ -41,7 +48,7 @@ export class UserService { try { // etsi peli valinnan mukaan ja otetaan käyttäjän rooli kyseisestä pelistä talteen const role = await this.gameRepository.findOne(); - return gamedata; + return role; } catch (error) { return error.message; } -- GitLab