mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 21:37:54 +00:00
finished groups endpoint
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { GroupService } from '../services/group.service';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
UseGuards,
|
||||
Query,
|
||||
Param,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
|
||||
import { AddGroupDto } from '../dtos/add.group.dto';
|
||||
import { GetGroupDto } from '../dtos/get.group.dto';
|
||||
|
||||
@ApiTags('Group Module')
|
||||
@Controller({
|
||||
version: '1',
|
||||
path: 'group',
|
||||
})
|
||||
export class GroupController {
|
||||
constructor(private readonly groupService: GroupService) {}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get(':homeId')
|
||||
async userList(
|
||||
@Param('homeId') homeId: string,
|
||||
@Query() getGroupsDto: GetGroupDto,
|
||||
) {
|
||||
try {
|
||||
return await this.groupService.getGroupsByHomeId(homeId, getGroupsDto);
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post()
|
||||
async addGroup(@Body() addGroupDto: AddGroupDto) {
|
||||
try {
|
||||
return await this.groupService.addGroup(addGroupDto);
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user