src/model/*: added Workshop and Engagement.
parent
91e0c8f9e9
commit
cfa0e14f8e
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
@ -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[];
|
||||||
|
}
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue