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 _log; private readonly IServiceProvider _provider; private readonly IUnitOfWork _unitOfWork; private readonly IMapper _mapper; public ApiDbService(ILogger logger, IServiceProvider provider, IUnitOfWork unitOfWork, IMapper mapper) { _log = logger; _provider = provider; _unitOfWork = unitOfWork; _mapper = mapper; _log.LogError("ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo: ApiDbService"); } public async Task ReloadDatabase() { try { //AipFileApiService? aipFileApiService = ContainerService.provider.GetService(); AipFileApiService? aipFileApiService = _provider.GetService(); 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> GetLinkedSystems() { try { var result = await _unitOfWork.LinkedSystemRepository.GetAllAsync(); return _mapper.Map>(result); } catch (Exception) { throw; } } public async Task> GetLinkedServers() { try { var result = await _unitOfWork.LinkedServerRepository.GetAllAsync(); return _mapper.Map>(result); } catch (Exception) { throw; } } public async Task> GetLinkedApiKeys() { try { var result = await _unitOfWork.LinkedApiKeyRepository.GetAllAsync(); return _mapper.Map>(result); } catch (Exception) { throw; } } public async Task> GetLinkedDecryptKeys() { try { var result = await _unitOfWork.LinkedDecryptKeyRepository.GetAllAsync(); return _mapper.Map>(result); } catch (Exception) { throw; } } } }