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 { Organization } from './model/Organization';
import { Provider } from './model/Provider';
import { Engagement } from './model/Engagement';
import { Workshop } from './model/Workshop';
require('dotenv').config();
@ -62,7 +64,9 @@ createConnection({
LoanPeriod,
Organization,
Participant,
Provider
Provider,
Engagement,
Workshop
],
synchronize: true,
logging: false

@ -9,6 +9,7 @@ import { LoanPeriod } from './LoanPeriod';
import { LendingStation } from './LendingStation';
import { Taxes } from './Taxes';
import { Equipment } from './Equipment';
import { Engagement } from './Engagement';
export enum Group {
KL = 'KL',
@ -125,6 +126,9 @@ export class CargoBike extends Bike {
})
lendingStation: LendingStation;
@OneToMany(type => Engagement, engagement => engagement.cargoBike)
engagement: Engagement[];
@Column(type => 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 { CargoBike } from './CargoBike';
import { Engagement } from './Engagement';
import { Workshop } from './Workshop';
@Entity()
export class Participant {
@ -38,6 +40,14 @@ export class Participant {
@OneToMany(type => CargoBike, cargoBike => cargoBike.coordinator)
cargoBikes: CargoBike[];
@OneToMany(type => Engagement, engagement => engagement.participant)
engagement: Engagement[];
@ManyToMany(type => Workshop, workshop => workshop.participants, {
nullable: true
})
workshops: Workshop[];
@Column()
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)) {
return dataSources.cargoBikeAPI.findCargoBikeById({ id });
} else {
throw new GraphQLError('Insufficient Permissions');
return new GraphQLError('Insufficient Permissions');
}
}
},
@ -16,14 +16,14 @@ export default {
if (req.permissions.includes(Permission.WriteBike)) {
return dataSources.cargoBikeAPI.updateBike({ id, name });
} else {
throw new GraphQLError('Insufficient Permissions');
return new GraphQLError('Insufficient Permissions');
}
},
cargoBike: (_: any, { cargoBike }: { cargoBike: any }, { dataSources, req }:{dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.WriteBike)) {
return dataSources.cargoBikeAPI.updateCargoBike({ cargoBike });
} 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
}
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 {
"""
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
}
input SecurityInput {
frameNumber: String!
keyNumberFrameLock: String
keyNumberAXAChain: String
policeCoding: String
adfcCoding: String
}
enum StickerBikeNameState {
OK
IMPROVE
@ -300,9 +343,21 @@ type ContactInformation {
phone2Intern: String
emailExtern: String
emailIntern: 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 {
@ -322,11 +377,20 @@ type LendingStation {
id: ID!
name: String!
contactInformation: [ContactInformation]!
address: Address
address: Address!
loanTimes: LoanTimes
loanPeriods: [LoanPeriod]!
}
input LendingStationInput {
id: ID
name: String
contactInformation: [ContactInformationInput]
address: AddressInput
loanTimes: LoanTimesInput
loanPeriods: [LoanPeriodInput]
}
"""
(dt. Ausleihzeiten)
"""
@ -341,6 +405,21 @@ type LoanTimes {
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)"
type LoanPeriod {
id: ID!
@ -351,14 +430,30 @@ type LoanPeriod{
cargobike: CargoBike!
}
input LoanPeriodInput {
id: ID
from: Date
to: Date
note: String
lendingstationID: Int!
cargobikeID: Int!
}
type Address {
street: String
number: String
zip: String
street: String!
number: String!
zip: String!
}
input AddressInput {
street: String!
number: String!
zip: String!
}
type Query {
cargobikeById(id:ID!): CargoBike
"!!!!"
cargobikes: [CargoBike]!
cargobikesByProvider(providerId:ID!): [CargoBike]!
providerById(id:ID!): Provider
@ -370,55 +465,13 @@ type Query {
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 {
"for testing"
addBike(id: ID!, name: String): CargoBike!
"if id: null, then new bike will be created, else old bike will be updated"
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