mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
fix publication details
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActionLocalRepositoryService } from 'src/app/module/actions/data/repository/action-local-repository.service';
|
||||
import { ActionRemoteRepositoryService } from 'src/app/module/actions/data/repository/action-remote-repository.service';
|
||||
import { z } from "zod";
|
||||
|
||||
export const ActionGetAllOutPutSchema = z.array(z.object({
|
||||
processId: z.number(),
|
||||
applicationId: z.number(),
|
||||
organicEntityId: z.number(),
|
||||
securityId: z.number(),
|
||||
serieId: z.number(),
|
||||
userId: z.number(),
|
||||
dateIndex: z.string().datetime(), // ISO 8601 datetime
|
||||
description: z.string(),
|
||||
detail: z.string(),
|
||||
dateBegin: z.string().datetime(),
|
||||
dateEnd: z.string().datetime(),
|
||||
actionType: z.number(),
|
||||
location: z.string(),
|
||||
isExported: z.boolean(),
|
||||
sourceLocation: z.number(),
|
||||
sourceProcessId: z.number(),
|
||||
}));
|
||||
|
||||
// Example usage:
|
||||
export type ActionGetAllOutPut = z.infer<typeof ActionGetAllOutPutSchema>;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ActionsGetAllUseCaseService {
|
||||
|
||||
constructor(
|
||||
private remote: ActionRemoteRepositoryService,
|
||||
private local: ActionLocalRepositoryService
|
||||
) { }
|
||||
|
||||
async execute() {
|
||||
|
||||
var result = await this.remote.actionGetAll();
|
||||
|
||||
if(result.isOk()) {
|
||||
const data = result.value.data.data;
|
||||
|
||||
this.local.createTransaction( async (table) => {
|
||||
// Clear the table before inserting new data
|
||||
await table.clear();
|
||||
// Insert the new data
|
||||
await table.bulkAdd(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user