27 lines
638 B
TypeScript
27 lines
638 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", "id", "ASC"]]
|
|
});
|
|
|
|
// console.log('kkkkkkkkkkkkkkkkkkkk: ', whatsapp)
|
|
|
|
if (!whatsapp) {
|
|
throw new AppError("ERR_NO_WAPP_FOUND", 404);
|
|
}
|
|
|
|
return whatsapp;
|
|
};
|
|
|
|
export default ShowWhatsAppService;
|