mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-14 12:49:41 +03:00
Get all banned users
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user