first commit

This commit is contained in:
Bastian Wagner
2026-07-31 21:02:47 +02:00
commit 6bea4f766a
512 changed files with 64459 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
import {
AfterLoad,
BeforeInsert,
Column,
Entity,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';
import { EntityHelper } from 'src/utils/entity-helper';
import { TeamRole } from 'src/team-roles/entities/team-roles.entity';
import { Team } from 'src/teams/entities/team.entity';
import { User } from 'src/users/entities/user.entity';
import { Transaction } from 'src/transactions/entitites/transaction.entity';
@Entity()
export class Player extends EntityHelper {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstName: string;
@Column()
lastName: string;
@ManyToOne(() => TeamRole, {
eager: true,
})
teamRole?: TeamRole | null;
@ManyToOne(() => Team, {
eager: true,
})
team: Team;
@Column({ type: 'decimal', precision: 10, scale: 2, default: 0 })
balance: number;
@ManyToOne(() => User, (user) => user.players, {
eager: true,
})
user?: User | null;
@OneToMany(() => Transaction, (transaction) => transaction.player)
transactions: Transaction[];
@AfterLoad()
updateValue() {
this.balance = Number(this.balance);
}
@Column({ default: true })
active: boolean;
@BeforeInsert()
prepareData() {
if (this.balance == null) {
this.balance = 0;
}
if (this.transactions == null) {
this.transactions = [];
}
}
}