src/model/*: finished rough design of entities

pull/7/head
leonnicolas 4 years ago
parent c06bb1d1f1
commit 7bcf3c3c46
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -3,7 +3,7 @@ WORKDIR /
COPY ./src /src COPY ./src /src
COPY ./package*.json ./ COPY ./package*.json ./
COPY ./gulpfile.js ./tsconfig.json ./ COPY ./gulpfile.js ./
COPY ./ormconfig.json ./ COPY ./ormconfig.json ./
RUN npm install RUN npm install
RUN npm install -g gulp RUN npm install -g gulp
@ -11,5 +11,5 @@ RUN npm install gulp
RUN gulp RUN gulp
EXPOSE 4000 EXPOSE 4000
EXPOSE 5432
CMD ["npm", "start"] CMD ["npm", "start"]

@ -13,18 +13,24 @@ export class BikeEvent {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Column() @Column({
nullable: true
})
note: string; note: string;
@Column('simple-array') @Column({
type: 'date'
})
date: Date;
@Column('simple-array', {
nullable: true
})
documents: string[]; documents: string[];
@Column({ @Column({
type: 'enum', type: 'enum',
enum: BikeEventType enum: BikeEventType
}) })
type: BikeEventType eventType: BikeEventType
@Column()
otherEquipment: string;
} }

@ -0,0 +1,11 @@
import { PrimaryGeneratedColumn, Column, Entity } from 'typeorm';
import { Bike } from './BikeFeatures';
@Entity()
export class BikeModel extends Bike {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
}

@ -5,6 +5,10 @@ import { ChainSwap } from './ChainSwap';
import { Provider } from './Provider'; import { Provider } from './Provider';
import { Participant } from './Participant'; import { Participant } from './Participant';
import { InsuranceData } from './InsuranceData'; import { InsuranceData } from './InsuranceData';
import { LoanPeriod } from './LoanPeriod';
import { LendingStation } from './LendingStation';
import { Taxes } from './Taxes';
import { Equipment } from './Equipment';
export enum Group { export enum Group {
KL, KL,
@ -40,7 +44,19 @@ export class CargoBike extends Bike {
@Column() @Column()
serialNo: string; serialNo: string;
@OneToMany(type => ChainSwap, chainSwap => chainSwap.cargoBike) @OneToMany(type => Equipment, equipment => equipment.cargoBike, {
nullable: true
})
equipment: Equipment[];
@Column({
nullable: true
})
otherEquipment: string;
@OneToMany(type => ChainSwap, chainSwap => chainSwap.cargoBike, {
nullable: true
})
chainSwaps: ChainSwap[] chainSwaps: ChainSwap[]
// Security information // Security information
@ -68,12 +84,39 @@ export class CargoBike extends Bike {
@Column() @Column()
note: string; note: string;
@ManyToOne(type => Provider) @ManyToOne(type => Provider, {
nullable: true
})
provider: Provider; provider: Provider;
@ManyToOne(type => Participant, participant => participant.cargoBikes) @ManyToOne(type => Participant, participant => participant.cargoBikes)
coordinator: Participant; coordinator: Participant;
@OneToOne(type => InsuranceData) @Column(type => InsuranceData)
insuranceData: InsuranceData; insuranceData: InsuranceData;
@OneToMany(type => LoanPeriod, loanPeriod => loanPeriod.cargoBike, {
nullable: true
})
loanPeriods: LoanPeriod[];
// This relation is a little redundant because one could also check all LoanPeriods for current station
@ManyToOne(type => LendingStation, lendingStation => lendingStation.cargoBikes, {
nullable: true
})
lendingStation: LendingStation;
@Column(type => Taxes)
taxes: Taxes;
@Column({
nullable: true
})
lockedBy: number;
@Column({
type: 'date',
nullable: true
})
lockedUntil: Date;
} }

@ -0,0 +1,16 @@
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
import { CargoBike } from './CargoBike';
@Entity()
export class Equipment {
@PrimaryGeneratedColumn()
id: number;
@Column()
serialNo: string;
@OneToMany(type => CargoBike, cargoBike => cargoBike.equipment, {
nullable: true
})
cargoBike: CargoBike;
}

@ -1,10 +1,6 @@
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; import { Column } from 'typeorm';
@Entity()
export class InsuranceData { export class InsuranceData {
@PrimaryGeneratedColumn()
id: number
@Column() @Column()
name: string; name: string;

@ -0,0 +1,36 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable, OneToMany, ManyToOne } from 'typeorm';
import { ContactInformation } from './ContactInformation';
import { LoanPeriod } from './LoanPeriod';
import { CargoBike } from './CargoBike';
import { Organization } from './Organization';
@Entity()
export class LendingStation {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@ManyToMany(type => ContactInformation)
@JoinTable()
contactInformation: ContactInformation[];
@Column()
addressStreet: string;
@Column()
addressStreetNo: string;
@Column()
addressZip: string;
@OneToMany(type => LoanPeriod, loanPeriod => loanPeriod.lendingStation)
loanPeriods: LoanPeriod[];
@OneToMany(type => CargoBike, cargoBike => cargoBike.lendingStation)
cargoBikes: CargoBike[];
@ManyToOne(type => Organization, organization => organization.lendingStations)
organization: Organization;
}

@ -0,0 +1,26 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
import { LendingStation } from './LendingStation';
import { CargoBike } from './CargoBike';
@Entity()
export class LoanPeriod {
@PrimaryGeneratedColumn()
id: number;
// I have to find out how typorm will map the datetange data type.
@Column({
type: 'daterange'
})
dateRange: Date[];
@ManyToOne(type => LendingStation, lendingStation => lendingStation.loanPeriods)
lendingStation: LendingStation;
@Column({
nullable: true
})
note: string;
@ManyToOne(type => CargoBike, cargoBike => cargoBike.loanPeriods)
cargoBike: CargoBike;
}

@ -0,0 +1,26 @@
import { PrimaryGeneratedColumn, OneToOne, OneToMany, Column } from 'typeorm';
import { LendingStation } from './LendingStation';
import { Provider } from './Provider';
export class Organization {
@PrimaryGeneratedColumn()
id: number;
@OneToMany(type => LendingStation, lendingStation => lendingStation.organization)
lendingStations: LendingStation[];
@OneToOne(type => Provider, provider => provider.organization, {
nullable: true
})
provider: Provider;
@Column({
nullable: true
})
registerdAt: string;
@Column({
nullable: true
})
registerNo: string;
}

@ -1,7 +1,9 @@
/* eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from 'typeorm'; import { PrimaryGeneratedColumn, Column, OneToMany, Entity, OneToOne } from 'typeorm';
import { ContactInformation } from './ContactInformation'; import { ContactInformation } from './ContactInformation';
import { LendingStation } from './LendingStation';
import { Organization } from './Organization';
@Entity() @Entity()
export class Provider { export class Provider {
@ -11,7 +13,9 @@ export class Provider {
@Column() @Column()
name: string; name: string;
@Column() @Column({
nullable: false
})
formularName: String; formularName: String;
@Column() @Column()
@ -23,12 +27,14 @@ export class Provider {
@Column() @Column()
zip: string; zip: string;
@Column() @OneToMany(type => ContactInformation, contactInformation => contactInformation.provider)
registerdAt: string; contactInformation: ContactInformation[];
@Column() @Column()
registerNo: string; isPrivatePerson: boolean;
@OneToMany(type => ContactInformation, contactInformation => contactInformation.provider) @OneToOne(type => Organization, organization => organization.provider, {
contactInformation: ContactInformation[]; nullable: true
})
organization: Organization;
} }

@ -0,0 +1,18 @@
/* eslint no-unused-vars: "off" */
import { Column } from 'typeorm';
export enum OrganizationArea {
IB,
ZB
}
export class Taxes {
@Column()
costCenter: string;
@Column({
type: 'enum',
enum: OrganizationArea,
nullable: true
})
organizationArea: OrganizationArea;
}

@ -41,8 +41,10 @@ type CargoBike {
coordinator: Participant coordinator: Participant
insuranceData: InsuranceData! insuranceData: InsuranceData!
lendingstation: LendingStation lendingstation: LendingStation
taxes: Taxes
"null if not locked by other user" "null if not locked by other user"
lockedBy: ID lockedBy: ID
lockedUntil: Date
} }
type InsuranceData { type InsuranceData {
@ -82,7 +84,7 @@ Even bikes of the same model can have different properties.
""" """
type BikeModel { type BikeModel {
id: ID! id: ID!
name: String name: String!
dimensionsAndLoad: DimensionsAndLoad! dimensionsAndLoad: DimensionsAndLoad!
technicalEquipment: TechnicalEquipment! technicalEquipment: TechnicalEquipment!
} }
@ -147,7 +149,7 @@ type Equipment {
id: ID! id: ID!
serialNo: String! serialNo: String!
""" """
TODO unclear what this means TODO unclear what this means. tomy fragen
""" """
investable: Boolean investable: Boolean
name: String name: String
@ -156,10 +158,8 @@ type Equipment {
"An Event is a point in time, when the state of the bike somehow changed." "An Event is a point in time, when the state of the bike somehow changed."
type BikeEvent { type BikeEvent {
id: ID! id: ID!
type: BikeEventType eventType: BikeEventType
""" date: Date!
TODO: An Event should have a date field (Leon).
"""
note: String note: String
""" """
Path to documents Path to documents
@ -238,9 +238,7 @@ type Provider {
name: String! name: String!
formularName: String formularName: String
address: Address address: Address
"If Club, at what court registered"
registeredAt: String
registerNumber: String
providerContactPerson: [ContactInformation] providerContactPerson: [ContactInformation]
isPrivatePerson: Boolean! isPrivatePerson: Boolean!
organisation: Organisation organisation: Organisation
@ -266,15 +264,19 @@ type ContactInformation {
type Organisation{ type Organisation{
id: ID! id: ID!
"(dt. Ausleihstation)" "(dt. Ausleihstation)"
lendinglocation: [LendingStation] lendingStations: [LendingStation]
"registration number of association" "registration number of association"
associationNo: String associationNo: String
"If Club, at what court registered"
registeredAt: String
provider: Provider
otherdata: String otherdata: String
} }
"(dt. Standort)" "(dt. Standort)"
type LendingStation { type LendingStation {
id: ID! id: ID!
name: String!
contactInformation: [ContactInformation]! contactInformation: [ContactInformation]!
address: Address address: Address
loanTimes: LoanTimes loanTimes: LoanTimes
@ -322,8 +324,8 @@ type Query {
CargobikesByProvider(token:String!,providerId:ID!): [CargoBike]! CargobikesByProvider(token:String!,providerId:ID!): [CargoBike]!
ProviderById(token:String!,id:ID!): Provider ProviderById(token:String!,id:ID!): Provider
Providers(token:String!): [Provider]! Providers(token:String!): [Provider]!
ParticipantById(token:String!,id:ID!): Participant ParticipantById(token:String!,id:ID!): Participant
Participants(token:String!): [ Participant]! Participants(token:String!): [ Participant]!
lendingStationById(token:String!, id:ID!): LendingStation lendingStationById(token:String!, id:ID!): LendingStation
lendingStations(token:String!): [LendingStation]! lendingStations(token:String!): [LendingStation]!
contactInformation(token:String!): [ContactInformation]! contactInformation(token:String!): [ContactInformation]!

Loading…
Cancel
Save