get all tickets
This commit is contained in:
@@ -9,6 +9,7 @@ import { User } from "src/modules/user/entities/user.entity";
|
||||
import { UserRepository } from "src/modules/user/repositories/user.repository";
|
||||
import { AdminRepository } from "src/modules/admin/repositories/admin.repository";
|
||||
import { Admin } from "src/modules/admin/entities/admin.entity";
|
||||
import { FindTicketQueryDto } from "../DTO/search-ticket-query.dto";
|
||||
|
||||
|
||||
@Injectable()
|
||||
@@ -35,7 +36,7 @@ export class TicketService {
|
||||
|
||||
let user: null | User = null
|
||||
let admin: null | Admin = null
|
||||
|
||||
|
||||
if (userId) {
|
||||
user = await this.userRepository.findOne({ id: userId })
|
||||
if (!user) {
|
||||
@@ -334,19 +335,23 @@ export class TicketService {
|
||||
|
||||
// //******************************** */
|
||||
|
||||
// async getTickets(queryDto: SearchTicketQueryDto, userId: string) {
|
||||
// const [tickets, count] = await this.ticketsRepository.findTicketsList(queryDto, userId);
|
||||
async getTickets(orderId: string, queryDto: FindTicketQueryDto, userId?: string) {
|
||||
|
||||
// return { tickets, count, paginate: true };
|
||||
// }
|
||||
// //******************************** */
|
||||
// async getTicketForAdmin(queryDto: SearchTicketQueryDto, adminId: string) {
|
||||
// const isSuperAdmin = await this.usersService.isSuperAdmin(adminId);
|
||||
const order = await this.orderRepository.findOne({ id: orderId })
|
||||
if (!order) {
|
||||
throw new BadRequestException("order not found!")
|
||||
}
|
||||
if(userId){
|
||||
if (order.user.id !== userId) {
|
||||
throw new BadRequestException("This ticket doenst belongs to You !")
|
||||
}
|
||||
}
|
||||
const data = await this.ticketsRepository.findAllPaginated({ ...queryDto, orderId });
|
||||
|
||||
// const [tickets, count] = await this.ticketsRepository.findTicketsListForAdmin(queryDto, adminId, isSuperAdmin);
|
||||
return data
|
||||
}
|
||||
//******************************** */
|
||||
|
||||
// return { tickets, count, paginate: true };
|
||||
// }
|
||||
|
||||
// //******************************** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user