feat(tickets): added a service function to get tickets according to email or session email and ticket status
This commit is contained in:
parent
a5fc7b1de9
commit
a32d636b6e
|
|
@ -1,45 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
To allow me to get all infos needed to display in the ticket list page i need to access these informations and how to get it :
|
|
||||||
|
|
||||||
-> ticket_id:
|
|
||||||
- ticket table:
|
|
||||||
using the account ids and delivery ids, i can :
|
|
||||||
i need first name and last name for contacts, i will use the account_ids to query the account table
|
|
||||||
i need to find the service_id, i need the product_id to query the service table.
|
|
||||||
|
|
||||||
-> status:
|
|
||||||
-ticket table : the status is here.
|
|
||||||
|
|
||||||
-> assign_to:
|
|
||||||
- ticket table :
|
|
||||||
displays a staff_id:
|
|
||||||
I need to query the staff table, using the email to get the id of the employee, its email, its first and last name,
|
|
||||||
|
|
||||||
-> deliveryAddress:
|
|
||||||
- ticket table: the account_id is here.
|
|
||||||
- delivery table: i can get the address here, using the account_id.
|
|
||||||
|
|
||||||
-> product_type:
|
|
||||||
- ticket table : using the account_id :
|
|
||||||
i can query the delivery table:
|
|
||||||
-delivery table:
|
|
||||||
get delivery id linked to the account id
|
|
||||||
i can query the service table
|
|
||||||
- service table:
|
|
||||||
delivery_id to get the product_id and device_id
|
|
||||||
- product table:
|
|
||||||
using the product_id, i can get the type here
|
|
||||||
-> department:
|
|
||||||
- ticket table:
|
|
||||||
i can get the dept_id here
|
|
||||||
- ticket_dept :
|
|
||||||
using the dept_id from the ticket table, i can get the name here.
|
|
||||||
-> parentTicketId:
|
|
||||||
- ticket table:
|
|
||||||
i can get the parent here.
|
|
||||||
-> dueDate, updatedAt, completedAt:
|
|
||||||
- ticket table:
|
|
||||||
i can get the due_date, last_update, Date_closed here.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Controller, Get, Param } from "@nestjs/common";
|
import { Controller, Get, Param } from "@nestjs/common";
|
||||||
|
import { Access } from "src/common/decorators/module-access.decorators";
|
||||||
import { ModuleAccessAllowed } from "src/common/decorators/modules-guard.decorators";
|
import { ModuleAccessAllowed } from "src/common/decorators/modules-guard.decorators";
|
||||||
import { Result } from "src/common/errors/result-error.factory";
|
import { Result } from "src/common/errors/result-error.factory";
|
||||||
import { TicketListItem } from "src/customer-support/tickets/dtos/ticket-list.dto";
|
import { TicketListItem } from "src/customer-support/tickets/dtos/ticket-list.dto";
|
||||||
|
|
@ -9,13 +10,18 @@ export class TicketController {
|
||||||
|
|
||||||
constructor(private readonly getService: TicketService) { }
|
constructor(private readonly getService: TicketService) { }
|
||||||
|
|
||||||
@Get(':email/:status')
|
@Get(':status/:email')
|
||||||
@ModuleAccessAllowed()
|
@ModuleAccessAllowed()
|
||||||
async findTicketByFilters(
|
async findTicketByFilters(
|
||||||
|
@Access('email') email: string,
|
||||||
@Param('status') status: string,
|
@Param('status') status: string,
|
||||||
@Param('email') email?: string,
|
@Param('email') filter_email?: string,
|
||||||
): Promise<Result<TicketListItem[], string>> {
|
): Promise<Result<TicketListItem[], string>> {
|
||||||
return await this.getService.getListOfAllTicketByFilters(status, email);
|
if (!filter_email) {
|
||||||
|
return await this.getService.getListOfAllTicketByFilters(status, email)
|
||||||
|
} else {
|
||||||
|
return await this.getService.getListOfAllTicketByFilters(status, filter_email);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +113,7 @@ export class SickLeaveService {
|
||||||
|
|
||||||
takeSickLeaveHours = async (employee_id: number, asked_hours: number): Promise<Result<number, string>> => {
|
takeSickLeaveHours = async (employee_id: number, asked_hours: number): Promise<Result<number, string>> => {
|
||||||
if (asked_hours <= 0) return { success: false, error: 'INVALID_BANKING_HOURS' };
|
if (asked_hours <= 0) return { success: false, error: 'INVALID_BANKING_HOURS' };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await this.prisma.$transaction(async (tx) => {
|
const result = await this.prisma.$transaction(async (tx) => {
|
||||||
const employee = await this.prisma.employees.findUnique({
|
const employee = await this.prisma.employees.findUnique({
|
||||||
|
|
@ -147,7 +147,7 @@ export class SickLeaveService {
|
||||||
last_updated: new Date(),
|
last_updated: new Date(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return { success: true, data: asked_hours } as Result<number, string>;
|
return { success: true, data: asked_hours } as Result<number, string>;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user