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

+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) {