From c06bb1d1f1e483d4ed04495e9077ef66c38cb7f9 Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Mon, 14 Sep 2020 23:57:49 +0200 Subject: [PATCH] src/model/*: added insuranceData and participants --- src/model/CargoBike.ts | 14 ++++++++++- src/model/InsuranceData.ts | 48 ++++++++++++++++++++++++++++++++++++++ src/model/Participant.ts | 6 ++++- src/schema/type-defs.ts | 41 +++++++++++++++++++++++++------- 4 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 src/model/InsuranceData.ts diff --git a/src/model/CargoBike.ts b/src/model/CargoBike.ts index 019c192..55a2bff 100644 --- a/src/model/CargoBike.ts +++ b/src/model/CargoBike.ts @@ -1,7 +1,10 @@ /* eslint no-unused-vars: "off" */ -import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'; +import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, OneToOne } from 'typeorm'; import { Bike } from './BikeFeatures'; import { ChainSwap } from './ChainSwap'; +import { Provider } from './Provider'; +import { Participant } from './Participant'; +import { InsuranceData } from './InsuranceData'; export enum Group { KL, @@ -64,4 +67,13 @@ export class CargoBike extends Bike { @Column() note: string; + + @ManyToOne(type => Provider) + provider: Provider; + + @ManyToOne(type => Participant, participant => participant.cargoBikes) + coordinator: Participant; + + @OneToOne(type => InsuranceData) + insuranceData: InsuranceData; } diff --git a/src/model/InsuranceData.ts b/src/model/InsuranceData.ts new file mode 100644 index 0000000..564489e --- /dev/null +++ b/src/model/InsuranceData.ts @@ -0,0 +1,48 @@ +import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; + +@Entity() +export class InsuranceData { + @PrimaryGeneratedColumn() + id: number + + @Column() + name: string; + + @Column() + benefector: string; + + @Column() + noPnP: string; + + @Column() + maintananceResponisble: string; + + @Column() + maintanceBenfector: string; + + @Column({ + nullable: true + }) + maintanceAgreement: string; + + @Column({ + nullable: true + }) + hasFixedRate: boolean; + + @Column({ + nullable: true + }) + fixedRate: number; + + @Column({ + type: 'money', + nullable: true + }) + projectAllowance: number; + + @Column({ + nullable: true + }) + note: string; +} diff --git a/src/model/Participant.ts b/src/model/Participant.ts index 869a1ce..5319f20 100644 --- a/src/model/Participant.ts +++ b/src/model/Participant.ts @@ -1,5 +1,6 @@ -import { Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn } from 'typeorm'; +import { Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn, OneToMany } from 'typeorm'; import { ContactInformation } from './ContactInformation'; +import { CargoBike } from './CargoBike'; @Entity() export class Participant { @@ -34,6 +35,9 @@ export class Participant { }) locationZIPs: string[]; + @OneToMany(type => CargoBike, cargoBike => cargoBike.coordinator) + cargoBikes: CargoBike[]; + @Column() roleCoreTeam: boolean; diff --git a/src/schema/type-defs.ts b/src/schema/type-defs.ts index 4766aa5..704930d 100644 --- a/src/schema/type-defs.ts +++ b/src/schema/type-defs.ts @@ -38,9 +38,9 @@ type CargoBike { stickerBikeNameState: StickerBikeNameState note: String provider: Provider - coordinator: Participants - insuranceData: InsuranceData - loantimes: [LoanTimes] + coordinator: Participant + insuranceData: InsuranceData! + lendingstation: LendingStation "null if not locked by other user" lockedBy: ID } @@ -49,8 +49,19 @@ type InsuranceData { """ Eventuelly, this field will become an enum or a seperate data table and user can choose from a pool of insurance companies. """ - name: String - + name: String! + benefactor: String! + billing: String! + noPnP: String! + "eg. Anbieter, flotte, eigenleistung" + maintananceResponsible: String! + maintanceBenefector: String! + maintananceAgreement: String + hasFixedRate: Boolean! + fixedRate: Float + "Projektzuschuss" + projectAllowance: Float + notes: String } enum Group{ @@ -76,7 +87,7 @@ type BikeModel { technicalEquipment: TechnicalEquipment! } -type Participants { +type Participant { id: ID! start: Date! end: Date! @@ -273,6 +284,20 @@ type LendingStation { "(dt. Ausleihzeiten)" type LoanTimes { notes: String + mof: String + mot: String + tuf: String + tut: String + wef: String + wet: String + thf: String + tht: String + frf: String + frt: String + saf: String + sat: String + suf: String + sut: String } "(dt. Zeitscheibe)" @@ -297,8 +322,8 @@ type Query { CargobikesByProvider(token:String!,providerId:ID!): [CargoBike]! ProviderById(token:String!,id:ID!): Provider Providers(token:String!): [Provider]! - ParticipantsById(token:String!,id:ID!): Participants - Participantss(token:String!): [ Participants]! + ParticipantById(token:String!,id:ID!): Participant + Participants(token:String!): [ Participant]! lendingStationById(token:String!, id:ID!): LendingStation lendingStations(token:String!): [LendingStation]! contactInformation(token:String!): [ContactInformation]!