feat: resolve doctors query error, add FAQ, testimonials, blog preview, and full menu management
Deploy Canina / deploy (push) Successful in 1m41s
Deploy Canina / deploy (push) Successful in 1m41s
This commit is contained in:
1 parent
70d58e7086
commit
2c452215c3
31 files changed
+1987
-76
No files matched your search
@@ -10,7 +10,8 @@ import {
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { DoctorsService, DoctorQuery } from './doctors.service';
|
||||
import { DoctorsService } from './doctors.service';
|
||||
import { DoctorQueryDto } from './dto/doctor-query.dto';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
@@ -21,7 +22,7 @@ export class DoctorsController {
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Get list of all doctors / specialists' })
|
||||
findAll(@Query() query: DoctorQuery) {
|
||||
findAll(@Query() query: DoctorQueryDto) {
|
||||
return this.doctorsService.findAll(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { DoctorQueryDto } from './dto/doctor-query.dto';
|
||||
|
||||
export class DoctorQuery {
|
||||
page?: number | string;
|
||||
limit?: number | string;
|
||||
search?: string;
|
||||
activeOnly?: boolean | string;
|
||||
}
|
||||
export { DoctorQueryDto as DoctorQuery };
|
||||
|
||||
@Injectable()
|
||||
export class DoctorsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async findAll(query: DoctorQuery = {}) {
|
||||
async findAll(query: DoctorQueryDto = {}) {
|
||||
const page = Number(query.page) || 1;
|
||||
const limit = Number(query.limit) || 50;
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
const where: Prisma.DoctorWhereInput = {};
|
||||
|
||||
if (query.activeOnly === 'true' || query.activeOnly === true) {
|
||||
if (query.activeOnly === true) {
|
||||
where.isActive = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsOptional, IsInt, Min, IsString, IsBoolean } from 'class-validator';
|
||||
import { Type, Transform } from 'class-transformer';
|
||||
|
||||
export class DoctorQueryDto {
|
||||
@ApiPropertyOptional({ description: 'شماره صفحه', minimum: 1, default: 1 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
page?: number = 1;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'تعداد آیتم در هر صفحه',
|
||||
minimum: 1,
|
||||
default: 50,
|
||||
})
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
limit?: number = 50;
|
||||
|
||||
@ApiPropertyOptional({ description: 'عبارت جستجو' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
search?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'فقط پزشکان فعال' })
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => {
|
||||
if (value === 'true' || value === true) return true;
|
||||
if (value === 'false' || value === false) return false;
|
||||
return undefined;
|
||||
})
|
||||
@IsBoolean()
|
||||
activeOnly?: boolean;
|
||||
}
|
||||
Reference in new issue
Block a user