Now all /usergroups endpoints return ResponseUserGroup
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
ref #143
This commit is contained in:
parent
dd81f4c7e4
commit
bdcfce88cb
@ -26,20 +26,25 @@ export class UserGroupController {
|
|||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@Authorized("USERGROUP:GET")
|
@Authorized("USERGROUP:GET")
|
||||||
@ResponseSchema(UserGroup, { isArray: true })
|
@ResponseSchema(ResponseUserGroup, { isArray: true })
|
||||||
@OpenAPI({ description: 'Lists all groups. <br> The information provided might change while the project continues to evolve.' })
|
@OpenAPI({ description: 'Lists all groups. <br> The information provided might change while the project continues to evolve.' })
|
||||||
getAll() {
|
async getAll() {
|
||||||
return this.userGroupsRepository.find({ relations: ["permissions"] });
|
let responseGroups: ResponseUserGroup[] = new Array<ResponseUserGroup>();
|
||||||
|
const groups = await this.userGroupsRepository.find({ relations: ['permissions'] });
|
||||||
|
groups.forEach(group => {
|
||||||
|
responseGroups.push(group.toResponse());
|
||||||
|
});
|
||||||
|
return responseGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/:id')
|
@Get('/:id')
|
||||||
@Authorized("USERGROUP:GET")
|
@Authorized("USERGROUP:GET")
|
||||||
@ResponseSchema(UserGroup)
|
@ResponseSchema(ResponseUserGroup)
|
||||||
@ResponseSchema(UserGroupNotFoundError, { statusCode: 404 })
|
@ResponseSchema(UserGroupNotFoundError, { statusCode: 404 })
|
||||||
@OnUndefined(UserGroupNotFoundError)
|
@OnUndefined(UserGroupNotFoundError)
|
||||||
@OpenAPI({ description: 'Lists all information about the group whose id got provided. <br> The information provided might change while the project continues to evolve.' })
|
@OpenAPI({ description: 'Lists all information about the group whose id got provided. <br> The information provided might change while the project continues to evolve.' })
|
||||||
getOne(@Param('id') id: number) {
|
async getOne(@Param('id') id: number) {
|
||||||
return this.userGroupsRepository.findOne({ id: id }, { relations: ["permissions"] });
|
return await (await (this.userGroupsRepository.findOne({ id: id }, { relations: ["permissions"] }))).toResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/:id/permissions')
|
@Get('/:id/permissions')
|
||||||
@ -67,7 +72,8 @@ export class UserGroupController {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.userGroupsRepository.save(userGroup);
|
userGroup = await this.userGroupsRepository.save(userGroup);
|
||||||
|
return (await (this.userGroupsRepository.findOne({ id: userGroup.id }, { relations: ["permissions"] }))).toResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('/:id')
|
@Put('/:id')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user