parent
dd7e5dae36
commit
179c2a5157
|
@ -1,11 +1,12 @@
|
|||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { getConnection, getConnectionManager, Repository } from 'typeorm';
|
||||
import { GroupContactIdsNotMatchingError, GroupContactNotFoundError } from '../errors/GroupContactErrors';
|
||||
import { RunnerGroupNotFoundError } from '../errors/RunnerGroupErrors';
|
||||
import { CreateGroupContact } from '../models/actions/create/CreateGroupContact';
|
||||
import { UpdateGroupContact } from '../models/actions/update/UpdateGroupContact';
|
||||
import { GroupContact } from '../models/entities/GroupContact';
|
||||
import { RunnerGroup } from '../models/entities/RunnerGroup';
|
||||
import { ResponseEmpty } from '../models/responses/ResponseEmpty';
|
||||
import { ResponseGroupContact } from '../models/responses/ResponseGroupContact';
|
||||
|
||||
|
@ -95,6 +96,10 @@ export class GroupContactController {
|
|||
let contact = await this.contactRepository.findOne({ id: id });
|
||||
if (!contact) { return null; }
|
||||
const responseContact = await this.contactRepository.findOne(contact, { relations: ['groups'] });
|
||||
for (let group of responseContact.groups) {
|
||||
group.contact = null;
|
||||
await getConnection().getRepository(RunnerGroup).save(group);
|
||||
}
|
||||
|
||||
await this.contactRepository.delete(contact);
|
||||
return responseContact.toResponse();
|
||||
|
|
Loading…
Reference in New Issue