Removed the IAddressUser Interface entity
ref #105 - It was only needed b/c addresses were implemented as their own class
This commit is contained in:
parent
673dea2e57
commit
e2651728c5
@ -7,10 +7,9 @@ import {
|
|||||||
|
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { Address } from "./Address";
|
import { Address } from "./Address";
|
||||||
import { IAddressUser } from './IAddressUser';
|
|
||||||
import { RunnerGroup } from "./RunnerGroup";
|
import { RunnerGroup } from "./RunnerGroup";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,7 +17,7 @@ import { RunnerGroup } from "./RunnerGroup";
|
|||||||
* Mainly it's own class to reduce duplicate code and enable contact's to be associated with multiple groups.
|
* Mainly it's own class to reduce duplicate code and enable contact's to be associated with multiple groups.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
export class GroupContact implements IAddressUser {
|
export class GroupContact {
|
||||||
/**
|
/**
|
||||||
* Autogenerated unique id (primary key).
|
* Autogenerated unique id (primary key).
|
||||||
*/
|
*/
|
||||||
@ -55,7 +54,7 @@ export class GroupContact implements IAddressUser {
|
|||||||
* This is a address object to prevent any formatting differences.
|
* This is a address object to prevent any formatting differences.
|
||||||
*/
|
*/
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
@Column(type => Address)
|
||||||
address?: Address;
|
address?: Address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
import { Entity, ManyToOne, PrimaryColumn } from 'typeorm';
|
|
||||||
import { Address } from './Address';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The interface(tm) all entities using addresses have to implement.
|
|
||||||
* This is a abstract class, because apparently typeorm can't really work with interfaces :/
|
|
||||||
*/
|
|
||||||
@Entity()
|
|
||||||
export abstract class IAddressUser {
|
|
||||||
@PrimaryColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
|
||||||
address?: Address
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns this entity into it's response class.
|
|
||||||
*/
|
|
||||||
public abstract toResponse();
|
|
||||||
}
|
|
@ -7,11 +7,10 @@ import {
|
|||||||
|
|
||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
import { Column, Entity, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { ResponseParticipant } from '../responses/ResponseParticipant';
|
import { ResponseParticipant } from '../responses/ResponseParticipant';
|
||||||
import { Address } from "./Address";
|
import { Address } from "./Address";
|
||||||
import { IAddressUser } from './IAddressUser';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the Participant entity.
|
* Defines the Participant entity.
|
||||||
@ -19,7 +18,7 @@ import { IAddressUser } from './IAddressUser';
|
|||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
||||||
export abstract class Participant implements IAddressUser {
|
export abstract class Participant {
|
||||||
/**
|
/**
|
||||||
* Autogenerated unique id (primary key).
|
* Autogenerated unique id (primary key).
|
||||||
*/
|
*/
|
||||||
@ -55,7 +54,7 @@ export abstract class Participant implements IAddressUser {
|
|||||||
* The participant's address.
|
* The participant's address.
|
||||||
* This is a address object to prevent any formatting differences.
|
* This is a address object to prevent any formatting differences.
|
||||||
*/
|
*/
|
||||||
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
@Column(type => Address)
|
||||||
address?: Address;
|
address?: Address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { IsInt, IsOptional } from "class-validator";
|
import { IsInt, IsOptional } from "class-validator";
|
||||||
import { ChildEntity, ManyToOne, OneToMany } from "typeorm";
|
import { ChildEntity, Column, OneToMany } from "typeorm";
|
||||||
import { ResponseRunnerOrganisation } from '../responses/ResponseRunnerOrganisation';
|
import { ResponseRunnerOrganisation } from '../responses/ResponseRunnerOrganisation';
|
||||||
import { Address } from './Address';
|
import { Address } from './Address';
|
||||||
import { IAddressUser } from './IAddressUser';
|
|
||||||
import { Runner } from './Runner';
|
import { Runner } from './Runner';
|
||||||
import { RunnerGroup } from "./RunnerGroup";
|
import { RunnerGroup } from "./RunnerGroup";
|
||||||
import { RunnerTeam } from "./RunnerTeam";
|
import { RunnerTeam } from "./RunnerTeam";
|
||||||
@ -12,13 +11,13 @@ import { RunnerTeam } from "./RunnerTeam";
|
|||||||
* This usually is a school, club or company.
|
* This usually is a school, club or company.
|
||||||
*/
|
*/
|
||||||
@ChildEntity()
|
@ChildEntity()
|
||||||
export class RunnerOrganisation extends RunnerGroup implements IAddressUser {
|
export class RunnerOrganisation extends RunnerGroup {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The organisations's address.
|
* The organisations's address.
|
||||||
*/
|
*/
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
@Column(type => Address)
|
||||||
address?: Address;
|
address?: Address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user