change salutation to separate table

This commit is contained in:
Julian Krauser 2025-01-25 10:20:57 +01:00
parent ff651b7d8f
commit 21cf811a56
17 changed files with 64 additions and 61 deletions

View file

@ -1,32 +1,16 @@
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, PrimaryColumn } from "typeorm";
import { Salutation } from "../../../enums/salutation";
import { membership } from "./membership";
import { memberAwards } from "./memberAwards";
import { memberQualifications } from "./memberQualifications";
import { memberExecutivePositions } from "./memberExecutivePositions";
import { communication } from "./communication";
import { CommunicationViewModel } from "../../../viewmodel/admin/club/member/communication.models";
import { salutation } from "../../settings/salutation";
@Entity()
export class member {
@PrimaryColumn({ generated: "increment", type: "int" })
id: number;
@Column({
type: "varchar",
length: "255",
default: Salutation.none.toString(),
transformer: {
to(value: Salutation) {
return value.toString();
},
from(value: string) {
return Salutation[value as keyof typeof Salutation];
},
},
})
salutation: Salutation;
@Column({ type: "varchar", length: 255 })
firstname: string;
@ -42,6 +26,9 @@ export class member {
@Column({ type: "varchar", length: 255, unique: true, nullable: true })
internalId?: string;
@Column()
salutationId: number;
@OneToMany(() => communication, (communications) => communications.member)
communications: communication[];
@ -53,6 +40,9 @@ export class member {
@JoinColumn()
sendNewsletter?: communication;
@ManyToOne(() => salutation, (salutation) => salutation.members)
salutation: salutation;
@OneToMany(() => membership, (membership) => membership.member)
memberships: membership[];