This commit is contained in:
peter.maquiran
2026-01-19 15:14:30 +01:00
parent 2673f8a17a
commit 2f054bc781
5 changed files with 98 additions and 6 deletions
@@ -0,0 +1,8 @@
import { HttpErrorResponse } from "@angular/common/http";
import { Err, Result } from "neverthrow";
import { HttpResult } from "src/app/infra/http/type";
import { OK } from "zod";
export abstract class ITaskRemoteRepository {
abstract uploadDoc(id: string | number): Promise<Err<HttpResult<unknown>, HttpErrorResponse> | OK<boolean>>
}
+19
View File
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { SignalRService } from 'src/app/infra/socket/signalR/signal-r.service';
import { ISignalRService } from 'src/app/infra/socket/adapter';
import { HttpModule } from 'src/app/infra/http/http.module';
@NgModule({
imports: [HttpModule],
providers: [
{
provide: ISignalRService,
useClass: SignalRService, // or MockDataService
},
],
declarations: [],
schemas: [],
entryComponents: []
})
export class GabineteModule {
constructor() {}
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { TaskRepoService } from './task-repo.service';
describe('TaskRepoService', () => {
let service: TaskRepoService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TaskRepoService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,49 @@
import { Injectable } from '@angular/core';
import { HttpAdapter } from 'src/app/infra/http/adapter';
import { OK } from 'zod';
import { HttpErrorResponse } from '@angular/common/http';
import { Err } from 'neverthrow';
import { HttpResult } from 'src/app/infra/http/type';
import { SessionStore } from 'src/app/store/session.service';
export function instanceIdGenerator() {
const now = new Date();
const prefix = 'DC';
const formattedDate = now.toISOString()
.replace('T', ' ')
.replace('Z', '')
.slice(0, 23); // yyyy-MM-dd HH:mm:ss.SSS
return `${prefix}_${SessionStore.user.Email}_${formattedDate}`;
}
interface UploadDocInputDto {
InstanceId: string;
UserId: string;
Source: string;
FileExtension: string;
FileBase64: string;
OriginalFileName: string;
}
@Injectable({
providedIn: 'root'
})
export class TaskRepoService {
constructor(
private http: HttpAdapter
) { }
async uploadDoc(input: UploadDocInputDto[]): Promise<Err<HttpResult<unknown>, HttpErrorResponse> | OK<boolean>> {
for(const attachment in input) {
var result = await this.http.post('/Tasks/AttachDocImage', attachment);
if(result.isErr()) {
return result;
}
}
return OK(true);
}
}