123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using AipGateway.API.Application.Modules;
- using AipGateway.API.Domain.Entities;
- using AipGateway.API.Domain.IRepositories.IGenericRepositories;
- using AipGateway.API.Domain.Models;
- using AutoMapper;
- namespace AipGateway.API.Services.impl
- {
- public class ApiDbService : IApiDbService
- {
- private readonly ILogger<ApiFileService> _log;
- private readonly IServiceProvider _provider;
- private readonly IUnitOfWork _unitOfWork;
- private readonly IMapper _mapper;
- public ApiDbService(ILogger<ApiFileService> logger, IServiceProvider provider, IUnitOfWork unitOfWork, IMapper mapper)
- {
- _log = logger;
- _provider = provider;
- _unitOfWork = unitOfWork;
- _mapper = mapper;
- _log.LogError("ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo: ApiDbService");
- }
- public async Task<ApiResponseDto> ReloadDatabase()
- {
- try
- {
- //AipFileApiService? aipFileApiService = ContainerService.provider.GetService<AipFileApiService>();
- AipFileApiService? aipFileApiService = _provider.GetService<AipFileApiService>();
- if (aipFileApiService == null)
- {
- return new ApiResponseDto
- {
- errorCode = 1,
- errorMessage = "AIP File 관리 서비스를 찾을 수 없습니다.",
- effectCount = 0,
- };
- }
- var task = Task.Run(() =>
- {
- aipFileApiService.LoadLinkedApiKeys();
- aipFileApiService.LoadLinkedDecryptKeys();
- return ContainerService.apiKeyMap.Count + ContainerService.decryptKeyMap.Count;
- });
- int result = await task;
- return new ApiResponseDto
- {
- errorCode = 0,
- errorMessage = GlobalConstants.API_RESULT_SUCCESS,
- effectCount = result,
- };
- }
- catch (Exception)
- {
- throw;
- }
- }
- public async Task<List<LinkedSystemDto>> GetLinkedSystems()
- {
- try
- {
- var result = await _unitOfWork.LinkedSystemRepository.GetAllAsync();
- return _mapper.Map<List<LinkedSystemDto>>(result);
- }
- catch (Exception)
- {
- throw;
- }
- }
- public async Task<List<LinkedServerDto>> GetLinkedServers()
- {
- try
- {
- var result = await _unitOfWork.LinkedServerRepository.GetAllAsync();
- return _mapper.Map<List<LinkedServerDto>>(result);
- }
- catch (Exception)
- {
- throw;
- }
- }
- public async Task<List<LinkedApiKeyDto>> GetLinkedApiKeys()
- {
- try
- {
- var result = await _unitOfWork.LinkedApiKeyRepository.GetAllAsync();
- return _mapper.Map<List<LinkedApiKeyDto>>(result);
- }
- catch (Exception)
- {
- throw;
- }
- }
- public async Task<List<LinkedDecryptKeyDto>> GetLinkedDecryptKeys()
- {
- try
- {
- var result = await _unitOfWork.LinkedDecryptKeyRepository.GetAllAsync();
- return _mapper.Map<List<LinkedDecryptKeyDto>>(result);
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|