diff --git a/backend/src/modules/user/user.controller.ts b/backend/src/modules/user/user.controller.ts index 364b24a..260e2a1 100644 --- a/backend/src/modules/user/user.controller.ts +++ b/backend/src/modules/user/user.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Param, Post, Put } from '@nestjs/common'; +import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { IGetUser } from './user.dto'; import { UserService } from './user.service'; @@ -31,4 +31,12 @@ export class UserController { async unBanUser(@Param('id') id: string) { return await this.userService.unBanUser(id); } + + @ApiOperation({ + description: 'Get all banned users', + }) + @Get('banned') + async getBannedUsers() { + return await this.userService.getBannedUsers(); + } } diff --git a/backend/src/modules/user/user.service.ts b/backend/src/modules/user/user.service.ts index 4d68fb4..96c1ad2 100644 --- a/backend/src/modules/user/user.service.ts +++ b/backend/src/modules/user/user.service.ts @@ -60,7 +60,14 @@ export class UserService { throw error; } this.logger.debug(`[user.deBanUser] ${JSON.stringify({ error })}`); - throw new HttpException(`[user.unBanUser] Error: ${JSON.stringify(error)}`, HttpStatus.BAD_GATEWAY); + + async getBannedUsers() { + try { + this.logger.log('[user.getBannedUsers]'); + return await this.userRepository.find({ where: { banned: true }, select: { id: true, user_name: true } }); + } catch (error) { + this.logger.debug(`[user.getBannedUsers] ${error}`); + throw new HttpException('Error occurred', HttpStatus.INTERNAL_SERVER_ERROR); } } }