feat(backend): implement Phase A database models and controllers for cross-boundary dependencies
Deploy Canina / deploy (push) Failing after 28s

This commit is contained in:
parsa committed 2026-08-06 23:45:51 +03:30
1 parent 74fcaa6a4e
commit 1ae4c99ffc
26 files changed
+1205 -345

No files matched your search

+22 -114
View File
@@ -1,10 +1,13 @@
import {
Controller,
Get,
Patch,
Body,
Query,
Param,
NotFoundException,
HttpStatus,
UseGuards,
} from '@nestjs/common';
import { ProductsService } from './products.service';
import { GetProductsDto } from './dto/get-products.dto';
@@ -15,62 +18,21 @@ import {
ApiOkResponse,
ApiNotFoundResponse,
} from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { RolesGuard } from '../common/guards/roles.guard';
import { Roles } from '../common/decorators/roles.decorator';
@ApiTags('Products - مدیریت محصولات دارویی')
@Controller('products')
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'خطای داخلی سرور',
schema: {
example: {
success: false,
message: 'خطای داخلی سرور',
code: 'SERVER_ERROR',
details: {},
},
},
})
export class ProductsController {
constructor(private readonly productsService: ProductsService) {}
@Get()
@ApiOperation({ summary: 'لیست و فیلتر محصولات' })
@ApiOkResponse({
description: 'لیست محصولات متناسب با فیلترها (دسته، پت و جستجو)',
schema: {
example: {
data: [
{
id: 'a1b2c3d4-1234-5678-abcd-ef1234567890',
artNo: 'canhydrox-gag',
name: 'Canhydrox GAG (کنهیدروکس)',
scientificTagline: 'برای تقویت مفاصل و استخوان‌ها',
description:
'کنهیدروکس محصولی بی‌نظیر برای مفاصل و سیستم حرکتی سگ‌ها...',
shortDescription: 'تقویت مفاصل و غضروف‌ها',
category: 'سیستم حرکتی و مفاصل',
categorySlug: 'joints',
priceValue: '1750000.00',
priceDisplay: '۱,۷۵۰,۰۰۰ تومان',
unit: 'عدد قرص',
packageSize: '120.00',
dosageLogic: 'یک قرص به ازای هر ۱۰ کیلوگرم وزن بدن سگ',
suitableFor: 'سگ',
imageUrl: 'https://example.com/canhydrox.png',
createdAt: '2026-05-26T18:10:00.000Z',
ingredients: [],
symptoms: [],
},
],
meta: {
total: 1,
page: 1,
lastPage: 1,
limit: 10,
},
},
},
})
findAll(@Query() query: GetProductsDto) {
return this.productsService.findAll(query);
}
@@ -79,16 +41,6 @@ export class ProductsController {
@ApiOperation({
summary: 'دریافت فیلترهای فعال محصولات (دسته، علائم، نوع پت)',
})
@ApiOkResponse({
description: 'لیست فیلترهای پویا استخراج شده از دیتابیس',
schema: {
example: {
categories: [{ id: '1', name: 'مفاصل و استخوان', slug: 'joints' }],
symptoms: ['لنگش', 'ریزش مو'],
petTypes: ['سگ', 'گربه', 'هر دو'],
},
},
})
getActiveFilters() {
return this.productsService.getActiveFilters();
}
@@ -97,72 +49,28 @@ export class ProductsController {
@ApiOperation({
summary: 'دریافت فیلترها و راهکارهای ناوبری (دسته با علائم مربوطه)',
})
@ApiOkResponse({
description: 'ساختار درختی فیلترها و تگ‌های درمانی واقعی متصل به محصولات',
schema: {
example: [
{
id: '1',
name: 'مفاصل و استخوان',
slug: 'joints',
symptoms: ['درد مفاصل', 'لنگش'],
},
],
},
})
getNavigationFilters() {
return this.productsService.getNavigationFilters();
}
@Get(':id/dosage-config')
@ApiOperation({ summary: 'دریافت پیکربندی دوز مصرف محصول' })
getDosageConfig(@Param('id') id: string) {
return this.productsService.getDosageConfig(id);
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('Admin')
@Patch(':id/dosage-config')
@ApiOperation({
summary: 'ویرایش پیکربندی دوز مصرف محصول (نیازمند دسترسی ادمین)',
})
updateDosageConfig(@Param('id') id: string, @Body() body: any) {
return this.productsService.updateDosageConfig(id, body);
}
@Get(':id')
@ApiOperation({ summary: 'دریافت اطلاعات محصول با شناسه یکتا (ID)' })
@ApiOkResponse({
description: 'اطلاعات کامل محصول شامل مواد تشکیل‌دهنده و علائم مرتبط',
schema: {
example: {
id: 'a1b2c3d4-1234-5678-abcd-ef1234567890',
artNo: 'canhydrox-gag',
name: 'Canhydrox GAG (کنهیدروکس)',
scientificTagline: 'برای تقویت مفاصل و استخوان‌ها',
description: 'کنهیدروکس محصولی بی‌نظیر برای مفاصل...',
shortDescription: 'تقویت مفاصل و غضروف‌ها',
category: 'سیستم حرکتی و مفاصل',
categorySlug: 'joints',
priceValue: '1750000.00',
priceDisplay: '۱,۷۵۰,۰۰۰ تومان',
unit: 'عدد قرص',
packageSize: '120.00',
dosageLogic: 'یک قرص به ازای هر ۱۰ کیلوگرم وزن بدن سگ',
suitableFor: 'سگ',
imageUrl: 'https://example.com/canhydrox.png',
createdAt: '2026-05-26T18:10:00.000Z',
ingredients: [
{
productId: 'a1b2c3d4-1234-5678-abcd-ef1234567890',
ingredient: 'صدف لب‌سبز',
},
],
symptoms: [
{
productId: 'a1b2c3d4-1234-5678-abcd-ef1234567890',
symptom: 'لنگیدن',
},
],
},
},
})
@ApiNotFoundResponse({
description: 'محصول با شناسه ارسال شده پیدا نشد',
schema: {
example: {
success: false,
message:
'Product with ID a1b2c3d4-1234-5678-abcd-ef1234567890 not found',
code: 'NOT_FOUND',
details: {},
},
},
})
async findOne(@Param('id') id: string) {
const product = await this.productsService.findOne(id);
if (!product) {