25 lines
586 B
TypeScript
25 lines
586 B
TypeScript
|
import Whatsapp from "../../models/Whatsapp";
|
||
|
import AppError from "../../errors/AppError";
|
||
|
import Queue from "../../models/Queue";
|
||
|
|
||
|
const ShowWhatsAppService = async (id: string | number): Promise<Whatsapp> => {
|
||
|
const whatsapp = await Whatsapp.findByPk(id, {
|
||
|
include: [
|
||
|
{
|
||
|
model: Queue,
|
||
|
as: "queues",
|
||
|
attributes: ["id", "name", "color", "greetingMessage"]
|
||
|
}
|
||
|
],
|
||
|
order: [["queues", "name", "ASC"]]
|
||
|
});
|
||
|
|
||
|
if (!whatsapp) {
|
||
|
throw new AppError("ERR_NO_WAPP_FOUND", 404);
|
||
|
}
|
||
|
|
||
|
return whatsapp;
|
||
|
};
|
||
|
|
||
|
export default ShowWhatsAppService;
|