From 04cc2daf434ed020971d1d2350f5f10f29074374 Mon Sep 17 00:00:00 2001 From: Mathis Date: Mon, 14 Oct 2024 14:52:52 +0200 Subject: [PATCH] Improve groups.controller with service integration This commit adds service method calls for managing groups in the controller. It includes integration for fetching groups by name, creating a new group, deleting a group, and finding files for a group. These changes enhance the functionality and efficiency of the groups controller. --- .../backend/src/app/groups/groups.controller.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/backend/src/app/groups/groups.controller.ts b/apps/backend/src/app/groups/groups.controller.ts index 350dae1..e9deb0a 100644 --- a/apps/backend/src/app/groups/groups.controller.ts +++ b/apps/backend/src/app/groups/groups.controller.ts @@ -24,15 +24,20 @@ export class GroupsController { @Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number, @Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number, @Query("search", new DefaultValuePipe("")) search: string, - ) {} + ) { + return await this.groupsService.getGroupsByName(limit, offset, search) + } - //TODO DTO @Post("new") - async newGroup() {} + async newGroup(@Body() body: CreateGroupDto) { + return await this.groupsService.newGroup(body.groupName) + } @UseGuards(AdminGuard) @Delete(":groupId") - async deleteGroup(@Param("groupId") groupId: string) {} + async deleteGroup(@Param("groupId") groupId: string) { + return await this.groupsService.deleteGroup(groupId) + } //TODO Patch @@ -42,5 +47,7 @@ export class GroupsController { @Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number, @Query("search", new DefaultValuePipe("")) search: string, @Param("groupId") groupId: string, - ) {} + ) { + return await this.groupsService.findFilesForGroup(limit, offset, search, groupId) + } }