feat(services): Hinzufügen des EnvelopeService zur Verarbeitung von API-Anfragen

This commit is contained in:
Developer 02 2024-09-05 11:53:22 +02:00
parent b8b09ded5d
commit 3692aa80a4
6 changed files with 47 additions and 6 deletions

View File

@ -6,18 +6,15 @@ using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Application.Resources;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
{
private readonly ILogger _logger;
public EnvelopeService(IEnvelopeRepository repository, IMapper mapper, ILogger<EnvelopeService> logger)
: base(repository, mapper)
{
_logger = logger;
}
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)

View File

@ -1,5 +1,6 @@
import { AfterViewInit, Component, Input, ViewChild, inject, viewChild } from '@angular/core';
import { EnvelopeReceiverService } from '../../../services/envelope-receiver.service';
import { EnvelopeService } from '../../../services/envelope.service';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { ConfigurationService } from '../../../services/configuration.service';
import { DDTable } from "../dd-table/dd-table.component";
@ -60,9 +61,12 @@ export class EnvelopeTableComponent implements AfterViewInit {
private erService: EnvelopeReceiverService = inject(EnvelopeReceiverService);
private envService: EnvelopeService = inject(EnvelopeService);
private config: ConfigurationService = inject(ConfigurationService);
async ngAfterViewInit() {
this.data = await this.erService.getEnvelopeReceiverAsync(this.options);
await this.envService.getEnvelopeAsync().then(console.log)
}
}

View File

@ -27,7 +27,6 @@ export class EnvelopeReceiverService {
return this.http.get<any>(this.url, { params });
}
getEnvelopeReceiverAsync(options?: { min_status?: number; max_status?: number; ignore_status?: number[] }): Promise<any> {
return firstValueFrom(this.getEnvelopeReceiver(options));
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { EnvelopeService } from './envelope.service';
describe('EnvelopeService', () => {
let service: EnvelopeService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(EnvelopeService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,24 @@
import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, firstValueFrom } from 'rxjs';
import { API_URL } from '../tokens/index';
@Injectable({
providedIn: 'root'
})
export class EnvelopeService {
protected url: string;
constructor(private http: HttpClient) {
const api_url = inject(API_URL);
this.url = `${api_url}/envelope`;
}
public getEnvelope(): Observable<any> {
return this.http.get(this.url);
}
public async getEnvelopeAsync(): Promise<any> {
return await firstValueFrom(this.getEnvelope());
}
}

View File

@ -10,7 +10,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
[Authorize]
public class EnvelopeController : ControllerBase
{
private ILogger<EnvelopeController> _logger;
private readonly ILogger<EnvelopeController> _logger;
private readonly IEnvelopeService _envelopeService;
public EnvelopeController(ILogger<EnvelopeController> logger, IEnvelopeService envelopeService)
@ -20,7 +20,8 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
}
[Authorize]
public async Task<IActionResult> GetCurrentAsync(bool current_user)
[HttpGet]
public async Task<IActionResult> GetCurrentAsync()
{
try
{