parent
09e429fc67
commit
11af9c02d9
|
@ -1,7 +1,9 @@
|
|||
import { Authorized, Delete, Get, JsonController, OnUndefined, Param, QueryParam } from 'routing-controllers';
|
||||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, QueryParam } from 'routing-controllers';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { GroupContactNotFoundError } from '../errors/GroupContactErrors';
|
||||
import { RunnerGroupNotFoundError } from '../errors/RunnerGroupErrors';
|
||||
import { CreateGroupContact } from '../models/actions/create/CreateGroupContact';
|
||||
import { GroupContact } from '../models/entities/GroupContact';
|
||||
import { ResponseEmpty } from '../models/responses/ResponseEmpty';
|
||||
import { ResponseGroupContact } from '../models/responses/ResponseGroupContact';
|
||||
|
@ -43,21 +45,22 @@ export class ContactController {
|
|||
return contact.toResponse();
|
||||
}
|
||||
|
||||
// @Post()
|
||||
// @Authorized("DONOR:CREATE")
|
||||
// @ResponseSchema(ResponseDonor)
|
||||
// @OpenAPI({ description: 'Create a new contact.' })
|
||||
// async post(@Body({ validate: true }) createRunner: CreateDonor) {
|
||||
// let contact;
|
||||
// try {
|
||||
// contact = await createRunner.toEntity();
|
||||
// } catch (error) {
|
||||
// throw error;
|
||||
// }
|
||||
@Post()
|
||||
@Authorized("CONTACT:CREATE")
|
||||
@ResponseSchema(ResponseGroupContact)
|
||||
@ResponseSchema(RunnerGroupNotFoundError, { statusCode: 404 })
|
||||
@OpenAPI({ description: 'Create a new contact.' })
|
||||
async post(@Body({ validate: true }) createContact: CreateGroupContact) {
|
||||
let contact;
|
||||
try {
|
||||
contact = await createContact.toEntity();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
// contact = await this.contactRepository.save(contact)
|
||||
// return new ResponseDonor(await this.contactRepository.findOne(contact, { relations: ['donations', 'donations.runner', 'donations.runner.scans', 'donations.runner.scans.track'] }));
|
||||
// }
|
||||
contact = await this.contactRepository.save(contact)
|
||||
return (await this.contactRepository.findOne(contact, { relations: ['groups'] })).toResponse();
|
||||
}
|
||||
|
||||
// @Put('/:id')
|
||||
// @Authorized("DONOR:UPDATE")
|
||||
|
|
Loading…
Reference in New Issue