full project: admin panel, backend modules, docs

This commit is contained in:
Lizandro Guarnizo
2026-06-03 22:11:01 -05:00
parent 1635723035
commit afc096d552
94 changed files with 15994 additions and 240 deletions
@@ -1,22 +1,54 @@
import { Controller, Get, Post, Patch, Param, Body, UseGuards, Req, Query } from '@nestjs/common';
import { Controller, Get, Post, Patch, Param, Body, UseGuards, Req, HttpCode, HttpStatus, NotFoundException } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { ProfessionalsService } from './professionals.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { CreateProfessionalDto, UpdateProfessionalDto, UpdateSchedulesDto } from './dto/professional.dto';
import { AuthService } from '../auth/auth.service';
@ApiTags('Professionals')
@Controller('professionals')
export class ProfessionalsController {
constructor(private pros: ProfessionalsService) {}
constructor(
private pros: ProfessionalsService,
private auth: AuthService,
) {}
@Get()
findAllActive() {
return this.pros.findAllActive();
findAllActive(@Req() req) {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 20);
return this.pros.findAllActive(page, limit);
}
@Get('pending')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
findPending(@Req() req) {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 20);
return this.pros.findPendingApprovals(page, limit);
}
@Post(':id/approve')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
approve(@Param('id') id: string) {
return this.pros.approve(id);
}
@Post(':id/deny')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
deny(@Param('id') id: string) {
return this.pros.deny(id);
}
@Get('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
findByMe(@Req() req) {
async findByMe(@Req() req) {
const profId = await this.auth.getProfessionalId(req.user.sub);
if (!profId) throw new NotFoundException('No eres un profesional');
return this.pros.findByUserId(req.user.sub);
}
@@ -28,21 +60,22 @@ export class ProfessionalsController {
@Post('request')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
request(@Req() req, @Body() data: any) {
return this.pros.requestProfessional(req.user.sub, data);
request(@Req() req, @Body() dto: CreateProfessionalDto) {
return this.pros.requestProfessional(req.user.sub, dto);
}
@Patch('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
update(@Req() req, @Body() data: any) {
return this.pros.upsert(req.user.sub, data);
async update(@Req() req, @Body() dto: UpdateProfessionalDto) {
return this.pros.upsert(req.user.sub, dto);
}
@Patch('me/schedules')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
updateSchedules(@Req() req, @Body() data: { schedules: any[] }) {
return this.pros.updateSchedules(req.user.sub, data.schedules);
async updateSchedules(@Req() req, @Body() dto: UpdateSchedulesDto) {
const prof = await this.pros.findByUserId(req.user.sub);
return this.pros.updateSchedules(prof.id, dto.schedules);
}
}