mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { ActionsCreateInput } from 'src/app/core/actions/use-case/actions-create-use-case.service';
|
|
import { ActionGetAllOutPut } from 'src/app/core/actions/use-case/actions-get-all-use-case.service';
|
|
import { ActionsUpdateInput } from 'src/app/core/actions/use-case/actions-update-use-case.service';
|
|
import { PublicationGetDocumentByProcessIdOutPut } from 'src/app/core/actions/use-case/publication-get-documents-by-document-id.service';
|
|
import { PublicationListByProcessIdOutPut } from 'src/app/core/actions/use-case/publication-list-by-process-id.service';
|
|
import { HttpService } from 'src/app/infra/http/http.service';
|
|
import { ApiResponse } from 'src/app/infra/http/type';
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ActionRemoteRepositoryService {
|
|
|
|
private baseUrl = `${environment.apiURLStage.slice(0, -1)}/PresidentialActions`; // Your base URL
|
|
|
|
constructor(
|
|
private http: HttpService
|
|
) { }
|
|
|
|
async actionGetAll() {
|
|
return await this.http.get<ApiResponse<ActionGetAllOutPut>>(`${this.baseUrl}`);
|
|
}
|
|
|
|
async create(input: ActionsCreateInput) {
|
|
return await this.http.post<ApiResponse<any>>(`${this.baseUrl}`, input);
|
|
}
|
|
|
|
async update(input: ActionsUpdateInput) {
|
|
return await this.http.put<ApiResponse<any>>(`${this.baseUrl}/${input.processId}`, input);
|
|
}
|
|
|
|
async postGetListByProcessId(processId: string) {
|
|
return await this.http.get<ApiResponse<PublicationListByProcessIdOutPut>>(`${this.baseUrl}/${processId}/Posts`);
|
|
}
|
|
|
|
async postGetDocumentListByProcessId(documentId: number) {
|
|
var result = await this.http.get<ApiResponse<PublicationGetDocumentByProcessIdOutPut>>(`${this.baseUrl}/Posts/${documentId}/file`);
|
|
|
|
return result.map((e) => {
|
|
// Add a new attribute to each item
|
|
e.data.data = e.data.data.map((item) => ({
|
|
...item,
|
|
documentId,
|
|
}));
|
|
return e;
|
|
});
|
|
}
|
|
|
|
}
|