2022-01-06 01:26:15 +00:00
|
|
|
import User from "../../models/User";
|
|
|
|
import AppError from "../../errors/AppError";
|
|
|
|
import Queue from "../../models/Queue";
|
|
|
|
|
|
|
|
const ShowUserService = async (id: string | number): Promise<User> => {
|
|
|
|
const user = await User.findByPk(id, {
|
2024-02-01 21:49:06 +00:00
|
|
|
attributes: ["name", "id", "email", "profile", "positionCompany", "tokenVersion"],
|
2022-01-06 01:26:15 +00:00
|
|
|
include: [
|
|
|
|
{ model: Queue, as: "queues", attributes: ["id", "name", "color"] }
|
|
|
|
],
|
|
|
|
order: [ [ { model: Queue, as: "queues"}, 'name', 'asc' ] ]
|
|
|
|
});
|
|
|
|
if (!user) {
|
|
|
|
throw new AppError("ERR_NO_USER_FOUND", 404);
|
|
|
|
}
|
|
|
|
|
|
|
|
return user;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ShowUserService;
|