full project: admin panel, backend modules, docs
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { Controller, Get, Post, Patch, Param, Body, UseGuards, Req } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { Controller, Get, Post, Patch, Param, Body, UseGuards, Req, Query } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth, ApiQuery } from '@nestjs/swagger';
|
||||
import { ServicesService } from './services.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { CreateServiceDto, UpdateServiceStatusDto } from './dto/service.dto';
|
||||
|
||||
@ApiTags('Services')
|
||||
@Controller('services')
|
||||
@@ -11,43 +12,74 @@ export class ServicesController {
|
||||
@Post()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
create(@Req() req, @Body() data: any) {
|
||||
return this.services.create({ ...data, user_id: req.user.sub });
|
||||
create(@Req() req, @Body() dto: CreateServiceDto) {
|
||||
return this.services.create({ ...dto, user_id: req.user.sub });
|
||||
}
|
||||
|
||||
@Get()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
findAll(@Req() req) {
|
||||
const page = +(req.query.page || 1);
|
||||
const limit = +(req.query.limit || 20);
|
||||
return this.services.findAll(page, limit);
|
||||
}
|
||||
|
||||
@Get('me')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
findByMe(@Req() req) {
|
||||
return this.services.findByUser(req.user.sub);
|
||||
const page = +(req.query.page || 1);
|
||||
const limit = +(req.query.limit || 20);
|
||||
return this.services.findByUser(req.user.sub, page, limit);
|
||||
}
|
||||
|
||||
@Get('professional')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
findByProfessional(@Req() req) {
|
||||
return this.services.findByProfessional(req.user.sub);
|
||||
const page = +(req.query.page || 1);
|
||||
const limit = +(req.query.limit || 20);
|
||||
return this.services.findByProfessional(req.user.sub, page, limit);
|
||||
}
|
||||
|
||||
@Get('professional/requests')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
requestsByProfessional(@Req() req) {
|
||||
return this.services.findRequestsByProfessional(req.user.sub);
|
||||
const page = +(req.query.page || 1);
|
||||
const limit = +(req.query.limit || 20);
|
||||
return this.services.findRequestsByProfessional(req.user.sub, page, limit);
|
||||
}
|
||||
|
||||
@Get('professional/history')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
historyByProfessional(@Req() req) {
|
||||
return this.services.getHistoryByProfessional(req.user.sub);
|
||||
const page = +(req.query.page || 1);
|
||||
const limit = +(req.query.limit || 20);
|
||||
return this.services.getHistoryByProfessional(req.user.sub, page, limit);
|
||||
}
|
||||
|
||||
@Get('me/history')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
historyByUser(@Req() req) {
|
||||
return this.services.getHistoryByUser(req.user.sub);
|
||||
const page = +(req.query.page || 1);
|
||||
const limit = +(req.query.limit || 20);
|
||||
return this.services.getHistoryByUser(req.user.sub, page, limit);
|
||||
}
|
||||
|
||||
@Get('professional/calendar')
|
||||
@@ -72,7 +104,7 @@ export class ServicesController {
|
||||
@Patch(':id/status')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
updateStatus(@Param('id') id: string, @Body() dto: { status: string }) {
|
||||
return this.services.updateStatus(id, dto.status);
|
||||
updateStatus(@Req() req, @Param('id') id: string, @Body() dto: UpdateServiceStatusDto) {
|
||||
return this.services.updateStatus(id, dto.status, req.user.sub);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user