2025-05-06 06:45:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-08-11 06:34:44 +00:00
|
|
|
|
using Kurs.Platform.Extensions;
|
2025-05-06 06:45:49 +00:00
|
|
|
|
using Kurs.Platform.ListForms.DynamicApi;
|
|
|
|
|
|
using Kurs.Platform.Localization;
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
using Volo.Abp;
|
|
|
|
|
|
using Volo.Abp.Application.Dtos;
|
|
|
|
|
|
using Volo.Abp.Data;
|
|
|
|
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
|
|
using Volo.Abp.Domain.Entities;
|
|
|
|
|
|
using Volo.Abp.EventBus.Distributed;
|
|
|
|
|
|
using Volo.Abp.EventBus.Local;
|
|
|
|
|
|
using Volo.Abp.Identity;
|
|
|
|
|
|
using Volo.Abp.TenantManagement;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Kurs.Platform.Tenants;
|
|
|
|
|
|
|
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.Default)]
|
|
|
|
|
|
[Dependency(ReplaceServices = true)]
|
|
|
|
|
|
public class PlatformTenantAppService : TenantAppService, IPlatformTenantAppService
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ITenantRepository tenantRepository;
|
|
|
|
|
|
private readonly IDistributedEventBus distributedEventBus;
|
|
|
|
|
|
private readonly ILocalEventBus localEventBus;
|
|
|
|
|
|
|
|
|
|
|
|
public PlatformTenantAppService(
|
|
|
|
|
|
ITenantRepository tenantRepository,
|
|
|
|
|
|
ITenantManager tenantManager,
|
|
|
|
|
|
IDataSeeder dataSeeder,
|
|
|
|
|
|
IDistributedEventBus distributedEventBus,
|
|
|
|
|
|
ILocalEventBus localEventBus) : base(tenantRepository, tenantManager, dataSeeder, distributedEventBus, localEventBus)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.tenantRepository = tenantRepository;
|
|
|
|
|
|
this.distributedEventBus = distributedEventBus;
|
|
|
|
|
|
this.localEventBus = localEventBus;
|
|
|
|
|
|
|
|
|
|
|
|
LocalizationResource = typeof(PlatformResource);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-24 13:21:19 +00:00
|
|
|
|
public override Task<TenantDto> GetAsync(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.GetAsync(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public async Task<TenantDto> GetByNameAsync(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ObjectMapper.Map<Tenant, TenantDto>(
|
|
|
|
|
|
await TenantRepository.FindByNameAsync(name)
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-06 06:45:49 +00:00
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public override Task<PagedResultDto<TenantDto>> GetListAsync(GetTenantsInput input) => base.GetListAsync(input);
|
|
|
|
|
|
|
|
|
|
|
|
[RemoteService(false)]
|
|
|
|
|
|
public override Task<TenantDto> CreateAsync(TenantCreateDto input) => throw new NotImplementedException();
|
|
|
|
|
|
|
|
|
|
|
|
[RemoteService(false)]
|
|
|
|
|
|
public override Task<TenantDto> UpdateAsync(Guid id, TenantUpdateDto input) => base.UpdateAsync(id, input);
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Update ve Delete ConnectionString: Validation vt varsa değiştireceği zaman uyarı verilmeli
|
|
|
|
|
|
|
2025-08-11 06:34:44 +00:00
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public async Task<CustomTenantDto> GetByNameDetailAsync(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tenant = await TenantRepository.FindByNameAsync(name);
|
|
|
|
|
|
|
|
|
|
|
|
if (tenant == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
//throw new EntityNotFoundException($"Tenant bulunamadı: {name}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<Tenant, CustomTenantDto>(tenant);
|
|
|
|
|
|
dto.IsActive = tenant.GetIsActive();
|
|
|
|
|
|
dto.InstitutionName = tenant.GetInstitutionName();
|
|
|
|
|
|
dto.Founder = tenant.GetFounder();
|
|
|
|
|
|
dto.VknTckn = tenant.GetVknTckn();
|
|
|
|
|
|
dto.TaxOffice = tenant.GetTaxOffice();
|
|
|
|
|
|
dto.Address = tenant.GetAddress();
|
|
|
|
|
|
dto.Address2 = tenant.GetAddress2();
|
|
|
|
|
|
dto.District = tenant.GetDistrict();
|
|
|
|
|
|
dto.Country = tenant.GetCountry();
|
|
|
|
|
|
dto.City = tenant.GetCity();
|
|
|
|
|
|
dto.PostalCode = tenant.GetPostalCode();
|
|
|
|
|
|
dto.Phone = tenant.GetPhone();
|
|
|
|
|
|
dto.Mobile = tenant.GetMobile();
|
|
|
|
|
|
dto.Fax = tenant.GetFax();
|
|
|
|
|
|
dto.Email = tenant.GetEmail();
|
|
|
|
|
|
dto.Website = tenant.GetWebsite();
|
|
|
|
|
|
|
|
|
|
|
|
return dto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-06 06:45:49 +00:00
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.Update)]
|
|
|
|
|
|
public async Task PostSeedTenantDataAsync(CreateUpdateTenantInput input)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tenant = await tenantRepository.FindAsync(input.Id.Value) ?? throw new EntityNotFoundException();
|
|
|
|
|
|
await distributedEventBus.PublishAsync(
|
|
|
|
|
|
new ApplyDatabaseMigrationsEto
|
|
|
|
|
|
{
|
|
|
|
|
|
TenantId = tenant.Id,
|
|
|
|
|
|
DatabaseName = tenant.Name,
|
|
|
|
|
|
Properties =
|
|
|
|
|
|
{
|
|
|
|
|
|
{ IdentityDataSeedContributor.AdminEmailPropertyName, input.AdminEmail },
|
|
|
|
|
|
{ IdentityDataSeedContributor.AdminPasswordPropertyName, input.AdminPassword },
|
|
|
|
|
|
{ IdentityDataSeedContributor.AdminUserNamePropertyName, input.AdminEmail }
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|