mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 19:07:55 +00:00
Added all community endpoints
This commit is contained in:
@@ -1 +1,2 @@
|
||||
export * from './user.controller';
|
||||
export * from './user-communities.controller';
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
|
||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||
import { ControllerRoute } from '@app/common/constants/controller-route';
|
||||
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
||||
import { UserCommunityService } from '../services';
|
||||
import { UserCommunityParamDto, UserParamDto } from '../dtos';
|
||||
|
||||
@ApiTags('User Module')
|
||||
@Controller({
|
||||
version: EnableDisableStatusEnum.ENABLED,
|
||||
path: ControllerRoute.USER_COMMUNITY.ROUTE,
|
||||
})
|
||||
export class UserCommunityController {
|
||||
constructor(private readonly userCommunityService: UserCommunityService) {}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
summary:
|
||||
ControllerRoute.USER_COMMUNITY.ACTIONS.GET_USER_COMMUNITIES_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.USER_COMMUNITY.ACTIONS.GET_USER_COMMUNITIES_DESCRIPTION,
|
||||
})
|
||||
async getCommunitiesByUserId(
|
||||
@Param() params: UserParamDto,
|
||||
): Promise<BaseResponseDto> {
|
||||
return await this.userCommunityService.getCommunitiesByUserId(
|
||||
params.userUuid,
|
||||
);
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post(':communityUuid')
|
||||
@ApiOperation({
|
||||
summary:
|
||||
ControllerRoute.USER_COMMUNITY.ACTIONS.ASSOCIATE_USER_COMMUNITY_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.USER_COMMUNITY.ACTIONS
|
||||
.ASSOCIATE_USER_COMMUNITY_DESCRIPTION,
|
||||
})
|
||||
async associateUserWithCommunity(
|
||||
@Param() params: UserCommunityParamDto,
|
||||
): Promise<BaseResponseDto> {
|
||||
return await this.userCommunityService.associateUserWithCommunity(
|
||||
params.userUuid,
|
||||
params.communityUuid,
|
||||
);
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiOperation({
|
||||
summary:
|
||||
ControllerRoute.USER_COMMUNITY.ACTIONS
|
||||
.DISASSOCIATE_USER_COMMUNITY_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.USER_COMMUNITY.ACTIONS
|
||||
.DISASSOCIATE_USER_COMMUNITY_DESCRIPTION,
|
||||
})
|
||||
@Delete(':communityUuid')
|
||||
async disassociateUserFromCommunity(
|
||||
@Param() params: UserCommunityParamDto,
|
||||
): Promise<BaseResponseDto> {
|
||||
return await this.userCommunityService.disassociateUserFromCommunity(
|
||||
params.userUuid,
|
||||
params.communityUuid,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user