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
@@ -3,6 +3,7 @@ import {
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Patch,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
@@ -19,7 +20,6 @@ import {
|
||||
ApiOperation,
|
||||
ApiQuery,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
|
||||
@ApiTags('Admin - مدیریت مقالات (بلاگ)')
|
||||
@@ -31,9 +31,9 @@ export class BlogsController {
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'لیست مقالات' })
|
||||
@ApiQuery({ name: 'page', required: false, description: 'شماره صفحه' })
|
||||
@ApiQuery({ name: 'limit', required: false, description: 'تعداد آیتمها' })
|
||||
@ApiQuery({ name: 'search', required: false, description: 'جستجو' })
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
@ApiQuery({ name: 'search', required: false })
|
||||
async getBlogs(@Query() query: PaginationDto) {
|
||||
return this.blogsService.getBlogs(query);
|
||||
}
|
||||
@@ -64,4 +64,43 @@ export class BlogsController {
|
||||
await this.blogsService.deleteBlog(id);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
// Blog Comments endpoints
|
||||
@Get('comments')
|
||||
@ApiOperation({ summary: 'لیست نظرات مقالات' })
|
||||
@ApiQuery({
|
||||
name: 'status',
|
||||
required: false,
|
||||
description: 'PENDING | APPROVED | REJECTED',
|
||||
})
|
||||
@ApiQuery({ name: 'blogId', required: false })
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
async getComments(
|
||||
@Query()
|
||||
query: {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
status?: string;
|
||||
blogId?: string;
|
||||
},
|
||||
) {
|
||||
return this.blogsService.getComments(query);
|
||||
}
|
||||
|
||||
@Patch('comments/:id/status')
|
||||
@ApiOperation({ summary: 'تغییر وضعیت نظر (تأیید/رد)' })
|
||||
async updateCommentStatus(
|
||||
@Param('id') id: string,
|
||||
@Body() body: { status: 'APPROVED' | 'REJECTED' },
|
||||
) {
|
||||
return this.blogsService.updateCommentStatus(id, body.status);
|
||||
}
|
||||
|
||||
@Delete('comments/:id')
|
||||
@ApiOperation({ summary: 'حذف نظر' })
|
||||
async deleteComment(@Param('id') id: string) {
|
||||
await this.blogsService.deleteComment(id);
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,13 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
export class BlogQuery {
|
||||
page?: number | string;
|
||||
limit?: number | string;
|
||||
search?: string;
|
||||
}
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
|
||||
@Injectable()
|
||||
export class BlogsService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
async getBlogs(query: BlogQuery = {}) {
|
||||
async getBlogs(query: PaginationDto) {
|
||||
const page = Number(query.page) || 1;
|
||||
const limit = Number(query.limit) || 10;
|
||||
const skip = (page - 1) * limit;
|
||||
@@ -27,7 +22,10 @@ export class BlogsService {
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: { author: { select: { firstName: true, lastName: true } } },
|
||||
include: {
|
||||
author: { select: { firstName: true, lastName: true } },
|
||||
_count: { select: { comments: true } },
|
||||
},
|
||||
}),
|
||||
this.prisma.blog.count({ where }),
|
||||
]);
|
||||
@@ -63,4 +61,51 @@ export class BlogsService {
|
||||
if (!blog) throw new NotFoundException('Blog not found');
|
||||
return this.prisma.blog.delete({ where: { id } });
|
||||
}
|
||||
|
||||
// Blog Comments Management
|
||||
async getComments(query: {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
status?: string;
|
||||
blogId?: string;
|
||||
}) {
|
||||
const page = Number(query.page) || 1;
|
||||
const limit = Number(query.limit) || 20;
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
const where: Prisma.BlogCommentWhereInput = {};
|
||||
if (query.status) where.status = query.status;
|
||||
if (query.blogId) where.blogId = query.blogId;
|
||||
|
||||
const [data, total] = await Promise.all([
|
||||
this.prisma.blogComment.findMany({
|
||||
where,
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: {
|
||||
blog: { select: { title: true, slug: true } },
|
||||
user: { select: { firstName: true, lastName: true, mobile: true } },
|
||||
},
|
||||
}),
|
||||
this.prisma.blogComment.count({ where }),
|
||||
]);
|
||||
|
||||
return {
|
||||
data,
|
||||
meta: { total, page, limit, lastPage: Math.ceil(total / limit) },
|
||||
};
|
||||
}
|
||||
|
||||
async updateCommentStatus(id: string, status: 'APPROVED' | 'REJECTED') {
|
||||
const comment = await this.prisma.blogComment.findUnique({ where: { id } });
|
||||
if (!comment) throw new NotFoundException('Comment not found');
|
||||
return this.prisma.blogComment.update({ where: { id }, data: { status } });
|
||||
}
|
||||
|
||||
async deleteComment(id: string) {
|
||||
const comment = await this.prisma.blogComment.findUnique({ where: { id } });
|
||||
if (!comment) throw new NotFoundException('Comment not found');
|
||||
return this.prisma.blogComment.delete({ where: { id } });
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ import { PaymentModule } from './payment/payment.module';
|
||||
import { TicketsModule } from './tickets/tickets.module';
|
||||
import { ReviewsModule } from './reviews/reviews.module';
|
||||
import { DoctorsModule } from './doctors/doctors.module';
|
||||
import { FaqModule } from './faq/faq.module';
|
||||
import { MenuModule } from './menu/menu.module';
|
||||
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
|
||||
@@ -70,6 +72,8 @@ import { Request, Response, NextFunction } from 'express';
|
||||
IngredientsModule,
|
||||
PrescriptionsModule,
|
||||
B2BModule,
|
||||
FaqModule,
|
||||
MenuModule,
|
||||
],
|
||||
controllers: [MetricsController],
|
||||
providers: [
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
import { Controller, Get, Param, HttpStatus, Query } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Param,
|
||||
Body,
|
||||
HttpStatus,
|
||||
Query,
|
||||
UseGuards,
|
||||
Request,
|
||||
} from '@nestjs/common';
|
||||
import { BlogsService } from './blogs.service';
|
||||
import {
|
||||
ApiTags,
|
||||
@@ -6,8 +16,10 @@ import {
|
||||
ApiResponse,
|
||||
ApiOkResponse,
|
||||
ApiNotFoundResponse,
|
||||
ApiBearerAuth,
|
||||
} from '@nestjs/swagger';
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
|
||||
@ApiTags('Blogs - مجله سلامت')
|
||||
@Controller('blogs')
|
||||
@@ -25,6 +37,13 @@ export class BlogsController {
|
||||
return this.blogsService.findAll(query);
|
||||
}
|
||||
|
||||
@Get('homepage')
|
||||
@ApiOperation({ summary: 'دریافت مقالات برای نمایش در صفحه اصلی' })
|
||||
@ApiOkResponse({ description: 'مقالات انتخاب شده برای صفحه اصلی' })
|
||||
findHomepage() {
|
||||
return this.blogsService.findHomepage();
|
||||
}
|
||||
|
||||
@Get(':slug')
|
||||
@ApiOperation({ summary: 'دریافت مقاله با اسلاگ (Slug)' })
|
||||
@ApiOkResponse({ description: 'اطلاعات کامل مقاله' })
|
||||
@@ -32,4 +51,25 @@ export class BlogsController {
|
||||
findOne(@Param('slug') slug: string) {
|
||||
return this.blogsService.findOneBySlug(slug);
|
||||
}
|
||||
|
||||
@Get(':slug/comments')
|
||||
@ApiOperation({ summary: 'دریافت نظرات تأیید شده مقاله' })
|
||||
findComments(@Param('slug') slug: string) {
|
||||
return this.blogsService.findCommentsBySlug(slug);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post(':slug/comments')
|
||||
@ApiOperation({ summary: 'ارسال نظر برای مقاله (نیازمند ورود)' })
|
||||
addComment(
|
||||
@Param('slug') slug: string,
|
||||
@Body() body: { userName: string; content: string },
|
||||
@Request() req: any,
|
||||
) {
|
||||
return this.blogsService.addComment(slug, {
|
||||
...body,
|
||||
userId: req.user?.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,9 @@ export class BlogsService {
|
||||
author: {
|
||||
select: { firstName: true, lastName: true },
|
||||
},
|
||||
_count: {
|
||||
select: { comments: true },
|
||||
},
|
||||
},
|
||||
}),
|
||||
this.prisma.blog.count({ where: whereClause }),
|
||||
@@ -52,6 +55,36 @@ export class BlogsService {
|
||||
};
|
||||
}
|
||||
|
||||
async findHomepage() {
|
||||
// Find blogs that have showOnHome = true (selected mode)
|
||||
const selectedBlogs = await this.prisma.blog.findMany({
|
||||
where: { isPublished: true, showOnHome: true },
|
||||
take: 3,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: {
|
||||
author: { select: { firstName: true, lastName: true } },
|
||||
_count: { select: { comments: true } },
|
||||
},
|
||||
});
|
||||
|
||||
if (selectedBlogs.length > 0) {
|
||||
return { mode: 'selected', blogs: selectedBlogs };
|
||||
}
|
||||
|
||||
// Fallback: return newest 3 published blogs
|
||||
const newestBlogs = await this.prisma.blog.findMany({
|
||||
where: { isPublished: true },
|
||||
take: 3,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: {
|
||||
author: { select: { firstName: true, lastName: true } },
|
||||
_count: { select: { comments: true } },
|
||||
},
|
||||
});
|
||||
|
||||
return { mode: 'newest', blogs: newestBlogs };
|
||||
}
|
||||
|
||||
async findOneBySlug(slug: string) {
|
||||
const blog = await this.prisma.blog.findUnique({
|
||||
where: { slug, isPublished: true },
|
||||
@@ -59,6 +92,9 @@ export class BlogsService {
|
||||
author: {
|
||||
select: { firstName: true, lastName: true },
|
||||
},
|
||||
_count: {
|
||||
select: { comments: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -66,6 +102,46 @@ export class BlogsService {
|
||||
throw new NotFoundException('مقاله یافت نشد');
|
||||
}
|
||||
|
||||
return blog;
|
||||
// Increment view count
|
||||
await this.prisma.blog.update({
|
||||
where: { id: blog.id },
|
||||
data: { viewCount: { increment: 1 } },
|
||||
});
|
||||
|
||||
return { ...blog, viewCount: blog.viewCount + 1 };
|
||||
}
|
||||
|
||||
async findCommentsBySlug(slug: string) {
|
||||
const blog = await this.prisma.blog.findUnique({
|
||||
where: { slug, isPublished: true },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!blog) throw new NotFoundException('مقاله یافت نشد');
|
||||
|
||||
return this.prisma.blogComment.findMany({
|
||||
where: { blogId: blog.id, status: 'APPROVED' },
|
||||
orderBy: { createdAt: 'asc' },
|
||||
});
|
||||
}
|
||||
|
||||
async addComment(
|
||||
slug: string,
|
||||
data: { userName: string; content: string; userId?: string },
|
||||
) {
|
||||
const blog = await this.prisma.blog.findUnique({
|
||||
where: { slug, isPublished: true },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!blog) throw new NotFoundException('مقاله یافت نشد');
|
||||
|
||||
return this.prisma.blogComment.create({
|
||||
data: {
|
||||
blogId: blog.id,
|
||||
userName: data.userName,
|
||||
content: data.content,
|
||||
userId: data.userId,
|
||||
status: 'PENDING',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { FaqService } from './faq.service';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth } 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('FAQ - سوالات متداول')
|
||||
@Controller('faq')
|
||||
export class FaqController {
|
||||
constructor(private readonly faqService: FaqService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'دریافت سوالات متداول فعال برای صفحه اصلی' })
|
||||
findActive() {
|
||||
return this.faqService.findActive();
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Get('admin')
|
||||
@ApiOperation({ summary: 'دریافت تمام سوالات (ادمین)' })
|
||||
findAll() {
|
||||
return this.faqService.findAll();
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'ایجاد سوال متداول جدید' })
|
||||
create(
|
||||
@Body()
|
||||
body: {
|
||||
question: string;
|
||||
answer: string;
|
||||
order?: number;
|
||||
isActive?: boolean;
|
||||
},
|
||||
) {
|
||||
return this.faqService.create(body);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Put('reorder')
|
||||
@ApiOperation({ summary: 'مرتبسازی سوالات' })
|
||||
reorder(@Body() body: { items: { id: string; order: number }[] }) {
|
||||
return this.faqService.reorder(body.items);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'ویرایش سوال متداول' })
|
||||
update(
|
||||
@Param('id') id: string,
|
||||
@Body()
|
||||
body: Partial<{
|
||||
question: string;
|
||||
answer: string;
|
||||
order: number;
|
||||
isActive: boolean;
|
||||
}>,
|
||||
) {
|
||||
return this.faqService.update(id, body);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'حذف سوال متداول' })
|
||||
remove(@Param('id') id: string) {
|
||||
return this.faqService.remove(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { FaqController } from './faq.controller';
|
||||
import { FaqService } from './faq.service';
|
||||
|
||||
@Module({
|
||||
controllers: [FaqController],
|
||||
providers: [FaqService],
|
||||
})
|
||||
export class FaqModule {}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class FaqService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
// Public: only active FAQs
|
||||
async findActive() {
|
||||
return this.prisma.fAQ.findMany({
|
||||
where: { isActive: true },
|
||||
orderBy: { order: 'asc' },
|
||||
});
|
||||
}
|
||||
|
||||
// Admin: all FAQs
|
||||
async findAll() {
|
||||
return this.prisma.fAQ.findMany({
|
||||
orderBy: { order: 'asc' },
|
||||
});
|
||||
}
|
||||
|
||||
async create(data: {
|
||||
question: string;
|
||||
answer: string;
|
||||
order?: number;
|
||||
isActive?: boolean;
|
||||
}) {
|
||||
return this.prisma.fAQ.create({ data });
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
data: Partial<{
|
||||
question: string;
|
||||
answer: string;
|
||||
order: number;
|
||||
isActive: boolean;
|
||||
}>,
|
||||
) {
|
||||
const faq = await this.prisma.fAQ.findUnique({ where: { id } });
|
||||
if (!faq) throw new NotFoundException('سوال یافت نشد');
|
||||
return this.prisma.fAQ.update({ where: { id }, data });
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
const faq = await this.prisma.fAQ.findUnique({ where: { id } });
|
||||
if (!faq) throw new NotFoundException('سوال یافت نشد');
|
||||
return this.prisma.fAQ.delete({ where: { id } });
|
||||
}
|
||||
|
||||
async reorder(items: { id: string; order: number }[]) {
|
||||
await Promise.all(
|
||||
items.map((item) =>
|
||||
this.prisma.fAQ.update({
|
||||
where: { id: item.id },
|
||||
data: { order: item.order },
|
||||
}),
|
||||
),
|
||||
);
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { MenuService } from './menu.service';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiBearerAuth,
|
||||
ApiQuery,
|
||||
} 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('Menu - مدیریت منو')
|
||||
@Controller('menu')
|
||||
export class MenuController {
|
||||
constructor(private readonly menuService: MenuService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'دریافت منو عمومی بر اساس نوع' })
|
||||
@ApiQuery({
|
||||
name: 'type',
|
||||
required: true,
|
||||
description: 'HEADER | FOOTER_COL1 | FOOTER_COL2 | FOOTER_COL3',
|
||||
})
|
||||
findByType(@Query('type') type: string) {
|
||||
return this.menuService.findByType(type);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Get('admin')
|
||||
@ApiOperation({ summary: 'دریافت تمام آیتمهای منو (ادمین)' })
|
||||
@ApiQuery({ name: 'type', required: false })
|
||||
findAllAdmin(@Query('type') type?: string) {
|
||||
return this.menuService.findAllAdmin(type);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'ایجاد آیتم منو جدید' })
|
||||
create(
|
||||
@Body()
|
||||
body: {
|
||||
menuType: string;
|
||||
label: string;
|
||||
href: string;
|
||||
parentId?: string;
|
||||
order?: number;
|
||||
isActive?: boolean;
|
||||
isExternal?: boolean;
|
||||
icon?: string;
|
||||
badge?: string;
|
||||
},
|
||||
) {
|
||||
return this.menuService.create(body);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Put('reorder')
|
||||
@ApiOperation({ summary: 'مرتبسازی آیتمهای منو' })
|
||||
reorder(@Body() body: { items: { id: string; order: number }[] }) {
|
||||
return this.menuService.reorder(body.items);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'ویرایش آیتم منو' })
|
||||
update(
|
||||
@Param('id') id: string,
|
||||
@Body()
|
||||
body: Partial<{
|
||||
menuType: string;
|
||||
label: string;
|
||||
href: string;
|
||||
parentId: string | null;
|
||||
order: number;
|
||||
isActive: boolean;
|
||||
isExternal: boolean;
|
||||
icon: string;
|
||||
badge: string;
|
||||
}>,
|
||||
) {
|
||||
return this.menuService.update(id, body);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'حذف آیتم منو' })
|
||||
remove(@Param('id') id: string) {
|
||||
return this.menuService.remove(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { MenuController } from './menu.controller';
|
||||
import { MenuService } from './menu.service';
|
||||
|
||||
@Module({
|
||||
controllers: [MenuController],
|
||||
providers: [MenuService],
|
||||
exports: [MenuService],
|
||||
})
|
||||
export class MenuModule {}
|
||||
@@ -0,0 +1,145 @@
|
||||
import { Injectable, NotFoundException, OnModuleInit } from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
export type MenuType = 'HEADER' | 'FOOTER_COL1' | 'FOOTER_COL2' | 'FOOTER_COL3';
|
||||
|
||||
@Injectable()
|
||||
export class MenuService implements OnModuleInit {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
async onModuleInit() {
|
||||
await this.seedIfEmpty();
|
||||
}
|
||||
|
||||
private async seedIfEmpty() {
|
||||
const count = await this.prisma.menuItem.count();
|
||||
if (count > 0) return;
|
||||
|
||||
// Seed with current site navigation
|
||||
const headerItems = [
|
||||
{ label: 'راهکارهای درمانی', href: '/shop?view=symptoms', order: 1 },
|
||||
{ label: 'محصولات تخصصی', href: '/shop', order: 2 },
|
||||
{ label: 'دانشنامه علمی', href: '/wiki', order: 3 },
|
||||
{ label: 'مجله سلامت پت', href: '/blog', order: 4 },
|
||||
{ label: 'شناسنامه پتها', href: '/dashboard/pets', order: 5 },
|
||||
{ label: 'ویدیوها', href: '/videos', order: 6 },
|
||||
];
|
||||
|
||||
const footerCol1 = [
|
||||
{ label: 'درباره کنینا آلمان', href: '/about', order: 1 },
|
||||
{ label: 'تماس با ما', href: '/contact', order: 2 },
|
||||
{ label: 'مجوزها و گواهیها', href: '/trust-seals', order: 3 },
|
||||
{ label: 'حریم خصوصی', href: '/privacy', order: 4 },
|
||||
];
|
||||
|
||||
const footerCol2 = [
|
||||
{ label: 'فروشگاه تخصصی', href: '/shop', order: 1 },
|
||||
{ label: 'دستهٔبندی درمانی', href: '/shop?view=symptoms', order: 2 },
|
||||
{ label: 'دانشنامه علمی', href: '/wiki', order: 3 },
|
||||
{ label: 'مجله سلامت پت', href: '/blog', order: 4 },
|
||||
];
|
||||
|
||||
const footerCol3 = [
|
||||
{ label: 'شناسنامه پتها', href: '/dashboard/pets', order: 1 },
|
||||
{ label: 'سفارشات من', href: '/dashboard/orders', order: 2 },
|
||||
{ label: 'ردیابی سفارش', href: '/track', order: 3 },
|
||||
{ label: 'ورود / ثبتنام', href: '/?login=1', order: 4 },
|
||||
];
|
||||
|
||||
const createItems = (items: typeof headerItems, menuType: MenuType) =>
|
||||
items.map((item) => ({
|
||||
...item,
|
||||
menuType,
|
||||
isActive: true,
|
||||
isExternal: false,
|
||||
}));
|
||||
|
||||
await this.prisma.menuItem.createMany({
|
||||
data: [
|
||||
...createItems(headerItems, 'HEADER'),
|
||||
...createItems(footerCol1, 'FOOTER_COL1'),
|
||||
...createItems(footerCol2, 'FOOTER_COL2'),
|
||||
...createItems(footerCol3, 'FOOTER_COL3'),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async findByType(menuType: string) {
|
||||
const items = await this.prisma.menuItem.findMany({
|
||||
where: { menuType, isActive: true, parentId: null },
|
||||
orderBy: { order: 'asc' },
|
||||
include: {
|
||||
children: {
|
||||
where: { isActive: true },
|
||||
orderBy: { order: 'asc' },
|
||||
},
|
||||
},
|
||||
});
|
||||
return items;
|
||||
}
|
||||
|
||||
async findAllAdmin(menuType?: string) {
|
||||
return this.prisma.menuItem.findMany({
|
||||
where: menuType ? { menuType } : undefined,
|
||||
orderBy: [{ menuType: 'asc' }, { order: 'asc' }],
|
||||
include: {
|
||||
children: {
|
||||
orderBy: { order: 'asc' },
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async create(data: {
|
||||
menuType: string;
|
||||
label: string;
|
||||
href: string;
|
||||
parentId?: string;
|
||||
order?: number;
|
||||
isActive?: boolean;
|
||||
isExternal?: boolean;
|
||||
icon?: string;
|
||||
badge?: string;
|
||||
}) {
|
||||
return this.prisma.menuItem.create({ data });
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
data: Partial<{
|
||||
menuType: string;
|
||||
label: string;
|
||||
href: string;
|
||||
parentId: string | null;
|
||||
order: number;
|
||||
isActive: boolean;
|
||||
isExternal: boolean;
|
||||
icon: string;
|
||||
badge: string;
|
||||
}>,
|
||||
) {
|
||||
const item = await this.prisma.menuItem.findUnique({ where: { id } });
|
||||
if (!item) throw new NotFoundException('Menu item not found');
|
||||
return this.prisma.menuItem.update({ where: { id }, data });
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
const item = await this.prisma.menuItem.findUnique({ where: { id } });
|
||||
if (!item) throw new NotFoundException('Menu item not found');
|
||||
// Delete children first
|
||||
await this.prisma.menuItem.deleteMany({ where: { parentId: id } });
|
||||
return this.prisma.menuItem.delete({ where: { id } });
|
||||
}
|
||||
|
||||
async reorder(items: { id: string; order: number }[]) {
|
||||
await Promise.all(
|
||||
items.map((item) =>
|
||||
this.prisma.menuItem.update({
|
||||
where: { id: item.id },
|
||||
data: { order: item.order },
|
||||
}),
|
||||
),
|
||||
);
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
@@ -167,88 +167,133 @@ export const DEFAULT_UI_TEXTS: Record<string, string> = {
|
||||
title_separator: '|',
|
||||
title_position: 'suffix',
|
||||
defaultMetaTitle: 'کنینا ایران | نماینده رسمی مکملهای دارویی Canina آلمان',
|
||||
defaultMetaDescription: 'فروشگاه تخصصی و نماینده انحصاری مکملهای درمانی و تقویتی سگ و گربه کنینا آلمان با فرمولاسیون دارویی و تاییدیه بالینی.',
|
||||
defaultMetaDescription:
|
||||
'فروشگاه تخصصی و نماینده انحصاری مکملهای درمانی و تقویتی سگ و گربه کنینا آلمان با فرمولاسیون دارویی و تاییدیه بالینی.',
|
||||
canonicalBaseUrl: 'https://canina.ir',
|
||||
ogImageUrl: '/assets/images/regenerated_image_1779109861747.png',
|
||||
|
||||
// === Page-by-Page SEO Metadata Defaults ===
|
||||
home_meta_title: 'کنینا ایران | نماینده رسمی مکملهای دارویی Canina آلمان',
|
||||
home_meta_desc: 'فروشگاه تخصصی و نماینده انحصاری مکملهای درمانی و تقویتی سگ و گربه کنینا آلمان با فرمولاسیون دارویی و تاییدیه بالینی.',
|
||||
home_keywords: 'کنینا, مکمل سگ, مکمل گربه, مکمل دارویی حیوانات, Canina Germany',
|
||||
home_meta_desc:
|
||||
'فروشگاه تخصصی و نماینده انحصاری مکملهای درمانی و تقویتی سگ و گربه کنینا آلمان با فرمولاسیون دارویی و تاییدیه بالینی.',
|
||||
home_keywords:
|
||||
'کنینا, مکمل سگ, مکمل گربه, مکمل دارویی حیوانات, Canina Germany',
|
||||
home_canonical: 'https://canina.ir',
|
||||
|
||||
shop_meta_title: 'فروشگاه تخصصی مکملهای دارویی سگ و گربه',
|
||||
shop_meta_desc: 'خرید آنلاین انواع مکملهای درمانی مفاصل، پوست و مو، گوارش و ایمنی، رشد و ویتامینه سگ و گربه با ضمانت اصالت کنینا آلمان.',
|
||||
shop_keywords: 'خرید مکمل سگ, خرید مکمل گربه, مکمل مفاصل پت, پت شاپ تخصصی دارویی',
|
||||
shop_meta_desc:
|
||||
'خرید آنلاین انواع مکملهای درمانی مفاصل، پوست و مو، گوارش و ایمنی، رشد و ویتامینه سگ و گربه با ضمانت اصالت کنینا آلمان.',
|
||||
shop_keywords:
|
||||
'خرید مکمل سگ, خرید مکمل گربه, مکمل مفاصل پت, پت شاپ تخصصی دارویی',
|
||||
shop_canonical: 'https://canina.ir/shop',
|
||||
|
||||
catalog_meta_title: 'کاتالوگ رسمی مکملهای درمانی و دارویی',
|
||||
catalog_meta_desc: 'مشاهده و مطالعه کاتالوگ جامع دارویی و مکملهای تغذیهای تخصصی کنینا آلمان با قابلیت ورقزدن تعاملی و ثبت پیشخرید.',
|
||||
catalog_keywords: 'کاتالوگ کنینا, کاتالوگ محصولات Canina, راهنمای مکملهای دارویی پت',
|
||||
catalog_meta_desc:
|
||||
'مشاهده و مطالعه کاتالوگ جامع دارویی و مکملهای تغذیهای تخصصی کنینا آلمان با قابلیت ورقزدن تعاملی و ثبت پیشخرید.',
|
||||
catalog_keywords:
|
||||
'کاتالوگ کنینا, کاتالوگ محصولات Canina, راهنمای مکملهای دارویی پت',
|
||||
catalog_canonical: 'https://canina.ir/catalog',
|
||||
|
||||
blog_meta_title: 'مجله سلامت و دانشنامه مقالات تخصصی پت',
|
||||
blog_meta_desc: 'جدیدترین مقالات علمی، راهنمای تغذیه، بیماریهای سگ و گربه و توصیههای بالینی متخصصان و دامپزشکان کنینا.',
|
||||
blog_keywords: 'مقالات سگ و گربه, مجله سلامت حیوانات, تغذیه پت, بیماریهای سگ و گربه',
|
||||
blog_meta_desc:
|
||||
'جدیدترین مقالات علمی، راهنمای تغذیه، بیماریهای سگ و گربه و توصیههای بالینی متخصصان و دامپزشکان کنینا.',
|
||||
blog_keywords:
|
||||
'مقالات سگ و گربه, مجله سلامت حیوانات, تغذیه پت, بیماریهای سگ و گربه',
|
||||
blog_canonical: 'https://canina.ir/blog',
|
||||
|
||||
wiki_meta_title: 'دانشنامه علمی ترکیبات و اصطلاحات دارویی',
|
||||
wiki_meta_desc: 'مرجع تخصصی اثرات بالینی، مواد تشکیلدهنده، ویتامینها و ترکیبات ارگانیک به کار رفته در مکملهای دارویی کنینا آلمان.',
|
||||
wiki_keywords: 'دانشنامه دارویی پت, ترکیبات مکمل سگ, گلوکوزامین سگ, صدف سبز نیوزیلند',
|
||||
wiki_meta_desc:
|
||||
'مرجع تخصصی اثرات بالینی، مواد تشکیلدهنده، ویتامینها و ترکیبات ارگانیک به کار رفته در مکملهای دارویی کنینا آلمان.',
|
||||
wiki_keywords:
|
||||
'دانشنامه دارویی پت, ترکیبات مکمل سگ, گلوکوزامین سگ, صدف سبز نیوزیلند',
|
||||
wiki_canonical: 'https://canina.ir/wiki',
|
||||
|
||||
about_meta_title: 'درباره شرکت کنینا ایران و اصالت آلمانی',
|
||||
about_meta_desc: 'داستان کنینا ایران و بیش از ۴۰ سال سابقه درخشان شرکت Canina pharma GmbH آلمان در تولید مکملهای فوقتخصصی دامپزشکی.',
|
||||
about_keywords: 'درباره کنینا, شرکت Canina pharma, تاریخچه مکمل کنینا, استاندارد دارویی آلمان',
|
||||
about_meta_desc:
|
||||
'داستان کنینا ایران و بیش از ۴۰ سال سابقه درخشان شرکت Canina pharma GmbH آلمان در تولید مکملهای فوقتخصصی دامپزشکی.',
|
||||
about_keywords:
|
||||
'درباره کنینا, شرکت Canina pharma, تاریخچه مکمل کنینا, استاندارد دارویی آلمان',
|
||||
about_canonical: 'https://canina.ir/about',
|
||||
|
||||
contact_meta_title: 'تماس با ما و مشاوره تخصصی دامپزشکی',
|
||||
contact_meta_desc: 'راههای ارتباطی با دفتر مرکزی کنینا ایران، مشاوره تلفنی رایگان، پشتیبانی آنلاین و نشانی.',
|
||||
contact_meta_desc:
|
||||
'راههای ارتباطی با دفتر مرکزی کنینا ایران، مشاوره تلفنی رایگان، پشتیبانی آنلاین و نشانی.',
|
||||
contact_keywords: 'تماس با کنینا, پشتیبانی کنینا ایران, مشاوره دارویی پت',
|
||||
contact_canonical: 'https://canina.ir/contact',
|
||||
|
||||
b2b_meta_title: 'پرتال همکاران تجاری، کلینیکها و پتشاپها',
|
||||
b2b_meta_desc: 'ثبتنام و خرید عمده مکملهای دارویی کنینا ویژه کلینیکهای دامپزشکی، بیمارستانها و پتشاپهای سراسر کشور با تخفیف سازمانی.',
|
||||
b2b_meta_desc:
|
||||
'ثبتنام و خرید عمده مکملهای دارویی کنینا ویژه کلینیکهای دامپزشکی، بیمارستانها و پتشاپهای سراسر کشور با تخفیف سازمانی.',
|
||||
b2b_keywords: 'خرید عمده مکمل پت, نمایندگی کنینا, فروش سازمانی دامپزشکی',
|
||||
b2b_canonical: 'https://canina.ir/b2b',
|
||||
|
||||
videos_meta_title: 'ویدئوهای آموزشی و توصیههای بالینی دامپزشکان',
|
||||
videos_meta_desc: 'مشاهده ویدئوهای تخصصی نحوه مصرف مکملهای درمانی، نظرات دامپزشکان و راهکارهای بالینی تصویری.',
|
||||
videos_keywords: 'ویدیوهای آموزشی پت, راهنمای مصرف مکمل سگ, فیلم های دامپزشکی',
|
||||
videos_meta_desc:
|
||||
'مشاهده ویدئوهای تخصصی نحوه مصرف مکملهای درمانی، نظرات دامپزشکان و راهکارهای بالینی تصویری.',
|
||||
videos_keywords:
|
||||
'ویدیوهای آموزشی پت, راهنمای مصرف مکمل سگ, فیلم های دامپزشکی',
|
||||
videos_canonical: 'https://canina.ir/videos',
|
||||
|
||||
search_meta_title: 'جستجوی هوشمند مکملها و دانشنامه سلامت',
|
||||
search_meta_desc: 'جستجوی سریع در کاتالوگ محصولات، بیماریها، علائم بالینی و مقالات سلامت کنینا ایران.',
|
||||
search_meta_desc:
|
||||
'جستجوی سریع در کاتالوگ محصولات، بیماریها، علائم بالینی و مقالات سلامت کنینا ایران.',
|
||||
search_keywords: 'جستجوی داروی پت, سرچ مکمل کنینا',
|
||||
search_canonical: 'https://canina.ir/search',
|
||||
|
||||
dashboard_meta_title: 'داشبورد کاربری و پیگیری سفارشات',
|
||||
dashboard_meta_desc: 'مشاهده تاریخچه خریدها، وضعیت کیف پول، پیگیری آنلاین بستههای پستی و مدیریت پتها.',
|
||||
dashboard_meta_desc:
|
||||
'مشاهده تاریخچه خریدها، وضعیت کیف پول، پیگیری آنلاین بستههای پستی و مدیریت پتها.',
|
||||
dashboard_keywords: 'داشبورد کاربری, پروفایل کنینا',
|
||||
dashboard_canonical: 'https://canina.ir/dashboard',
|
||||
|
||||
profile_pets_meta_title: 'پرونده الکترونیک سلامت پت',
|
||||
profile_pets_meta_desc: 'مدیریت و ثبت پرونده سلامت سگ و گربه، تنظیم یادآورهای دوز دارو و تاریخچه تغذیه مکملها.',
|
||||
profile_pets_meta_desc:
|
||||
'مدیریت و ثبت پرونده سلامت سگ و گربه، تنظیم یادآورهای دوز دارو و تاریخچه تغذیه مکملها.',
|
||||
profile_pets_keywords: 'پرونده سلامت سگ, یادآور داروی پت, شناسنامه گربه',
|
||||
profile_pets_canonical: 'https://canina.ir/profile',
|
||||
|
||||
checkout_meta_title: 'تسویهحساب و پرداخت امن',
|
||||
checkout_meta_desc: 'انتخاب آدرس تحویل، روش ارسال و تسویهحساب سریع و امن سفارشات مکملهای کنینا.',
|
||||
checkout_meta_desc:
|
||||
'انتخاب آدرس تحویل، روش ارسال و تسویهحساب سریع و امن سفارشات مکملهای کنینا.',
|
||||
checkout_keywords: 'خرید آنلاین مکمل, پرداخت سفارش',
|
||||
checkout_canonical: 'https://canina.ir/checkout',
|
||||
|
||||
track_meta_title: 'پیگیری آنلاین سفارش و مرسوله پستی',
|
||||
track_meta_desc: 'پیگیری وضعیت لحظهای پردازش، بستهبندی و کد رهگیری پست پیشتاز سفارشات کنینا ایران.',
|
||||
track_meta_desc:
|
||||
'پیگیری وضعیت لحظهای پردازش، بستهبندی و کد رهگیری پست پیشتاز سفارشات کنینا ایران.',
|
||||
track_keywords: 'رهگیری پست پیشتاز, پیگیری سفارش کنینا',
|
||||
track_canonical: 'https://canina.ir/track',
|
||||
|
||||
trust_seals_meta_title: 'مجوزهای رسمی، گواهی اصالت و اینماد',
|
||||
trust_seals_meta_desc: 'بررسی تاییدیههای رسمی سازمان دامپزشکی کشور، گواهی استاندارد آلمان و اینماد رسمی کنینا ایران.',
|
||||
trust_seals_meta_desc:
|
||||
'بررسی تاییدیههای رسمی سازمان دامپزشکی کشور، گواهی استاندارد آلمان و اینماد رسمی کنینا ایران.',
|
||||
trust_seals_keywords: 'اینماد کنینا, مجوز دامپزشکی مکمل, اصالت کالا کنینا',
|
||||
trust_seals_canonical: 'https://canina.ir/trust-seals',
|
||||
|
||||
privacy_meta_title: 'حریم خصوصی و شرایط استفاده',
|
||||
privacy_meta_desc: 'سیاستهای حفاظت از اطلاعات شخصی کاربران، امنیت دادههای پزشکی و قوانین استفاده از خدمات کنینا ایران.',
|
||||
privacy_meta_desc:
|
||||
'سیاستهای حفاظت از اطلاعات شخصی کاربران، امنیت دادههای پزشکی و قوانین استفاده از خدمات کنینا ایران.',
|
||||
privacy_keywords: 'قوانین کنینا, شرایط مرجوعی, حریم خصوصی',
|
||||
privacy_canonical: 'https://canina.ir/privacy',
|
||||
|
||||
// === Testimonials Section (Homepage) ===
|
||||
testimonials_badge: 'صداهای واقعی، تجربههای اصیل',
|
||||
testimonials_title: 'مشتریان کنینا چه میگویند؟',
|
||||
testimonials_subtitle:
|
||||
'نظرات صادقانه صاحبان پت که از محصولات تخصصی کنینا استفاده کردهاند',
|
||||
|
||||
// === Blog Preview Section (Homepage) ===
|
||||
blog_preview_badge: 'آخرین مطالب تخصصی',
|
||||
blog_preview_title: 'مجله سلامت پت کنینا',
|
||||
blog_preview_subtitle:
|
||||
'مقالات علمی و تخصصی دامپزشکی برای مراقبت بهتر از حیوان خانگی شما',
|
||||
blog_preview_read_more: 'مشاهده همه مقالات',
|
||||
blog_preview_read_article: 'خواندن مقاله',
|
||||
blog_preview_views: 'بازدید',
|
||||
blog_preview_comments: 'نظر',
|
||||
|
||||
// === FAQ Section (Homepage) ===
|
||||
faq_badge: 'سوالات پرتکرار',
|
||||
faq_title: 'سوالات متداول',
|
||||
faq_subtitle: 'پاسخ سوالاتی که اغلب از ما میپرسید',
|
||||
};
|
||||
@@ -513,10 +513,14 @@ export class SettingsService implements OnModuleInit {
|
||||
updates['brand_name_en'] = brandEn;
|
||||
}
|
||||
if (obj.titleSeparator || obj.title_separator) {
|
||||
updates['title_separator'] = String(obj.titleSeparator || obj.title_separator);
|
||||
updates['title_separator'] = String(
|
||||
obj.titleSeparator || obj.title_separator,
|
||||
);
|
||||
}
|
||||
if (obj.titlePosition || obj.title_position) {
|
||||
updates['title_position'] = String(obj.titlePosition || obj.title_position);
|
||||
updates['title_position'] = String(
|
||||
obj.titlePosition || obj.title_position,
|
||||
);
|
||||
}
|
||||
if (obj.defaultMetaTitle) {
|
||||
updates['defaultMetaTitle'] = String(obj.defaultMetaTitle);
|
||||
|
||||
@@ -26,6 +26,12 @@ export class TestimonialsController {
|
||||
return this.testimonialsService.findAll();
|
||||
}
|
||||
|
||||
@Get('homepage')
|
||||
@ApiOperation({ summary: 'دریافت نظرات فعال برای نمایش در صفحه اصلی' })
|
||||
findHomepage() {
|
||||
return this.testimonialsService.findHomepage();
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
|
||||
@@ -12,6 +12,13 @@ export class TestimonialsService {
|
||||
});
|
||||
}
|
||||
|
||||
async findHomepage() {
|
||||
return this.prisma.testimonial.findMany({
|
||||
where: { isActive: true, showOnHome: true },
|
||||
orderBy: { order: 'asc' },
|
||||
});
|
||||
}
|
||||
|
||||
async create(data: Prisma.TestimonialCreateInput) {
|
||||
return this.prisma.testimonial.create({
|
||||
data,
|
||||
|
||||
Reference in new issue
Block a user