Skip to content
Snippets Groups Projects
Commit 3068bef3 authored by L4072's avatar L4072
Browse files

Database hiomista

parent 691c2685
No related branches found
No related tags found
4 merge requests!59Development to master,!14Type orm,!13Type orm,!11Type orm
import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert, ManyToMany, OneToMany } from 'typeorm';
import {Game_PersonEntity, ObjectivePointEntity} from '../game/game.entity'
import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert, ManyToMany, OneToMany, ManyToOne, JoinTable } from 'typeorm';
import {Game_PersonEntity, ObjectivePointEntity, GameEntity} from '../game/game.entity'
import { FactionEntity } from '../game/faction.entity'
//import { MapEntity, MapDrawingEntity } from '../map/map.entity'
@Entity('Coordinate')
export class CoordinateEntity {
......@@ -8,8 +9,52 @@ export class CoordinateEntity {
@Column({type: 'geometry'}) longitude: string;
@Column({type: 'geometry'}) latitude: string;
@ManyToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.mapDrawings_coordinates)
mapDrawings: MapDrawingEntity[];
@ManyToMany(type => Game_PersonEntity, game_persons => game_persons.game_person_coordinates)
game_persons: Game_PersonEntity[];
@OneToMany(type => ObjectivePointEntity, objective_points => objective_points.coordinate)
objective_points: ObjectivePointEntity[];
@OneToMany(type => MapEntity, maps => maps.coordinate)
maps: ObjectivePointEntity[];
}
@Entity('Map')
export class MapEntity {
@PrimaryGeneratedColumn('uuid') mapId: string;
@ManyToOne(type => CoordinateEntity, coordinate => coordinate.maps)
coordinate: CoordinateEntity;
@OneToMany(type => GameEntity, games => games.map)
games: GameEntity[];
@OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.map)
mapDrawings: MapDrawingEntity[];
}
@Entity('MapDrawing')
export class MapDrawingEntity {
@PrimaryGeneratedColumn('uuid') mapDrawingId: string;
@Column({type: 'bool'}) drawingIsActive: boolean;
@Column({type: 'time'}) drawingValidTill: string;
@ManyToMany(type => CoordinateEntity, mapDrawings_coordinates => mapDrawings_coordinates.mapDrawings)
@JoinTable()
mapDrawings_coordinates: CoordinateEntity[];
@ManyToOne(type => MapEntity, map => map.mapDrawings)
map: MapEntity;
@ManyToOne(type => MapDrawingTypeEntity, mapDrawingType => mapDrawingType.mapDrawings)
mapDrawingType: MapEntity;
@ManyToOne(type => FactionEntity, faction => faction.mapDrawings)
faction: FactionEntity;
}
@Entity('MapDrawingType')
export class MapDrawingTypeEntity {
@PrimaryGeneratedColumn('uuid') mapDrawingTypeId: string;
@Column({type: 'text'}) drawingTypeName: string;
@Column({type: 'text'}) drawingTypeDescription: string;
@OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.mapDrawingType)
mapDrawings: MapDrawingEntity[];
}
\ No newline at end of file
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToMany, JoinTable, ManyToOne, Timestamp } from 'typeorm';
import { type } from 'os';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, Timestamp } from 'typeorm';
import {PersonEntity} from '../user/user.entity'
import {GameEntity} from './game.entity'
import {Game_PersonEntity} from './game.entity'
import { MapDrawingEntity } from '../coordinate/coordinate.entity'
@Entity('Faction')
export class FactionEntity {
@PrimaryGeneratedColumn('uuid') factionId: string;
@Column({type: 'text', unique: true}) factionName: string;
@OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.faction)
mapDrawings: MapDrawingEntity[];
@OneToMany(type => ScoreEntity, scores => scores.faction)
scores: ScoreEntity[];
@OneToMany(type => PowerUpEntity, powerUps => powerUps.factions)
......@@ -70,6 +72,8 @@ export class TaskEntity {
@PrimaryGeneratedColumn('uuid') taskId: string;
@Column({type: 'text'}) taskName: string;
@Column({type: 'text'}) taskDescription: string;
@Column({type: 'text'}) taskWinner: string;
@Column({type: 'bool'}) taskIsActive: boolean;
@ManyToOne(type => FactionEntity, faction => faction.tasks)
faction: FactionEntity;
......
import { Controller, Post, Body } from '@nestjs/common';
import {CreateGameDTO} from './game.dto'
@Controller('Game')
export class GameController{
//@Post()
//create(@Body() )
}
\ No newline at end of file
import { IsNotEmpty, IsString } from 'class-validator';
export class CreateGameDTO {
@IsString () @IsNotEmpty()
gameId: string;
@IsString () @IsNotEmpty()
gameName: string;
}
\ No newline at end of file
import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert, OneToMany, ManyToOne, ManyToMany, Timestamp } from 'typeorm';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, ManyToMany, Timestamp, JoinTable } from 'typeorm';
import {PersonEntity, PersonRoleEntity} from '../user/user.entity'
import {FactionEntity} from './faction.entity'
import {CoordinateEntity} from '../coordinate/coordinate.entity'
import { MapEntity } from '../coordinate/coordinate.entity'
@Entity('Game')
export class GameEntity {
......@@ -11,6 +12,8 @@ export class GameEntity {
@Column({type: 'date'}) startDate: string;
@Column({type: 'date'}) endDate: string;
@ManyToOne(type => MapEntity, map => map.games)
map: MapEntity;
@OneToMany(type => FactionEntity, faction => faction.game)
factions: FactionEntity[];
@OneToMany(type => Game_PersonEntity, game_persons => game_persons.game)
......@@ -33,6 +36,7 @@ export class Game_PersonEntity {
@ManyToOne(type => PersonRoleEntity, person_role => person_role.game_persons)
person_role: PersonRoleEntity;
@ManyToMany(type => CoordinateEntity, game_person_coordinates => game_person_coordinates.game_persons)
@JoinTable()
game_person_coordinates: CoordinateEntity[];
}
......@@ -53,7 +57,7 @@ export class ObjectivePointEntity {
export class ObjectivePoint_HistoryEntity {
@PrimaryGeneratedColumn('uuid') oP_HistoryId: string;
@Column({type: 'timestamp'}) oP_HistoryTimestamp: Timestamp;
//@Column({/*type: 'timestamp'*/}) oP_HistoryStatus: Timestamp;
@Column({/*type: 'timestamp'*/}) oP_HistoryStatus: number;
@ManyToOne(type => ObjectivePointEntity, objective_point => objective_point.op_history)
objective_point: ObjectivePointEntity;
......
import { Entity, Column, PrimaryGeneratedColumn, BeforeInsert } from 'typeorm';
@Entity('ObjectivePoint')
export class ObjectivePointEntity {
@PrimaryGeneratedColumn('uuid') objectivePointId: string;
@Column({type: 'text'}) powerUpDescription: string;
@Column({type: 'int'}) amount: number;
@Column({type: 'time'}) cooldown: string;
//history; milloin käytetty (timestamp) taulukko
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment