projeto-hit/backend/src/controllers/ReportController.ts

32 lines
719 B
TypeScript
Raw Normal View History

//relatorio
import { Request, Response } from "express";
import AppError from "../errors/AppError";
import ShowTicketReport from "../services/TicketServices/ShowTicketReport";
type IndexQuery = {
userId: string;
startDate: string;
endDate: string;
};
export const reportUserByDateStartDateEnd = async (req: Request, res: Response): Promise<Response> => {
if (req.user.profile !== "master" && req.user.profile !== "admin") {
throw new AppError("ERR_NO_PERMISSION", 403);
}
const { userId, startDate, endDate } = req.query as IndexQuery
const data_query = await ShowTicketReport(userId, startDate, endDate);
return res.status(200).json(data_query);
};