add endpoint to get document drafts

This commit is contained in:
Peter Maquiran
2024-09-11 16:04:43 +01:00
parent 899b3ec3c0
commit f3e09cadf2
222 changed files with 799 additions and 8 deletions
+9
View File
@@ -0,0 +1,9 @@
import { NgModule, LOCALE_ID } from '@angular/core';
@NgModule({
imports: [],
declarations: [],
schemas: [],
providers: []
})
export class AgendaModule {}
@@ -9,6 +9,7 @@ import { AttendeesRemoveInputDTO } from '../dto/attendeeRemoveInputDTO';
import { EventListOutputDTO } from '../dto/eventListDTOOutput';
import { HttpService } from 'src/app/services/http.service';
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
import { IGetDraftListByProcessIdOutput, IGetDraftListByProcessIdSchema } from '../../domain/usecase/getDraft-list-by-process-id.service';
@Injectable({
providedIn: 'root'
@@ -130,4 +131,8 @@ export class AgendaDataService {
async getSharedCalendar() {
return await this.httpService.get<SharedCalendarListOutputDTO>(`${this.baseUrl}/Users/${SessionStore.user.UserId}/ShareCalendar`);
}
async getDraftListByProcessId(input: IGetDraftListByProcessIdSchema) {
return await this.httpService.get<IGetDraftListByProcessIdOutput>(`${this.baseUrl}/Contents/FolderId/${input.processId}`);
}
}
@@ -0,0 +1,16 @@
import { Injectable } from '@angular/core';
import { GetDraftListByProcessIdService, IGetDraftListByProcessIdSchema } from './usecase/getDraft-list-by-process-id.service';
@Injectable({
providedIn: 'root'
})
export class AgendaService {
constructor(
private getDraftListByProcessIdService: GetDraftListByProcessIdService
) { }
getDraftListByProcessId(input: IGetDraftListByProcessIdSchema) {
return this.getDraftListByProcessIdService.execute(input)
}
}
@@ -0,0 +1,60 @@
import { Injectable } from '@angular/core';
import { z } from 'zod';
import { AgendaDataService } from '../../data/data-source/agenda-data.service';
export const GetDraftListByProcessIdSchema = z.object({
processId: z.number()
});
export type IGetDraftListByProcessIdSchema = z.infer<typeof GetDraftListByProcessIdSchema>
//=======================================
const UserSchema = z.object({
wxUserId: z.number(),
createdAt: z.string(),
});
const VersionSchema = z.object({
versionID: z.number(),
versionNumber: z.number(),
createdBy: z.number(),
editDuration: z.number(),
content: z.string(),
createdDate: z.string(),
updatedDate: z.string(),
});
export const GetDraftListByProcessIdOutputSchema = z.object({
success: z.boolean(),
message: z.string().nullable(),
data: z.array(z.object({
id: z.number(),
description: z.string(),
path: z.string(),
nnc: z.string().nullable(),
status: z.boolean(),
content: z.string(),
wxDoctypeId: z.string().nullable(),
ownerId: z.number(),
createdAt: z.string(),
updatedAt: z.string(),
serialNumber: z.string().nullable(),
folderId: z.number(),
users: z.array(UserSchema),
version: z.array(VersionSchema),
})),
});
export type IGetDraftListByProcessIdOutput = z.infer<typeof GetDraftListByProcessIdOutputSchema>
@Injectable({
providedIn: 'root'
})
export class GetDraftListByProcessIdService {
constructor(
private agendaDataService: AgendaDataService
) { }
async execute(input: IGetDraftListByProcessIdSchema) {
return await this.agendaDataService.getDraftListByProcessId(input)
}
}
@@ -28,7 +28,7 @@ import { fromEvent, merge, interval, Subscription } from 'rxjs';
import { takeUntil, filter, switchMap, take } from 'rxjs/operators';
import { DespachosOptionsPage } from 'src/app/shared/popover/despachos-options/despachos-options.page';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { AgendaService } from 'src/app/module/agenda/domain/agenda.service'
@Component({
selector: 'app-despacho',
templateUrl: './despacho.page.html',
@@ -78,7 +78,8 @@ export class DespachoPage implements OnInit {
private httpErrorHandle: HttpErrorHandle,
public TaskService: TaskService,
public DeviceService: DeviceService,
private DocumentViewerOptionService: DocumentViewerOptionService
private DocumentViewerOptionService: DocumentViewerOptionService,
private agendaService: AgendaService
) {
@@ -158,6 +159,8 @@ export class DespachoPage implements OnInit {
"DraftIds": res.workflowInstanceDataFields?.DraftIds
}
// console.log({res})
// this.updateProcessOnDB(res);
@@ -196,7 +199,35 @@ export class DespachoPage implements OnInit {
}
});
}
// getDocumentPdf({FolderID}) {
// this.agendaService.getDraftListByProcessId({
// processId: FolderID
// }).then(( draftList => {
// if(draftList.isOk()) {
// const docObject = draftList.value.data.map((e) => ({
// "ApplicationId": "",
// "Assunto": e.description,
// "DocDate": e.createdAt,
// "DocId": "",
// "DocNumber": "element.DocNumber",
// "FolderId": e.folderId,
// "Sender": "uuid",
// "SourceDocId": "element.SourceDocId",
// "content": "",
// "path": "",
// "ownerId": "",
// "status": "",
// }))
// this.mergedArray.push(docObject);
// }
// }));
// }
getDocumentPdf(Documents: any) {
Documents.forEach(element => {
let docObject = {
"ApplicationId": element.ApplicationId,