2022-01-06 01:26:15 +00:00
|
|
|
import Ticket from "../../models/Ticket";
|
|
|
|
import AppError from "../../errors/AppError";
|
|
|
|
|
2022-10-25 14:16:36 +00:00
|
|
|
import { deleteTicketsByIdCache } from '../../helpers/TicketCache'
|
|
|
|
|
2022-01-06 01:26:15 +00:00
|
|
|
const DeleteTicketService = async (id: string): Promise<Ticket> => {
|
|
|
|
const ticket = await Ticket.findOne({
|
|
|
|
where: { id }
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!ticket) {
|
|
|
|
throw new AppError("ERR_NO_TICKET_FOUND", 404);
|
|
|
|
}
|
|
|
|
|
2022-10-25 14:16:36 +00:00
|
|
|
await ticket.destroy();
|
|
|
|
|
|
|
|
// TEST DEL
|
|
|
|
await deleteTicketsByIdCache(id)
|
|
|
|
//
|
2022-01-06 01:26:15 +00:00
|
|
|
|
|
|
|
return ticket;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DeleteTicketService;
|