src/model/*: added Workshop and Engagement.

pull/8/head
leonnicolas 4 years ago
parent 91e0c8f9e9
commit cfa0e14f8e
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -0,0 +1,14 @@
import { DataSource } from 'apollo-datasource';
import { Connection, getConnection } from 'typeorm';
export class LendingStationAPI extends DataSource {
connection : Connection
constructor () {
super();
this.connection = getConnection();
}
async updateLendingStation ({ lendingStation }:{ lendingStation: any }) {
return lendingStation;
}
}

@ -18,6 +18,8 @@ import { LoanPeriod } from './model/LoanPeriod';
import { Participant } from './model/Participant'; import { Participant } from './model/Participant';
import { Organization } from './model/Organization'; import { Organization } from './model/Organization';
import { Provider } from './model/Provider'; import { Provider } from './model/Provider';
import { Engagement } from './model/Engagement';
import { Workshop } from './model/Workshop';
require('dotenv').config(); require('dotenv').config();
@ -62,7 +64,9 @@ createConnection({
LoanPeriod, LoanPeriod,
Organization, Organization,
Participant, Participant,
Provider Provider,
Engagement,
Workshop
], ],
synchronize: true, synchronize: true,
logging: false logging: false

@ -9,6 +9,7 @@ import { LoanPeriod } from './LoanPeriod';
import { LendingStation } from './LendingStation'; import { LendingStation } from './LendingStation';
import { Taxes } from './Taxes'; import { Taxes } from './Taxes';
import { Equipment } from './Equipment'; import { Equipment } from './Equipment';
import { Engagement } from './Engagement';
export enum Group { export enum Group {
KL = 'KL', KL = 'KL',
@ -125,6 +126,9 @@ export class CargoBike extends Bike {
}) })
lendingStation: LendingStation; lendingStation: LendingStation;
@OneToMany(type => Engagement, engagement => engagement.cargoBike)
engagement: Engagement[];
@Column(type => Taxes) @Column(type => Taxes)
taxes: Taxes; taxes: Taxes;

@ -0,0 +1,26 @@
import { Entity, PrimaryGeneratedColumn, ManyToOne, Column } from 'typeorm';
import { Participant } from './Participant';
import { CargoBike } from './CargoBike';
@Entity()
export class Engagement {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(type => Participant, participant => participant.engagement)
participant: Participant;
@ManyToOne(type => CargoBike, cargoBike => cargoBike.engagement)
cargoBike: CargoBike;
@Column({
type: 'date'
})
from: Date;
@Column({
type: 'date',
nullable: true
})
to: Date;
}

@ -1,6 +1,8 @@
import { Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn, OneToMany } from 'typeorm'; import { Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn, OneToMany, ManyToMany } from 'typeorm';
import { ContactInformation } from './ContactInformation'; import { ContactInformation } from './ContactInformation';
import { CargoBike } from './CargoBike'; import { CargoBike } from './CargoBike';
import { Engagement } from './Engagement';
import { Workshop } from './Workshop';
@Entity() @Entity()
export class Participant { export class Participant {
@ -38,6 +40,14 @@ export class Participant {
@OneToMany(type => CargoBike, cargoBike => cargoBike.coordinator) @OneToMany(type => CargoBike, cargoBike => cargoBike.coordinator)
cargoBikes: CargoBike[]; cargoBikes: CargoBike[];
@OneToMany(type => Engagement, engagement => engagement.participant)
engagement: Engagement[];
@ManyToMany(type => Workshop, workshop => workshop.participants, {
nullable: true
})
workshops: Workshop[];
@Column() @Column()
roleCoreTeam: boolean; roleCoreTeam: boolean;

@ -0,0 +1,21 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToMany } from 'typeorm';
import { Participant } from './Participant';
@Entity()
export class Workshop {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column({
type: 'date'
})
date: Date;
@ManyToMany(type => Participant, participant => participant.workshops, {
nullable: true
})
participants: Participant[];
}

@ -7,7 +7,7 @@ export default {
if (req.permissions.includes(Permission.ReadBike)) { if (req.permissions.includes(Permission.ReadBike)) {
return dataSources.cargoBikeAPI.findCargoBikeById({ id }); return dataSources.cargoBikeAPI.findCargoBikeById({ id });
} else { } else {
throw new GraphQLError('Insufficient Permissions'); return new GraphQLError('Insufficient Permissions');
} }
} }
}, },
@ -16,14 +16,14 @@ export default {
if (req.permissions.includes(Permission.WriteBike)) { if (req.permissions.includes(Permission.WriteBike)) {
return dataSources.cargoBikeAPI.updateBike({ id, name }); return dataSources.cargoBikeAPI.updateBike({ id, name });
} else { } else {
throw new GraphQLError('Insufficient Permissions'); return new GraphQLError('Insufficient Permissions');
} }
}, },
cargoBike: (_: any, { cargoBike }: { cargoBike: any }, { dataSources, req }:{dataSources: any, req: any }) => { cargoBike: (_: any, { cargoBike }: { cargoBike: any }, { dataSources, req }:{dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.WriteBike)) { if (req.permissions.includes(Permission.WriteBike)) {
return dataSources.cargoBikeAPI.updateCargoBike({ cargoBike }); return dataSources.cargoBikeAPI.updateCargoBike({ cargoBike });
} else { } else {
throw new GraphQLError('Insufficient Permissions'); return new GraphQLError('Insufficient Permissions');
} }
} }
} }

@ -0,0 +1,17 @@
import { Permission } from '../datasources/userserver/permission';
import { GraphQLError } from 'graphql';
import { LendingStation } from '../model/LendingStation';
export default {
Query: {
},
Mutation: {
lendingStation: (_: any, { lendingStation }:{ lendingStation: LendingStation }, { dataSources, req }:{dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.WriteBike)) {
return new GraphQLError('Not implemented');
} else {
return new GraphQLError('Insufficient Permissions');
}
}
}
};

@ -46,6 +46,41 @@ type CargoBike {
lockedUntil: Date lockedUntil: Date
} }
input CargoBikeInput {
"if null, then new bike will be created, else old bike will be updated."
id: ID
"see column A in info tabelle"
group: Group!
name: String!
modelName: String!
numberOfWheels: Int!
forCargo: Boolean!
forChildren: Boolean!
numberOfChildren: Int!
"""
Safety is a custom type, that stores information about security features.
TODO: Should this be calles Security?
"""
security: SecurityInput!
"""
Does not refere to an extra table in the database.
"""
technicalEquipment: TechnicalEquipmentInput!
"""
Does not refere to an extra table in the database.
"""
dimensionsAndLoad: DimensionsAndLoadInput!
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String]
"Sticker State"
stickerBikeNameState: StickerBikeNameState
note: String
provider: String
insuranceData: InsuranceDataInput!
taxes: TaxesInput
}
type InsuranceData { type InsuranceData {
""" """
Eventuelly, this field will become an enum or a seperate data table and user can choose from a pool of insurance companies. Eventuelly, this field will become an enum or a seperate data table and user can choose from a pool of insurance companies.
@ -267,6 +302,14 @@ type Security {
adfcCoding: String adfcCoding: String
} }
input SecurityInput {
frameNumber: String!
keyNumberFrameLock: String
keyNumberAXAChain: String
policeCoding: String
adfcCoding: String
}
enum StickerBikeNameState { enum StickerBikeNameState {
OK OK
IMPROVE IMPROVE
@ -300,12 +343,24 @@ type ContactInformation {
phone2Intern: String phone2Intern: String
emailExtern: String emailExtern: String
emailIntern: String emailIntern: String
note: String note: String
}
input ContactInformationInput {
id: ID
name: String
firstName: String
retiredAt: Date
phoneExtern: String
phone2Extern: String
phoneIntern: String
phone2Intern: String
emailExtern: String
emailIntern: String
note: String
} }
type Organisation{ type Organisation {
id: ID! id: ID!
"(dt. Ausleihstation)" "(dt. Ausleihstation)"
lendingStations: [LendingStation] lendingStations: [LendingStation]
@ -322,11 +377,20 @@ type LendingStation {
id: ID! id: ID!
name: String! name: String!
contactInformation: [ContactInformation]! contactInformation: [ContactInformation]!
address: Address address: Address!
loanTimes: LoanTimes loanTimes: LoanTimes
loanPeriods: [LoanPeriod]! loanPeriods: [LoanPeriod]!
} }
input LendingStationInput {
id: ID
name: String
contactInformation: [ContactInformationInput]
address: AddressInput
loanTimes: LoanTimesInput
loanPeriods: [LoanPeriodInput]
}
""" """
(dt. Ausleihzeiten) (dt. Ausleihzeiten)
""" """
@ -341,8 +405,23 @@ type LoanTimes {
times: [String] times: [String]
} }
"""
(dt. Ausleihzeiten)
"""
input LoanTimesInput {
generalRemark: String
"notes for each day of the week, starting on Monday"
notes: [String]
"""
Loan times from and until for each day of the week.
Starting with Monday from, Monday to, Tuesday from, ..., Sunday to
"""
times: [String]
}
"(dt. Zeitscheibe)" "(dt. Zeitscheibe)"
type LoanPeriod{ type LoanPeriod {
id: ID! id: ID!
from: Date! from: Date!
to: Date to: Date
@ -351,14 +430,30 @@ type LoanPeriod{
cargobike: CargoBike! cargobike: CargoBike!
} }
input LoanPeriodInput {
id: ID
from: Date
to: Date
note: String
lendingstationID: Int!
cargobikeID: Int!
}
type Address { type Address {
street: String street: String!
number: String number: String!
zip: String zip: String!
}
input AddressInput {
street: String!
number: String!
zip: String!
} }
type Query { type Query {
cargobikeById(id:ID!): CargoBike cargobikeById(id:ID!): CargoBike
"!!!!"
cargobikes: [CargoBike]! cargobikes: [CargoBike]!
cargobikesByProvider(providerId:ID!): [CargoBike]! cargobikesByProvider(providerId:ID!): [CargoBike]!
providerById(id:ID!): Provider providerById(id:ID!): Provider
@ -370,55 +465,13 @@ type Query {
contactInformation: [ContactInformation]! contactInformation: [ContactInformation]!
} }
input CargoBikeInput {
"if null, then new bike will be created, else old bike will be updated."
id: ID
"see column A in info tabelle"
group: Group!
name: String!
modelName: String!
numberOfWheels: Int!
forCargo: Boolean!
forChildren: Boolean!
numberOfChildren: Int!
"""
Safety is a custom type, that stores information about security features.
TODO: Should this be calles Security?
"""
security: SecurityInput!
"""
Does not refere to an extra table in the database.
"""
technicalEquipment: TechnicalEquipmentInput!
"""
Does not refere to an extra table in the database.
"""
dimensionsAndLoad: DimensionsAndLoadInput!
"Refers to equipment that is not unique. See kommentierte info tabelle -> Fragen -> Frage 2"
otherEquipment: [String]
"Sticker State"
stickerBikeNameState: StickerBikeNameState
note: String
provider: String
insuranceData: InsuranceDataInput!
taxes: TaxesInput
}
input SecurityInput {
frameNumber: String!
keyNumberFrameLock: String
keyNumberAXAChain: String
policeCoding: String
adfcCoding: String
}
type Mutation { type Mutation {
"for testing" "for testing"
addBike(id: ID!, name: String): CargoBike! addBike(id: ID!, name: String): CargoBike!
"if id: null, then new bike will be created, else old bike will be updated" "if id: null, then new bike will be created, else old bike will be updated"
cargoBike(cargoBike: CargoBikeInput!): CargoBike! cargoBike(cargoBike: CargoBikeInput!): CargoBike!
"if id: null, then new lending station will be created, else existing one will be updated"
lendingStation(lendingStation: LendingStationInput): LendingStation!
} }
`; `;

Loading…
Cancel
Save