feat: complete backend swagger annotations, admin pages pagination, and frontend application fixes

This commit is contained in:
parsa committed 2026-07-10 16:13:52 +03:30
1 parent 24137beb32
commit 2851ef8a25
41 files changed
+478 -128

No files matched your search

+6 -5
View File
@@ -1,6 +1,7 @@
import { Controller, Get, Param, HttpStatus } from '@nestjs/common';
import { Controller, Get, Param, HttpStatus, Query } from '@nestjs/common';
import { BlogsService } from './blogs.service';
import { ApiTags, ApiOperation, ApiResponse, ApiOkResponse, ApiNotFoundResponse } from '@nestjs/swagger';
import { ApiTags, ApiOperation, ApiResponse, ApiOkResponse, ApiNotFoundResponse, ApiQuery } from '@nestjs/swagger';
import { PaginationDto } from '../common/dto/pagination.dto';
@ApiTags('Blogs - مجله سلامت')
@Controller('blogs')
@@ -13,9 +14,9 @@ export class BlogsController {
@Get()
@ApiOperation({ summary: 'دریافت لیست مقالات مجله سلامت' })
@ApiOkResponse({ description: 'لیست مقالات منتشر شده' })
findAll() {
return this.blogsService.findAll();
@ApiOkResponse({ description: 'لیست مقالات منتشر شده (صفحه‌بندی شده)' })
findAll(@Query() query: PaginationDto) {
return this.blogsService.findAll(query);
}
@Get(':slug')
+36 -8
View File
@@ -1,20 +1,48 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { PaginationDto } from '../common/dto/pagination.dto';
@Injectable()
export class BlogsService {
constructor(private prisma: PrismaService) {}
async findAll() {
return this.prisma.blog.findMany({
where: { isPublished: true },
orderBy: { createdAt: 'desc' },
include: {
author: {
select: { firstName: true, lastName: true }
async findAll(filters: PaginationDto) {
const { search, page = 1, limit = 10, sortBy = 'createdAt', sortOrder = 'desc' } = filters;
const whereClause: any = { isPublished: true };
if (search) {
whereClause.OR = [
{ title: { contains: search, mode: 'insensitive' } },
{ content: { contains: search, mode: 'insensitive' } },
];
}
const skip = (page - 1) * limit;
const [data, total] = await Promise.all([
this.prisma.blog.findMany({
where: whereClause,
skip,
take: limit,
orderBy: { [sortBy]: sortOrder },
include: {
author: {
select: { firstName: true, lastName: true }
}
}
}),
this.prisma.blog.count({ where: whereClause })
]);
return {
data,
meta: {
total,
page,
lastPage: Math.ceil(total / limit),
limit,
}
});
};
}
async findOneBySlug(slug: string) {