fix(shop): map requiresRx in productService, enable backend query param filtering, and classify 11 prescription vs 24 OTC products

This commit is contained in:
parsa aghaei committed 2026-07-26 20:03:45 +03:30
1 parent df6c56b1e8
commit 989f77e106
5 files changed
+20 -4

No files matched your search

@@ -17,4 +17,9 @@ export class GetProductsDto extends PaginationDto {
@IsOptional()
@IsString()
symptom?: string;
@ApiPropertyOptional({ description: 'فیلتر داروی نیازمند نسخه (true/false)' })
@IsOptional()
@IsString()
requiresRx?: string;
}
+5 -1
View File
@@ -7,10 +7,14 @@ export class ProductsService {
constructor(private prisma: PrismaService) {}
async findAll(filters: GetProductsDto, userRole?: string) {
const { category, petType, search, symptom, page = 1, limit = 10, sortBy = 'createdAt', sortOrder = 'desc' } = filters;
const { category, petType, search, symptom, requiresRx, page = 1, limit = 10, sortBy = 'createdAt', sortOrder = 'desc' } = filters;
const whereClause: any = {};
if (requiresRx !== undefined && requiresRx !== null && requiresRx !== '') {
whereClause.requiresRx = requiresRx === 'true' || requiresRx === '1';
}
if (category) {
whereClause.categorySlug = category;
}