@@ -1,7 +1,7 @@
|
||||
import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
|
||||
import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions';
|
||||
import { UserGroupIdsNotMatchingError, UserGroupNotFoundError } from '../errors/UserGroupErrors';
|
||||
import { CreateUserGroup } from '../models/creation/CreateUserGroup';
|
||||
import { UserGroup } from '../models/entities/UserGroup';
|
||||
@@ -73,14 +73,12 @@ export class UserGroupController {
|
||||
@ResponseSchema(UserGroup)
|
||||
@ResponseSchema(UserGroupNotFoundError, { statusCode: 404 })
|
||||
@OpenAPI({ description: 'Delete a specified usergroup (if it exists).' })
|
||||
async remove(@Param('id') id: number) {
|
||||
let userGroup = await this.userGroupsRepository.findOne({ id: id });
|
||||
|
||||
if (!userGroup) {
|
||||
async remove(@EntityFromParam('id') group: UserGroup) {
|
||||
if (!group) {
|
||||
throw new UserGroupNotFoundError();
|
||||
}
|
||||
|
||||
await this.userGroupsRepository.delete(userGroup);
|
||||
return userGroup;
|
||||
await this.userGroupsRepository.delete(group);
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user