mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 20:29:17 +00:00
changed find to show services
This commit is contained in:
30
backend/src/services/TicketServices/ShowTicketService.ts
Normal file
30
backend/src/services/TicketServices/ShowTicketService.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import Ticket from "../../models/Ticket";
|
||||
import AppError from "../../errors/AppError";
|
||||
import Contact from "../../models/Contact";
|
||||
import User from "../../models/User";
|
||||
|
||||
const ShowTicketService = async (id: string | number): Promise<Ticket> => {
|
||||
const ticket = await Ticket.findByPk(id, {
|
||||
include: [
|
||||
{
|
||||
model: Contact,
|
||||
as: "contact",
|
||||
attributes: ["id", "name", "number", "profilePicUrl"],
|
||||
include: ["extraInfo"]
|
||||
},
|
||||
{
|
||||
model: User,
|
||||
as: "user",
|
||||
attributes: ["id", "name"]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
if (!ticket) {
|
||||
throw new AppError("No ticket found with this conditions.", 404);
|
||||
}
|
||||
|
||||
return ticket;
|
||||
};
|
||||
|
||||
export default ShowTicketService;
|
||||
Reference in New Issue
Block a user