mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 18:05:48 +00:00
Add endpoint to get community child by UUID
This commit is contained in:
@ -7,11 +7,13 @@ import {
|
|||||||
HttpStatus,
|
HttpStatus,
|
||||||
Param,
|
Param,
|
||||||
Post,
|
Post,
|
||||||
|
Query,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||||
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
|
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
|
||||||
import { AddCommunityDto } from '../dtos/add.community.dto';
|
import { AddCommunityDto } from '../dtos/add.community.dto';
|
||||||
|
import { GetCommunityChildDto } from '../dtos/get.community.dto';
|
||||||
|
|
||||||
@ApiTags('Community Module')
|
@ApiTags('Community Module')
|
||||||
@Controller({
|
@Controller({
|
||||||
@ -55,4 +57,29 @@ export class CommunityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(JwtAuthGuard)
|
||||||
|
@Get('child/:communityUuid')
|
||||||
|
async getCommunityChildByUuid(
|
||||||
|
@Param('communityUuid') communityUuid: string,
|
||||||
|
@Query() query: GetCommunityChildDto,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const community = await this.communityService.getCommunityChildByUuid(
|
||||||
|
communityUuid,
|
||||||
|
query,
|
||||||
|
);
|
||||||
|
return community;
|
||||||
|
} catch (error) {
|
||||||
|
if (error.status === 404) {
|
||||||
|
throw new HttpException('Community not found', HttpStatus.NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
throw new HttpException(
|
||||||
|
error.message || 'Internal server error',
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user