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 ./package*.json ./
COPY ./gulpfile.js ./tsconfig.json ./
COPY ./gulpfile.js ./
COPY ./ormconfig.json ./
RUN npm install
RUN npm install -g gulp
@ -11,5 +11,5 @@ RUN npm install gulp
RUN gulp
EXPOSE 4000
EXPOSE 5432
CMD ["npm", "start"]

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

@ -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 { Participant } from './Participant';
import { InsuranceData } from './InsuranceData';
import { LoanPeriod } from './LoanPeriod';
import { LendingStation } from './LendingStation';
import { Taxes } from './Taxes';
import { Equipment } from './Equipment';
export enum Group {
KL,
@ -40,7 +44,19 @@ export class CargoBike extends Bike {
@Column()
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[]
// Security information
@ -68,12 +84,39 @@ export class CargoBike extends Bike {
@Column()
note: string;
@ManyToOne(type => Provider)
@ManyToOne(type => Provider, {
nullable: true
})
provider: Provider;
@ManyToOne(type => Participant, participant => participant.cargoBikes)
coordinator: Participant;
@OneToOne(type => InsuranceData)
@Column(type => 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 {
@PrimaryGeneratedColumn()
id: number
@Column()
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" */
import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from 'typeorm';
import { PrimaryGeneratedColumn, Column, OneToMany, Entity, OneToOne } from 'typeorm';
import { ContactInformation } from './ContactInformation';
import { LendingStation } from './LendingStation';
import { Organization } from './Organization';
@Entity()
export class Provider {
@ -11,7 +13,9 @@ export class Provider {
@Column()
name: string;
@Column()
@Column({
nullable: false
})
formularName: String;
@Column()
@ -23,12 +27,14 @@ export class Provider {
@Column()
zip: string;
@Column()
registerdAt: string;
@OneToMany(type => ContactInformation, contactInformation => contactInformation.provider)
contactInformation: ContactInformation[];
@Column()
registerNo: string;
isPrivatePerson: boolean;
@OneToMany(type => ContactInformation, contactInformation => contactInformation.provider)
contactInformation: ContactInformation[];
@OneToOne(type => Organization, organization => organization.provider, {
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
insuranceData: InsuranceData!
lendingstation: LendingStation
taxes: Taxes
"null if not locked by other user"
lockedBy: ID
lockedUntil: Date
}
type InsuranceData {
@ -82,7 +84,7 @@ Even bikes of the same model can have different properties.
"""
type BikeModel {
id: ID!
name: String
name: String!
dimensionsAndLoad: DimensionsAndLoad!
technicalEquipment: TechnicalEquipment!
}
@ -147,7 +149,7 @@ type Equipment {
id: ID!
serialNo: String!
"""
TODO unclear what this means
TODO unclear what this means. tomy fragen
"""
investable: Boolean
name: String
@ -156,10 +158,8 @@ type Equipment {
"An Event is a point in time, when the state of the bike somehow changed."
type BikeEvent {
id: ID!
type: BikeEventType
"""
TODO: An Event should have a date field (Leon).
"""
eventType: BikeEventType
date: Date!
note: String
"""
Path to documents
@ -238,9 +238,7 @@ type Provider {
name: String!
formularName: String
address: Address
"If Club, at what court registered"
registeredAt: String
registerNumber: String
providerContactPerson: [ContactInformation]
isPrivatePerson: Boolean!
organisation: Organisation
@ -266,15 +264,19 @@ type ContactInformation {
type Organisation{
id: ID!
"(dt. Ausleihstation)"
lendinglocation: [LendingStation]
lendingStations: [LendingStation]
"registration number of association"
associationNo: String
"If Club, at what court registered"
registeredAt: String
provider: Provider
otherdata: String
}
"(dt. Standort)"
type LendingStation {
id: ID!
name: String!
contactInformation: [ContactInformation]!
address: Address
loanTimes: LoanTimes
@ -322,8 +324,8 @@ type Query {
CargobikesByProvider(token:String!,providerId:ID!): [CargoBike]!
ProviderById(token:String!,id:ID!): Provider
Providers(token:String!): [Provider]!
ParticipantById(token:String!,id:ID!): Participant
Participants(token:String!): [ Participant]!
ParticipantById(token:String!,id:ID!): Participant
Participants(token:String!): [ Participant]!
lendingStationById(token:String!, id:ID!): LendingStation
lendingStations(token:String!): [LendingStation]!
contactInformation(token:String!): [ContactInformation]!

Loading…
Cancel
Save