diff --git a/src/controllers/UserGroupController.ts b/src/controllers/UserGroupController.ts
index e56996f..f8109ed 100644
--- a/src/controllers/UserGroupController.ts
+++ b/src/controllers/UserGroupController.ts
@@ -25,9 +25,9 @@ export class UserGroupController {
@Get()
@Authorized("USERGROUP:GET")
@ResponseSchema(UserGroup, { isArray: true })
- @OpenAPI({ description: 'Lists all usergroups.' })
+ @OpenAPI({ description: 'Lists all groups.
The information provided might change while the project continues to evolve.' })
getAll() {
- return this.userGroupsRepository.find();
+ return this.userGroupsRepository.find({ relations: ["permissions"] });
}
@Get('/:id')
@@ -35,16 +35,16 @@ export class UserGroupController {
@ResponseSchema(UserGroup)
@ResponseSchema(UserGroupNotFoundError, { statusCode: 404 })
@OnUndefined(UserGroupNotFoundError)
- @OpenAPI({ description: 'Returns a usergroup of a specified id (if it exists)' })
+ @OpenAPI({ description: 'Lists all information about the group whose id got provided.
The information provided might change while the project continues to evolve.' })
getOne(@Param('id') id: number) {
- return this.userGroupsRepository.findOne({ id: id });
+ return this.userGroupsRepository.findOne({ id: id }, { relations: ["permissions"] });
}
@Post()
@Authorized("USERGROUP:CREATE")
@ResponseSchema(UserGroup)
@ResponseSchema(UserGroupNotFoundError)
- @OpenAPI({ description: 'Create a new usergroup object (id will be generated automagicly).' })
+ @OpenAPI({ description: 'Create a new group.
If you want to grant permissions to the group you have to create them seperately by posting to /api/permissions after creating the group.' })
async post(@Body({ validate: true }) createUserGroup: CreateUserGroup) {
let userGroup;
try {
@@ -61,9 +61,9 @@ export class UserGroupController {
@ResponseSchema(UserGroup)
@ResponseSchema(UserGroupNotFoundError, { statusCode: 404 })
@ResponseSchema(UserGroupIdsNotMatchingError, { statusCode: 406 })
- @OpenAPI({ description: "Update a usergroup object (id can't be changed)." })
+ @OpenAPI({ description: "Update the group whose id you provided.
To change the permissions granted to the group please use /api/permissions instead.
Please remember that id's can't be changed." })
async put(@Param('id') id: number, @EntityFromBody() userGroup: UserGroup) {
- let oldUserGroup = await this.userGroupsRepository.findOne({ id: id });
+ let oldUserGroup = await this.userGroupsRepository.findOne({ id: id }, { relations: ["permissions"] });
if (!oldUserGroup) {
throw new UserGroupNotFoundError()
@@ -82,11 +82,11 @@ export class UserGroupController {
@ResponseSchema(ResponseUserGroup)
@ResponseSchema(ResponseEmpty, { statusCode: 204 })
@OnUndefined(204)
- @OpenAPI({ description: 'Delete a specified usergroup (if it exists).' })
+ @OpenAPI({ description: 'Delete the group whose id you provided.
If there are any permissions directly granted to the group they will get deleted as well.
Users associated with this group won\'t get deletet - just deassociated.
If no group with this id exists it will just return 204(no content).' })
async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
- let group = await this.userGroupsRepository.findOne({ id: id });
+ let group = await this.userGroupsRepository.findOne({ id: id }, { relations: ["permissions"] });
if (!group) { return null; }
- const responseGroup = await this.userGroupsRepository.findOne({ id: id }, { relations: ['permissions'] });;
+ const responseGroup = await this.userGroupsRepository.findOne({ id: id }, { relations: ['permissions'] });
const permissionControler = new PermissionController();
for (let permission of responseGroup.permissions) {