Now all /usergroups endpoints return ResponseUserGroup
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
ref #143
This commit is contained in:
parent
dd81f4c7e4
commit
bdcfce88cb
|
@ -26,20 +26,25 @@ export class UserGroupController {
|
|||
|
||||
@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.' })
|
||||
getAll() {
|
||||
return this.userGroupsRepository.find({ relations: ["permissions"] });
|
||||
async getAll() {
|
||||
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')
|
||||
@Authorized("USERGROUP:GET")
|
||||
@ResponseSchema(UserGroup)
|
||||
@ResponseSchema(ResponseUserGroup)
|
||||
@ResponseSchema(UserGroupNotFoundError, { statusCode: 404 })
|
||||
@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.' })
|
||||
getOne(@Param('id') id: number) {
|
||||
return this.userGroupsRepository.findOne({ id: id }, { relations: ["permissions"] });
|
||||
async getOne(@Param('id') id: number) {
|
||||
return await (await (this.userGroupsRepository.findOne({ id: id }, { relations: ["permissions"] }))).toResponse();
|
||||
}
|
||||
|
||||
@Get('/:id/permissions')
|
||||
|
@ -67,7 +72,8 @@ export class UserGroupController {
|
|||
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')
|
||||
|
|
Loading…
Reference in New Issue