2025-08-15 11:26:03 +00:00
|
|
|
import {
|
|
|
|
|
ReportTemplateDto,
|
2025-08-15 11:52:30 +00:00
|
|
|
ReportGeneratedDto,
|
2025-08-15 11:26:03 +00:00
|
|
|
CreateReportTemplateDto,
|
|
|
|
|
UpdateReportTemplateDto,
|
2025-08-15 15:00:09 +00:00
|
|
|
ReportGenerateDto,
|
|
|
|
|
ReportCategoryDto,
|
|
|
|
|
GetReportTemplatesInput, // backend'deki GenerateReportDto (templateId + parameters)
|
2025-08-15 11:26:03 +00:00
|
|
|
} from '@/proxy/reports/models'
|
|
|
|
|
import apiService from './api.service'
|
2025-08-15 08:07:51 +00:00
|
|
|
import { PagedAndSortedResultRequestDto, PagedResultDto } from '@/proxy'
|
|
|
|
|
|
|
|
|
|
export interface ReportsData {
|
|
|
|
|
templates: ReportTemplateDto[]
|
2025-08-15 11:52:30 +00:00
|
|
|
generatedReports: ReportGeneratedDto[]
|
2025-08-15 08:07:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class ReportsService {
|
|
|
|
|
apiName = 'Default'
|
|
|
|
|
|
2025-08-15 15:00:09 +00:00
|
|
|
getCategories = () =>
|
|
|
|
|
apiService.fetchData<ReportCategoryDto[]>(
|
|
|
|
|
{
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '/api/app/report/categories',
|
|
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-15 11:26:03 +00:00
|
|
|
// TEMPLATES
|
2025-08-15 15:00:09 +00:00
|
|
|
getTemplates = (input: GetReportTemplatesInput) =>
|
2025-08-15 08:07:51 +00:00
|
|
|
apiService.fetchData<PagedResultDto<ReportTemplateDto>, PagedAndSortedResultRequestDto>(
|
|
|
|
|
{
|
|
|
|
|
method: 'GET',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: '/api/app/report/templates', // ✔ Swagger: GET /api/app/report/templates
|
2025-08-15 08:07:51 +00:00
|
|
|
params: {
|
|
|
|
|
sorting: input.sorting,
|
|
|
|
|
skipCount: input.skipCount,
|
|
|
|
|
maxResultCount: input.maxResultCount,
|
2025-08-15 19:39:11 +00:00
|
|
|
filter: input.filter,
|
2025-10-08 11:31:29 +00:00
|
|
|
categoryId: input.categoryId,
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
getTemplateById = (id: string) =>
|
|
|
|
|
apiService.fetchData<ReportTemplateDto>(
|
|
|
|
|
{
|
|
|
|
|
method: 'GET',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: `/api/app/report/${id}/template`, // ✔ Swagger: GET /api/app/report/{id}/template
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-15 11:26:03 +00:00
|
|
|
createTemplate = (input: CreateReportTemplateDto) =>
|
|
|
|
|
apiService.fetchData<ReportTemplateDto, CreateReportTemplateDto>(
|
2025-08-15 08:07:51 +00:00
|
|
|
{
|
|
|
|
|
method: 'POST',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: '/api/app/report/template', // ✔ Swagger: POST /api/app/report/template
|
2025-08-15 08:07:51 +00:00
|
|
|
data: input,
|
|
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-15 11:26:03 +00:00
|
|
|
updateTemplate = (id: string, input: UpdateReportTemplateDto) =>
|
|
|
|
|
apiService.fetchData<ReportTemplateDto, UpdateReportTemplateDto>(
|
2025-08-15 08:07:51 +00:00
|
|
|
{
|
|
|
|
|
method: 'PUT',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: `/api/app/report/${id}/template`, // ✔ Swagger: PUT /api/app/report/{id}/template
|
|
|
|
|
data: input,
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
deleteTemplate = (id: string) =>
|
|
|
|
|
apiService.fetchData(
|
|
|
|
|
{
|
|
|
|
|
method: 'DELETE',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: `/api/app/report/${id}/template`, // ✔ Swagger: DELETE /api/app/report/{id}/template
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-15 11:26:03 +00:00
|
|
|
// GENERATED REPORTS
|
2025-08-15 08:07:51 +00:00
|
|
|
getGeneratedReports = (input: PagedAndSortedResultRequestDto) =>
|
2025-08-15 11:52:30 +00:00
|
|
|
apiService.fetchData<PagedResultDto<ReportGeneratedDto>, PagedAndSortedResultRequestDto>(
|
2025-08-15 08:07:51 +00:00
|
|
|
{
|
|
|
|
|
method: 'GET',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: '/api/app/report/generated-reports', // ✔ Swagger: GET /api/app/report/generated-reports
|
2025-08-15 08:07:51 +00:00
|
|
|
params: {
|
|
|
|
|
sorting: input.sorting,
|
|
|
|
|
skipCount: input.skipCount,
|
|
|
|
|
maxResultCount: input.maxResultCount,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
getGeneratedReportById = (id: string) =>
|
2025-08-15 11:52:30 +00:00
|
|
|
apiService.fetchData<ReportGeneratedDto>(
|
2025-08-15 08:07:51 +00:00
|
|
|
{
|
|
|
|
|
method: 'GET',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: `/api/app/report/${id}/generated-report`, // ✔ Swagger: GET /api/app/report/{id}/generated-report
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-15 11:52:30 +00:00
|
|
|
generateReport = (input: ReportGenerateDto) =>
|
|
|
|
|
apiService.fetchData<ReportGeneratedDto, ReportGenerateDto>(
|
2025-08-15 08:07:51 +00:00
|
|
|
{
|
|
|
|
|
method: 'POST',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: '/api/app/report/generate-report', // ✔ Swagger: POST /api/app/report/generate-report
|
|
|
|
|
data: input,
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
deleteGeneratedReport = (id: string) =>
|
|
|
|
|
apiService.fetchData(
|
|
|
|
|
{
|
|
|
|
|
method: 'DELETE',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: `/api/app/report/${id}/generated-report`, // ✔ Swagger: DELETE /api/app/report/{id}/generated-report
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-15 11:26:03 +00:00
|
|
|
// BULK
|
2025-08-15 08:07:51 +00:00
|
|
|
getAllData = () =>
|
|
|
|
|
apiService.fetchData<ReportsData>(
|
|
|
|
|
{
|
|
|
|
|
method: 'GET',
|
2025-08-15 11:26:03 +00:00
|
|
|
url: '/api/app/report/data', // ✔ Swagger: GET /api/app/report/data
|
2025-08-15 08:07:51 +00:00
|
|
|
},
|
|
|
|
|
{ apiName: this.apiName },
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ReportsService
|