add new endpoint to save and get draft

This commit is contained in:
Peter Maquiran
2024-09-12 18:57:45 +01:00
parent 38f51bd7e1
commit 82d6a15d5e
10 changed files with 118 additions and 66 deletions
@@ -10,6 +10,7 @@ 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';
import { IDraftSaveByIdInput } from '../../domain/usecase/draft-save-by-id-use-case.service';
@Injectable({
providedIn: 'root'
@@ -135,4 +136,8 @@ export class AgendaDataService {
async getDraftListByProcessId(input: IGetDraftListByProcessIdSchema) {
return await this.httpService.get<IGetDraftListByProcessIdOutput>(`${this.baseUrl}/Contents/FolderId/${input.processId}`);
}
async draftSaveById(input: IDraftSaveByIdInput) {
return await this.httpService.put<IGetDraftListByProcessIdOutput>(`${this.baseUrl}/Contents/${input.id}`, input);
}
}
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { GetDraftListByProcessIdService, IGetDraftListByProcessIdSchema } from './usecase/getDraft-list-by-process-id.service';
import { DraftSaveByIdInputSchema, DraftSaveByIdUseCaseService, IDraftSaveByIdInput } from './usecase/draft-save-by-id-use-case.service';
@Injectable({
providedIn: 'root'
@@ -7,10 +8,15 @@ import { GetDraftListByProcessIdService, IGetDraftListByProcessIdSchema } from '
export class AgendaService {
constructor(
private getDraftListByProcessIdService: GetDraftListByProcessIdService
private getDraftListByProcessIdService: GetDraftListByProcessIdService,
private DraftSaveByIdUseCaseService: DraftSaveByIdUseCaseService
) { }
getDraftListByProcessId(input: IGetDraftListByProcessIdSchema) {
return this.getDraftListByProcessIdService.execute(input)
}
draftSaveById(input: IDraftSaveByIdInput) {
return this.DraftSaveByIdUseCaseService.execute(input)
}
}
@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { AgendaDataService } from '../../data/data-source/agenda-data.service';
import { z } from 'zod';
export const DraftSaveByIdInputSchema = z.object({
description: z.string(),
status: z.boolean(),
content: z.string(),
path: z.string(),
ownerId: z.number(),
id: z.number()
})
export type IDraftSaveByIdInput= z.infer< typeof DraftSaveByIdInputSchema>
@Injectable({
providedIn: 'root'
})
export class DraftSaveByIdUseCaseService {
constructor(
private agendaDataService: AgendaDataService
) { }
async execute(input: IDraftSaveByIdInput) {
return await this.agendaDataService.draftSaveById(input)
}
}