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

@ -1,5 +1,5 @@
/* 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';
export enum BikeEventType {
@ -7,14 +7,15 @@ export enum BikeEventType {
INBETRIEBNAHME = 'INBETRIEBNAHME',
AUSFALL = 'AUSFALL',
WARTUNG = 'WARTUNG',
KETTENWECHSEL = 'KETTENWECHSEL',
ANDERE = 'ANDERE'
}
@Entity()
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.note = note;
this.remark = remark;
this.date = date;
this.documents = documents;
this.cargoBike = cargoBike;
@ -27,13 +28,28 @@ export class BikeEvent {
@Column({
nullable: true
})
note: string;
name: string;
@Column({
nullable: true
})
remark: string;
@Column({
type: 'date'
})
date: Date;
@Column({
nullable: true
})
mechanic: string;
@Column({
nullable: true
})
kexNoOldAXAChain: string;
@Column('simple-array', {
nullable: true
})

@ -1,7 +1,6 @@
/* eslint no-unused-vars: "off" */
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne, JoinColumn } from 'typeorm';
import { Bike } from './BikeFeatures';
import { ChainSwap } from './ChainSwap';
import { Provider } from './Provider';
import { Participant } from './Participant';
import { InsuranceData } from './InsuranceData';
@ -81,12 +80,7 @@ export class CargoBike extends Bike {
type: 'simple-array',
nullable: true
})
otherEquipment: string[];
@OneToMany(type => ChainSwap, chainSwap => chainSwap.cargoBike, {
nullable: true
})
chainSwaps: ChainSwap[]
miscellaneousEquipment: string[];
// Security information
@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 { Provider } from './Provider';
import { PrimaryGeneratedColumn, Column, Entity } from 'typeorm';
@Entity()
export class ContactInformation {
@ -50,7 +49,4 @@ export class ContactInformation {
@Column()
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
})
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 { ContactInformation } from './ContactInformation';
import { LoanPeriod } from './LoanPeriod';
import { CargoBike } from './CargoBike';
import { Organization } from './Organization';
import { Address } from './Provider';
import { ContactPerson } from './ContactPerson';
@Entity()
export class LendingStation {
@ -13,9 +13,9 @@ export class LendingStation {
@Column()
name: string;
@ManyToMany(type => ContactInformation)
@ManyToMany(type => ContactPerson)
@JoinTable()
contactInformation: ContactInformation[];
contactPersons: ContactPerson[];
@Column(type => Address)
address: Address;

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

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

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

@ -7,7 +7,13 @@ export class Workshop {
id: number;
@Column()
name: string;
type: string;
@Column()
title: string;
@Column()
description: string;
@Column({
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]
equipment: [Equipment]
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String]
miscellaneousEquipment: [String]
chainSwaps: [ChainSwap]
"Sticker State"
stickerBikeNameState: StickerBikeNameState
@ -69,7 +69,7 @@ input CargoBikeCreateInput {
"""
dimensionsAndLoad: DimensionsAndLoadCreateInput!
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String]
miscellaneousEquipment: [String]
"Sticker State"
stickerBikeNameState: StickerBikeNameState
@ -103,7 +103,7 @@ input CargoBikeUpdateInput {
"""
dimensionsAndLoad: DimensionsAndLoadUpdateInput
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String]
miscellaneousEquipment: [String]
lendingStationId: ID
"Sticker State"
stickerBikeNameState: StickerBikeNameState
@ -223,6 +223,13 @@ type Participant {
"""
distributedActiveBikeParte: Boolean!
reserve: String
engagement: Engagement
}
type Engagement {
id: ID!
participant: Participant
cargobike: CargoBike
}
type Taxes {
@ -449,7 +456,7 @@ type Provider {
id: ID!
name: String!
formularName: String
address: Address
providerContactPerson: [ContactInformation]
isPrivatePerson: Boolean!
@ -498,8 +505,28 @@ input ContactInformationUpdateInput {
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 {
id: ID!
address: Address
"(dt. Ausleihstation)"
lendingStations: [LendingStation]
"registration number of association"

Loading…
Cancel
Save