feat(services): Hinzufügen des EnvelopeService zur Verarbeitung von API-Anfragen
This commit is contained in:
parent
b8b09ded5d
commit
3692aa80a4
@ -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)
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user