sr/model/* included suggested changes from fLotte
parent
297b5592e5
commit
8f5d98c975
@ -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
|
||||
};
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue