mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-23 16:47:55 +00:00
added exception filter and removed controller error handling
This commit is contained in:
@@ -1,13 +1,5 @@
|
||||
import { GroupService } from '../services/group.service';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
UseGuards,
|
||||
Param,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import { Controller, Get, UseGuards, Param, Req } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
|
||||
import { UnitPermissionGuard } from 'src/guards/unit.permission.guard';
|
||||
@@ -24,14 +16,7 @@ export class GroupController {
|
||||
@UseGuards(JwtAuthGuard, UnitPermissionGuard)
|
||||
@Get(':unitUuid')
|
||||
async getGroupsBySpaceUuid(@Param('unitUuid') unitUuid: string) {
|
||||
try {
|
||||
return await this.groupService.getGroupsByUnitUuid(unitUuid);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
return await this.groupService.getGroupsByUnitUuid(unitUuid);
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard, UnitPermissionGuard)
|
||||
@@ -41,19 +26,12 @@ export class GroupController {
|
||||
@Param('groupName') groupName: string,
|
||||
@Req() req: any,
|
||||
) {
|
||||
try {
|
||||
const userUuid = req.user.uuid;
|
||||
const userUuid = req.user.uuid;
|
||||
|
||||
return await this.groupService.getUnitDevicesByGroupName(
|
||||
unitUuid,
|
||||
groupName,
|
||||
userUuid,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
return await this.groupService.getUnitDevicesByGroupName(
|
||||
unitUuid,
|
||||
groupName,
|
||||
userUuid,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user