2025-05-06 06:45:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-11-11 19:49:52 +00:00
|
|
|
|
using Erp.Languages.Entities;
|
2025-05-06 06:45:49 +00:00
|
|
|
|
using Volo.Abp;
|
|
|
|
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
|
|
|
|
2025-11-11 19:49:52 +00:00
|
|
|
|
namespace Erp.Languages;
|
2025-05-06 06:45:49 +00:00
|
|
|
|
|
|
|
|
|
|
[IntegrationService]
|
|
|
|
|
|
public class LanguageKeyIntegrationService : ILanguageKeyIntegrationService, ITransientDependency
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IRepository<LanguageKey, Guid> _repository;
|
|
|
|
|
|
|
|
|
|
|
|
public LanguageKeyIntegrationService(IRepository<LanguageKey, Guid> repository)
|
|
|
|
|
|
{
|
|
|
|
|
|
_repository = repository;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task CreateKeysForSettingsAsync(
|
|
|
|
|
|
string NameKey,
|
|
|
|
|
|
string DescriptionKey,
|
|
|
|
|
|
string MainGroupKey,
|
|
|
|
|
|
string SubGroupKey
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
//NameKey
|
|
|
|
|
|
if (!await _repository.AnyAsync(a => a.Key == NameKey && a.ResourceName == LanguagesConsts.AppName))
|
|
|
|
|
|
{
|
|
|
|
|
|
await _repository.InsertAsync(new LanguageKey { Key = NameKey, ResourceName = LanguagesConsts.AppName });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//DescriptionKey
|
|
|
|
|
|
if (!await _repository.AnyAsync(a => a.Key == DescriptionKey && a.ResourceName == LanguagesConsts.AppName))
|
|
|
|
|
|
{
|
|
|
|
|
|
await _repository.InsertAsync(new LanguageKey { Key = DescriptionKey, ResourceName = LanguagesConsts.AppName });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//MainGroupKey
|
|
|
|
|
|
if (!await _repository.AnyAsync(a => a.Key == MainGroupKey && a.ResourceName == LanguagesConsts.AppName))
|
|
|
|
|
|
{
|
|
|
|
|
|
await _repository.InsertAsync(new LanguageKey { Key = MainGroupKey, ResourceName = LanguagesConsts.AppName });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//SubGroupKey
|
|
|
|
|
|
if (!await _repository.AnyAsync(a => a.Key == SubGroupKey && a.ResourceName == LanguagesConsts.AppName))
|
|
|
|
|
|
{
|
|
|
|
|
|
await _repository.InsertAsync(new LanguageKey { Key = SubGroupKey, ResourceName = LanguagesConsts.AppName });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task DeleteKeysForSettingsAsync(
|
|
|
|
|
|
string NameKey,
|
|
|
|
|
|
string DescriptionKey,
|
|
|
|
|
|
string MainGroupKey,
|
|
|
|
|
|
string SubGroupKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
await _repository.DeleteAsync(a => a.Key == NameKey && a.ResourceName == LanguagesConsts.AppName);
|
|
|
|
|
|
await _repository.DeleteAsync(a => a.Key == DescriptionKey && a.ResourceName == LanguagesConsts.AppName);
|
|
|
|
|
|
await _repository.DeleteAsync(a => a.Key == MainGroupKey && a.ResourceName == LanguagesConsts.AppName);
|
|
|
|
|
|
await _repository.DeleteAsync(a => a.Key == SubGroupKey && a.ResourceName == LanguagesConsts.AppName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-11 19:49:52 +00:00
|
|
|
|
|