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

+27 -8
View File
@@ -1,5 +1,6 @@
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { PaginationDto } from '../common/dto/pagination.dto';
import { CreateOrderDto } from './dto/create-order.dto';
@Injectable()
@@ -43,14 +44,32 @@ export class OrdersService {
});
}
async findAllByUser(userId: string) {
return this.prisma.order.findMany({
where: { userId },
include: {
orderItems: { include: { product: true } },
},
orderBy: { createdAt: 'desc' },
});
async findAllByUser(userId: string, filters: PaginationDto) {
const { page = 1, limit = 10, sortBy = 'createdAt', sortOrder = 'desc' } = filters;
const skip = (page - 1) * limit;
const [data, total] = await Promise.all([
this.prisma.order.findMany({
where: { userId },
skip,
take: limit,
orderBy: { [sortBy]: sortOrder },
include: {
orderItems: { include: { product: true } },
},
}),
this.prisma.order.count({ where: { userId } })
]);
return {
data,
meta: {
total,
page,
lastPage: Math.ceil(total / limit),
limit,
}
};
}
async findOne(id: string, userId: string) {