mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 03:27:55 +00:00
Refactor group controller and service for better code organization
This commit is contained in:
@@ -26,8 +26,8 @@ import { CheckProductUuidForAllDevicesGuard } from 'src/guards/device.product.gu
|
||||
export class GroupController {
|
||||
constructor(private readonly groupService: GroupService) {}
|
||||
|
||||
// @ApiBearerAuth()
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('space/:spaceUuid')
|
||||
async getGroupsBySpaceUuid(@Param('spaceUuid') spaceUuid: string) {
|
||||
try {
|
||||
@@ -39,8 +39,8 @@ export class GroupController {
|
||||
);
|
||||
}
|
||||
}
|
||||
// @ApiBearerAuth()
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get(':groupUuid')
|
||||
async getGroupsByGroupId(@Param('groupUuid') groupUuid: string) {
|
||||
try {
|
||||
@@ -52,8 +52,8 @@ export class GroupController {
|
||||
);
|
||||
}
|
||||
}
|
||||
// @ApiBearerAuth()
|
||||
@UseGuards(CheckProductUuidForAllDevicesGuard)
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard, CheckProductUuidForAllDevicesGuard)
|
||||
@Post()
|
||||
async addGroup(@Body() addGroupDto: AddGroupDto) {
|
||||
try {
|
||||
@@ -72,13 +72,16 @@ export class GroupController {
|
||||
async controlGroup(@Body() controlGroupDto: ControlGroupDto) {
|
||||
try {
|
||||
return await this.groupService.controlGroup(controlGroupDto);
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// @ApiBearerAuth()
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put('rename/:groupUuid')
|
||||
async renameGroupByUuid(
|
||||
@Param('groupUuid') groupUuid: string,
|
||||
@@ -97,8 +100,8 @@ export class GroupController {
|
||||
}
|
||||
}
|
||||
|
||||
// @ApiBearerAuth()
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete(':groupUuid')
|
||||
async deleteGroup(@Param('groupUuid') groupUuid: string) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user