mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 23:27:31 +00:00
Add get Communities endpoint
This commit is contained in:
@ -18,10 +18,10 @@ import {
|
||||
} from '../dtos/add.community.dto';
|
||||
import { GetCommunityChildDto } from '../dtos/get.community.dto';
|
||||
import { UpdateCommunityNameDto } from '../dtos/update.community.dto';
|
||||
import { CheckUserCommunityGuard } from 'src/guards/user.community.guard';
|
||||
// import { CheckUserCommunityGuard } from 'src/guards/user.community.guard';
|
||||
import { AdminRoleGuard } from 'src/guards/admin.role.guard';
|
||||
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
|
||||
import { CommunityPermissionGuard } from 'src/guards/community.permission.guard';
|
||||
// import { CommunityPermissionGuard } from 'src/guards/community.permission.guard';
|
||||
|
||||
@ApiTags('Community Module')
|
||||
@Controller({
|
||||
@ -53,7 +53,7 @@ export class CommunityController {
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard, CommunityPermissionGuard)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get(':communityUuid')
|
||||
async getCommunityByUuid(@Param('communityUuid') communityUuid: string) {
|
||||
try {
|
||||
@ -67,9 +67,22 @@ export class CommunityController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard, CommunityPermissionGuard)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get()
|
||||
async getCommunities() {
|
||||
try {
|
||||
const communities = await this.communityService.getCommunities();
|
||||
return communities;
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('child/:communityUuid')
|
||||
async getCommunityChildByUuid(
|
||||
@Param('communityUuid') communityUuid: string,
|
||||
@ -103,7 +116,7 @@ export class CommunityController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AdminRoleGuard, CheckUserCommunityGuard)
|
||||
@UseGuards(AdminRoleGuard)
|
||||
@Post('user')
|
||||
async addUserCommunity(@Body() addUserCommunityDto: AddUserCommunityDto) {
|
||||
try {
|
||||
@ -121,7 +134,7 @@ export class CommunityController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard, CommunityPermissionGuard)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put('rename/:communityUuid')
|
||||
async renameCommunityByUuid(
|
||||
@Param('communityUuid') communityUuid: string,
|
||||
|
Reference in New Issue
Block a user