sr/model/* included suggested changes from fLotte

pull/11/head
leonnicolas 4 years ago
parent 297b5592e5
commit 8f5d98c975
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -1,7 +1,6 @@
import { DataSource } from 'apollo-datasource'; import { DataSource } from 'apollo-datasource';
import { GraphQLError } from 'graphql'; import { GraphQLError } from 'graphql';
import { Connection, getConnection } from 'typeorm'; import { Connection, getConnection } from 'typeorm';
import { CargoBike } from '../../model/CargoBike';
import { LendingStation } from '../../model/LendingStation'; import { LendingStation } from '../../model/LendingStation';
export class LendingStationAPI extends DataSource { export class LendingStationAPI extends DataSource {

@ -0,0 +1,22 @@
import { DataSource } from 'apollo-datasource';
import { Connection, getConnection } from 'typeorm';
export class ParticipantAPI extends DataSource {
connection : Connection
constructor () {
super();
this.connection = getConnection();
}
async getParticipantById (id: number) {
return {
id: 2
};
}
async engagementByParticipantId (id: number) {
return {
id: 3
};
}
}

@ -10,7 +10,6 @@ import { requiredPermissions } from './datasources/userserver/permission';
import { CargoBike } from './model/CargoBike'; import { CargoBike } from './model/CargoBike';
import { BikeEvent } from './model/BikeEvent'; import { BikeEvent } from './model/BikeEvent';
import { BikeModel } from './model/BikeModel'; import { BikeModel } from './model/BikeModel';
import { ChainSwap } from './model/ChainSwap';
import { ContactInformation } from './model/ContactInformation'; import { ContactInformation } from './model/ContactInformation';
import { Equipment } from './model/Equipment'; import { Equipment } from './model/Equipment';
import { LendingStation } from './model/LendingStation'; import { LendingStation } from './model/LendingStation';
@ -22,6 +21,9 @@ import { Engagement } from './model/Engagement';
import { Workshop } from './model/Workshop'; import { Workshop } from './model/Workshop';
import { LendingStationAPI } from './datasources/db/lendingstationAPI'; import { LendingStationAPI } from './datasources/db/lendingstationAPI';
import lendingstationResolvers from './resolvers/lendingstationResolvers'; import lendingstationResolvers from './resolvers/lendingstationResolvers';
import { ParticipantAPI } from './datasources/db/participantAPI';
import participantResolvers from './resolvers/participantResolvers';
import { ContactPerson } from './model/ContactPerson';
require('dotenv').config(); require('dotenv').config();
@ -59,7 +61,6 @@ createConnection({
CargoBike, CargoBike,
BikeEvent, BikeEvent,
BikeModel, BikeModel,
ChainSwap,
ContactInformation, ContactInformation,
Equipment, Equipment,
LendingStation, LendingStation,
@ -68,7 +69,8 @@ createConnection({
Participant, Participant,
Provider, Provider,
Engagement, Engagement,
Workshop Workshop,
ContactPerson
], ],
synchronize: true, synchronize: true,
logging: false logging: false
@ -81,12 +83,14 @@ const userAPI = new UserServerAPI(process.env.RPC_HOST);
const server = new ApolloServer({ const server = new ApolloServer({
resolvers: [ resolvers: [
bikeresolver, bikeresolver,
lendingstationResolvers lendingstationResolvers,
participantResolvers
], ],
typeDefs, typeDefs,
dataSources: () => ({ dataSources: () => ({
cargoBikeAPI: new CargoBikeAPI(), cargoBikeAPI: new CargoBikeAPI(),
lendingStationAPI: new LendingStationAPI(), lendingStationAPI: new LendingStationAPI(),
participantAPI: new ParticipantAPI(),
userAPI userAPI
}), }),
context: (req: any) => { context: (req: any) => {

@ -1,5 +1,5 @@
/* eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm'; import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn, TreeLevelColumn } from 'typeorm';
import { CargoBike } from './CargoBike'; import { CargoBike } from './CargoBike';
export enum BikeEventType { export enum BikeEventType {
@ -7,14 +7,15 @@ export enum BikeEventType {
INBETRIEBNAHME = 'INBETRIEBNAHME', INBETRIEBNAHME = 'INBETRIEBNAHME',
AUSFALL = 'AUSFALL', AUSFALL = 'AUSFALL',
WARTUNG = 'WARTUNG', WARTUNG = 'WARTUNG',
KETTENWECHSEL = 'KETTENWECHSEL',
ANDERE = 'ANDERE' ANDERE = 'ANDERE'
} }
@Entity() @Entity()
export class BikeEvent { export class BikeEvent {
public setValues ({ id, note, date, documents, cargoBike, eventType }: { id: number, note: string, date: Date, documents: string[], cargoBike: CargoBike, eventType: BikeEventType}): void { public setValues ({ id, remark, date, documents, cargoBike, eventType }: { id: number, remark: string, date: Date, documents: string[], cargoBike: CargoBike, eventType: BikeEventType}): void {
this.id = id; this.id = id;
this.note = note; this.remark = remark;
this.date = date; this.date = date;
this.documents = documents; this.documents = documents;
this.cargoBike = cargoBike; this.cargoBike = cargoBike;
@ -27,13 +28,28 @@ export class BikeEvent {
@Column({ @Column({
nullable: true nullable: true
}) })
note: string; name: string;
@Column({
nullable: true
})
remark: string;
@Column({ @Column({
type: 'date' type: 'date'
}) })
date: Date; date: Date;
@Column({
nullable: true
})
mechanic: string;
@Column({
nullable: true
})
kexNoOldAXAChain: string;
@Column('simple-array', { @Column('simple-array', {
nullable: true nullable: true
}) })

@ -1,7 +1,6 @@
/* eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, JoinColumn } from 'typeorm'; import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, JoinColumn } from 'typeorm';
import { Bike } from './BikeFeatures'; import { Bike } from './BikeFeatures';
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';
@ -81,12 +80,7 @@ export class CargoBike extends Bike {
type: 'simple-array', type: 'simple-array',
nullable: true nullable: true
}) })
otherEquipment: string[]; miscellaneousEquipment: string[];
@OneToMany(type => ChainSwap, chainSwap => chainSwap.cargoBike, {
nullable: true
})
chainSwaps: ChainSwap[]
// Security information // Security information
@Column(type => Security) @Column(type => Security)

@ -1,22 +0,0 @@
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
import { CargoBike } from './CargoBike';
@Entity()
export class ChainSwap {
@PrimaryGeneratedColumn()
id: number;
@Column()
mechanic: string;
@Column({
type: 'date'
})
time: Date;
@Column()
kexNoOldAXAChain: string;
@ManyToOne(type => CargoBike, cargoBike => cargoBike.chainSwaps)
cargoBike: CargoBike;
}

@ -1,5 +1,4 @@
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from 'typeorm'; import { PrimaryGeneratedColumn, Column, Entity } from 'typeorm';
import { Provider } from './Provider';
@Entity() @Entity()
export class ContactInformation { export class ContactInformation {
@ -50,7 +49,4 @@ export class ContactInformation {
@Column() @Column()
note: string; note: string;
@ManyToOne(type => Provider, provider => provider.contactInformation)
provider: Provider;
} }

@ -0,0 +1,28 @@
import { Column, Entity, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { ContactInformation } from './ContactInformation';
import { LendingStation } from './LendingStation';
import { Provider } from './Provider';
@Entity()
export class ContactPerson {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(type => ContactInformation)
contactInformation: ContactInformation;
@ManyToMany(type => LendingStation, lendingStation => lendingStation.contactPersons, {
nullable: true
})
lendingStation: LendingStation;
@ManyToMany(type => Provider, provider => provider.contactPersons, {
nullable: true
})
provider: Provider[];
@Column({
type: 'boolean'
})
intern: boolean;
}

@ -23,4 +23,19 @@ export class Engagement {
nullable: true nullable: true
}) })
to: Date; to: Date;
@Column()
roleCoordinator: boolean;
@Column()
roleEmployeADFC: boolean;
@Column()
roleMentor: boolean;
@Column()
roleAmbulance: boolean;
@Column()
roleBringer: boolean;
} }

@ -1,9 +1,9 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable, OneToMany, ManyToOne } from 'typeorm'; import { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable, OneToMany, ManyToOne } from 'typeorm';
import { ContactInformation } from './ContactInformation';
import { LoanPeriod } from './LoanPeriod'; import { LoanPeriod } from './LoanPeriod';
import { CargoBike } from './CargoBike'; import { CargoBike } from './CargoBike';
import { Organization } from './Organization'; import { Organization } from './Organization';
import { Address } from './Provider'; import { Address } from './Provider';
import { ContactPerson } from './ContactPerson';
@Entity() @Entity()
export class LendingStation { export class LendingStation {
@ -13,9 +13,9 @@ export class LendingStation {
@Column() @Column()
name: string; name: string;
@ManyToMany(type => ContactInformation) @ManyToMany(type => ContactPerson)
@JoinTable() @JoinTable()
contactInformation: ContactInformation[]; contactPersons: ContactPerson[];
@Column(type => Address) @Column(type => Address)
address: Address; address: Address;

@ -1,6 +1,6 @@
import { PrimaryGeneratedColumn, OneToOne, OneToMany, Column, Entity } from 'typeorm'; import { PrimaryGeneratedColumn, OneToOne, OneToMany, Column, Entity } from 'typeorm';
import { LendingStation } from './LendingStation'; import { LendingStation } from './LendingStation';
import { Provider } from './Provider'; import { Address, Provider } from './Provider';
@Entity() @Entity()
export class Organization { export class Organization {
@ -25,4 +25,7 @@ export class Organization {
nullable: true nullable: true
}) })
registerNo: string; registerNo: string;
@Column(type => Address)
address: Address;
} }

@ -15,7 +15,8 @@ export class Participant {
start: Date; start: Date;
@Column({ @Column({
type: 'date' type: 'date',
nullable: true
}) })
end: Date; end: Date;
@ -49,22 +50,7 @@ export class Participant {
workshops: Workshop[]; workshops: Workshop[];
@Column() @Column()
roleCoreTeam: boolean; memberCoreTeam: boolean;
@Column()
roleCoordinator: boolean;
@Column()
roleEmployeADFC: boolean;
@Column()
roleMentor: boolean;
@Column()
roleAmbulance: boolean;
@Column()
roleBringer: boolean;
@Column({ @Column({
type: 'date' type: 'date'

@ -1,7 +1,8 @@
/* eslint no-unused-vars: "off" */ /* eslint no-unused-vars: "off" */
import { PrimaryGeneratedColumn, Column, OneToMany, Entity, OneToOne } from 'typeorm'; import { PrimaryGeneratedColumn, Column, OneToMany, Entity, OneToOne, ChildEntity } from 'typeorm';
import { ContactInformation } from './ContactInformation'; import { ContactInformation } from './ContactInformation';
import { ContactPerson } from './ContactPerson';
import { LendingStation } from './LendingStation'; import { LendingStation } from './LendingStation';
import { Organization } from './Organization'; import { Organization } from './Organization';
@ -14,6 +15,11 @@ export class Address {
@Column() @Column()
zip: string; zip: string;
@Column({
nullable: true
})
city: string;
} }
@Entity() @Entity()
@ -21,19 +27,15 @@ export class Provider {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Column()
name: string;
@Column({ @Column({
nullable: false nullable: false
}) })
formularName: String; formularName: String;
@Column(type => Address) @OneToMany(type => ContactPerson, contactPerson => contactPerson.provider, {
address: Address; nullable: true
})
@OneToMany(type => ContactInformation, contactInformation => contactInformation.provider) contactPersons: ContactPerson[];
contactInformation: ContactInformation[];
@Column() @Column()
isPrivatePerson: boolean; isPrivatePerson: boolean;

@ -7,7 +7,13 @@ export class Workshop {
id: number; id: number;
@Column() @Column()
name: string; type: string;
@Column()
title: string;
@Column()
description: string;
@Column({ @Column({
type: 'date' type: 'date'

@ -0,0 +1,19 @@
import { GraphQLError } from 'graphql';
import { Permission } from '../datasources/userserver/permission';
export default {
Query: {
participantById: (_: any, { id }: { id: any }, { dataSources, req }: { dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.ReadBike)) {
return dataSources.participantAPI.getParticipantById(id);
} else {
return new GraphQLError('Insufficient Permissions');
}
}
},
Participant: {
engagement (parent: any, _: any, { dataSources, req }: { dataSources: any, req: any }) {
return dataSources.participantAPI.engagementByParticipantId(parent.id);
}
}
};

@ -31,7 +31,7 @@ type CargoBike {
bikeEvents: [BikeEvent] bikeEvents: [BikeEvent]
equipment: [Equipment] equipment: [Equipment]
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2" "Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String] miscellaneousEquipment: [String]
chainSwaps: [ChainSwap] chainSwaps: [ChainSwap]
"Sticker State" "Sticker State"
stickerBikeNameState: StickerBikeNameState stickerBikeNameState: StickerBikeNameState
@ -69,7 +69,7 @@ input CargoBikeCreateInput {
""" """
dimensionsAndLoad: DimensionsAndLoadCreateInput! dimensionsAndLoad: DimensionsAndLoadCreateInput!
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2" "Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String] miscellaneousEquipment: [String]
"Sticker State" "Sticker State"
stickerBikeNameState: StickerBikeNameState stickerBikeNameState: StickerBikeNameState
@ -103,7 +103,7 @@ input CargoBikeUpdateInput {
""" """
dimensionsAndLoad: DimensionsAndLoadUpdateInput dimensionsAndLoad: DimensionsAndLoadUpdateInput
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2" "Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String] miscellaneousEquipment: [String]
lendingStationId: ID lendingStationId: ID
"Sticker State" "Sticker State"
stickerBikeNameState: StickerBikeNameState stickerBikeNameState: StickerBikeNameState
@ -223,6 +223,13 @@ type Participant {
""" """
distributedActiveBikeParte: Boolean! distributedActiveBikeParte: Boolean!
reserve: String reserve: String
engagement: Engagement
}
type Engagement {
id: ID!
participant: Participant
cargobike: CargoBike
} }
type Taxes { type Taxes {
@ -449,7 +456,7 @@ type Provider {
id: ID! id: ID!
name: String! name: String!
formularName: String formularName: String
address: Address
providerContactPerson: [ContactInformation] providerContactPerson: [ContactInformation]
isPrivatePerson: Boolean! isPrivatePerson: Boolean!
@ -498,8 +505,28 @@ input ContactInformationUpdateInput {
note: String note: String
} }
type contactPerson {
id: ID!
intern: Boolean!
contactInformation: ContactInformation!
}
input contactPersonCreateInput {
intern: Boolean!
contactInformationCreate: ContactInformationCreateInput
contactInformationExisting: ContactInformationUpdateInput
}
input contactPersonUpdateInput {
id: ID!
intern: Boolean
contactInformationCreate: ContactInformationCreateInput
contactInformationExisting: ContactInformationUpdateInput
}
type Organisation { type Organisation {
id: ID! id: ID!
address: Address
"(dt. Ausleihstation)" "(dt. Ausleihstation)"
lendingStations: [LendingStation] lendingStations: [LendingStation]
"registration number of association" "registration number of association"

Loading…
Cancel
Save