Tenant Seed düzenlemesi
This commit is contained in:
parent
8c8e214e78
commit
d9f021c0f1
42 changed files with 392 additions and 266 deletions
|
|
@ -1,93 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Blog;
|
||||
|
||||
public class BlogPostDto : FullAuditedEntityDto<Guid>
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
|
||||
public Guid CategoryId { get; set; }
|
||||
public BlogCategoryDto Category { get; set; }
|
||||
|
||||
public AuthorDto Author { get; set; }
|
||||
|
||||
public int ViewCount { get; set; }
|
||||
public int LikeCount { get; set; }
|
||||
public int CommentCount { get; set; }
|
||||
|
||||
public bool IsPublished { get; set; }
|
||||
public DateTime? PublishedAt { get; set; }
|
||||
|
||||
public List<string> Tags { get; set; }
|
||||
public bool IsLiked { get; set; }
|
||||
|
||||
public BlogPostDto()
|
||||
{
|
||||
Tags = [];
|
||||
}
|
||||
}
|
||||
|
||||
public class AuthorDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
}
|
||||
|
||||
public class CreateUpdateBlogPostDto
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string ReadTime { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public Guid CategoryId { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
public bool IsPublished { get; set; }
|
||||
|
||||
public CreateUpdateBlogPostDto()
|
||||
{
|
||||
Tags = [];
|
||||
}
|
||||
}
|
||||
|
||||
public class BlogPostListDto : EntityDto<Guid>
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string ReadTime { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
|
||||
public BlogCategoryDto Category { get; set; }
|
||||
public AuthorDto Author { get; set; }
|
||||
|
||||
public int ViewCount { get; set; }
|
||||
public int LikeCount { get; set; }
|
||||
public int CommentCount { get; set; }
|
||||
|
||||
public bool IsPublished { get; set; }
|
||||
public DateTime? PublishedAt { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
public BlogPostListDto()
|
||||
{
|
||||
Tags = [];
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ using System.Text.Json;
|
|||
using System.Text.Json.Serialization;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Abouts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class AboutDto : EntityDto<Guid>
|
||||
{
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class AuthorDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Blog;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class BlogCategoryDto : FullAuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -15,13 +15,4 @@ public class BlogCategoryDto : FullAuditedEntityDto<Guid>
|
|||
public int PostCount { get; set; }
|
||||
}
|
||||
|
||||
public class CreateUpdateBlogCategoryDto
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public int DisplayOrder { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Blog;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class BlogPostAndCategoriesDto
|
||||
{
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class BlogPostDto : FullAuditedEntityDto<Guid>
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
|
||||
public Guid CategoryId { get; set; }
|
||||
public BlogCategoryDto Category { get; set; }
|
||||
|
||||
public AuthorDto Author { get; set; }
|
||||
|
||||
public int ViewCount { get; set; }
|
||||
public int LikeCount { get; set; }
|
||||
public int CommentCount { get; set; }
|
||||
|
||||
public bool IsPublished { get; set; }
|
||||
public DateTime? PublishedAt { get; set; }
|
||||
|
||||
public List<string> Tags { get; set; }
|
||||
public bool IsLiked { get; set; }
|
||||
|
||||
public BlogPostDto()
|
||||
{
|
||||
Tags = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class BlogPostListDto : EntityDto<Guid>
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string ReadTime { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
|
||||
public BlogCategoryDto Category { get; set; }
|
||||
public AuthorDto Author { get; set; }
|
||||
|
||||
public int ViewCount { get; set; }
|
||||
public int LikeCount { get; set; }
|
||||
public int CommentCount { get; set; }
|
||||
|
||||
public bool IsPublished { get; set; }
|
||||
public DateTime? PublishedAt { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
public BlogPostListDto()
|
||||
{
|
||||
Tags = [];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Contacts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class CityDto : AuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -3,7 +3,7 @@ using System.Text.Json;
|
|||
using System.Text.Json.Serialization;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Contacts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class ContactDto : EntityDto<Guid>
|
||||
{
|
||||
|
|
@ -52,30 +52,3 @@ public class ContactDto : EntityDto<Guid>
|
|||
set { MapJson = JsonSerializer.Serialize(value); }
|
||||
}
|
||||
}
|
||||
|
||||
public class BankDto
|
||||
{
|
||||
public string AccountHolder { get; set; }
|
||||
public string Branch { get; set; }
|
||||
public string AccountNumber { get; set; }
|
||||
public string Iban { get; set; }
|
||||
}
|
||||
|
||||
public class WorkHoursDto
|
||||
{
|
||||
public string Weekday { get; set; }
|
||||
public string Weekend { get; set; }
|
||||
public string Whatsapp { get; set; }
|
||||
}
|
||||
|
||||
public class MapDto
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Src { get; set; }
|
||||
public string Width { get; set; }
|
||||
public string Height { get; set; }
|
||||
public string Style { get; set; }
|
||||
public bool? AllowFullScreen { get; set; }
|
||||
public string Loading { get; set; }
|
||||
public string ReferrerPolicy { get; set; }
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Contacts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class ContactTagDto : AuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Contacts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class ContactTitleDto : AuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Contacts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class CountryDto : AuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Contacts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class CountryGroupDto : AuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class CreateUpdateBlogCategoryDto
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public int DisplayOrder { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class CreateUpdateBlogPostDto
|
||||
{
|
||||
public Guid? TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string ContentTr { get; set; }
|
||||
public string ContentEn { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string ReadTime { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public Guid CategoryId { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
public bool IsPublished { get; set; }
|
||||
|
||||
public CreateUpdateBlogPostDto()
|
||||
{
|
||||
Tags = [];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Contacts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class DistrictDto : AuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
|||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace Kurs.Platform.Blog;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public interface IBlogAppService : IApplicationService
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Orders;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class InstallmentOptionDto : EntityDto<Guid>
|
||||
{
|
||||
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using Kurs.Platform.Tenants;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Orders;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class OrderDto : EntityDto<Guid>
|
||||
{
|
||||
|
|
@ -21,11 +21,3 @@ public class OrderDto : EntityDto<Guid>
|
|||
public Dictionary<string, object> PaymentData { get; set; }
|
||||
}
|
||||
|
||||
public class OrderItemDto
|
||||
{
|
||||
public Guid ProductId { get; set; }
|
||||
public ProductDto Product { get; set; }
|
||||
public string BillingCycle { get; set; } // monthly | yearly
|
||||
public int Quantity { get; set; }
|
||||
public decimal TotalPrice { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class OrderItemDto
|
||||
{
|
||||
public Guid ProductId { get; set; }
|
||||
public ProductDto Product { get; set; }
|
||||
public string BillingCycle { get; set; } // monthly | yearly
|
||||
public int Quantity { get; set; }
|
||||
public decimal TotalPrice { get; set; }
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Orders;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class PaymentMethodDto : EntityDto<Guid>
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Orders;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class ProductDto : EntityDto<Guid>
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Kurs.Platform.Services;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class ServiceDto : FullAuditedEntityDto<Guid>
|
||||
{
|
||||
|
|
@ -7,7 +7,7 @@ using Microsoft.Extensions.Localization;
|
|||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Users;
|
||||
|
||||
namespace Kurs.Platform.Blog;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
[Authorize]
|
||||
public class BlogAppService : PlatformAppService, IBlogAppService
|
||||
|
|
|
|||
|
|
@ -2,21 +2,16 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Services;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using System.Text;
|
||||
using Kurs.Platform.Data.Seeds;
|
||||
using Kurs.Sender.Mail;
|
||||
using Volo.Abp.Settings;
|
||||
using Kurs.Platform.Demos;
|
||||
using Kurs.Platform.Blog;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using System.Linq;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Kurs.Platform.Orders;
|
||||
using System.Text.Json;
|
||||
using Kurs.Platform.Abouts;
|
||||
using Kurs.Platform.Contacts;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
using AutoMapper;
|
||||
using Kurs.Platform.Abouts;
|
||||
using Kurs.Platform.Blog;
|
||||
using Kurs.Platform.Contacts;
|
||||
using Kurs.Platform.Demos;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Orders;
|
||||
using Kurs.Platform.Services;
|
||||
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,19 +29,6 @@
|
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Remove="Seeds\TenantData.json" />
|
||||
<Content Include="Seeds\TenantData.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Seeds\TenantData.Dev.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Seeds\TenantData.Production.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Remove="Seeds\HostData.json" />
|
||||
<Content Include="Seeds\HostData.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using Volo.Abp.PermissionManagement;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using EFCore.BulkExtensions;
|
||||
using System.Collections.Generic;
|
||||
using Kurs.Platform.Contacts;
|
||||
using Kurs.Platform.Public;
|
||||
using static Kurs.Settings.SettingsConsts;
|
||||
|
||||
namespace Kurs.Platform.Data.Seeds;
|
||||
|
|
|
|||
9
api/src/Kurs.Platform.Domain.Shared/Public/BankDto.cs
Normal file
9
api/src/Kurs.Platform.Domain.Shared/Public/BankDto.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class BankDto
|
||||
{
|
||||
public string AccountHolder { get; set; }
|
||||
public string Branch { get; set; }
|
||||
public string AccountNumber { get; set; }
|
||||
public string Iban { get; set; }
|
||||
}
|
||||
13
api/src/Kurs.Platform.Domain.Shared/Public/MapDto.cs
Normal file
13
api/src/Kurs.Platform.Domain.Shared/Public/MapDto.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class MapDto
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Src { get; set; }
|
||||
public string Width { get; set; }
|
||||
public string Height { get; set; }
|
||||
public string Style { get; set; }
|
||||
public bool? AllowFullScreen { get; set; }
|
||||
public string Loading { get; set; }
|
||||
public string ReferrerPolicy { get; set; }
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace Kurs.Platform.Abouts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class SectionDto
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace Kurs.Platform.Abouts;
|
||||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class StatDto
|
||||
{
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
namespace Kurs.Platform.Public;
|
||||
|
||||
public class WorkHoursDto
|
||||
{
|
||||
public string Weekday { get; set; }
|
||||
public string Weekend { get; set; }
|
||||
public string Whatsapp { get; set; }
|
||||
}
|
||||
|
|
@ -21,8 +21,6 @@ using Volo.Abp.MultiTenancy;
|
|||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
using Volo.Abp.Uow;
|
||||
using IdentityRole = Volo.Abp.Identity.IdentityRole;
|
||||
using IdentityUser = Volo.Abp.Identity.IdentityUser;
|
||||
using static Kurs.Settings.SettingsConsts;
|
||||
|
||||
namespace Kurs.Platform.Migrations;
|
||||
|
|
@ -90,17 +88,19 @@ public class DatabaseMigrationEventHandler :
|
|||
|
||||
public async Task HandleEventAsync(ApplyDatabaseMigrationsEto eventData)
|
||||
{
|
||||
var schemaMigrated = false;
|
||||
try
|
||||
{
|
||||
schemaMigrated = await MigrateDatabaseSchemaAsync(eventData.TenantId);
|
||||
var schemaMigrated = await MigrateDatabaseSchemaAsync(eventData.TenantId);
|
||||
if (schemaMigrated)
|
||||
{
|
||||
await SeedTenantDataAsync(eventData);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error while seeding tenant data");
|
||||
throw;
|
||||
|
||||
//await HandleErrorOnApplyDatabaseMigrationAsync(eventData, ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -189,80 +189,80 @@ public class DatabaseMigrationEventHandler :
|
|||
{
|
||||
using (CurrentTenant.Change(eventData.TenantId))
|
||||
{
|
||||
// await DataSeeder.SeedAsync(
|
||||
// new DataSeedContext(eventData.TenantId)
|
||||
// .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName])
|
||||
// .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName])
|
||||
// .WithProperty(IdentityDataSeedContributor.AdminUserNamePropertyName, eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName])
|
||||
// );
|
||||
|
||||
await IdentityOptions.SetAsync();
|
||||
|
||||
var result = new IdentityDataSeedResult();
|
||||
var adminEmail = eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName];
|
||||
var adminPassword = eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName];
|
||||
var adminUserName = eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName];
|
||||
var adminUser = await UserRepository.FindByNormalizedUserNameAsync(
|
||||
LookupNormalizer.NormalizeName(adminUserName)
|
||||
await DataSeeder.SeedAsync(
|
||||
new DataSeedContext(eventData.TenantId)
|
||||
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName])
|
||||
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName])
|
||||
.WithProperty(IdentityDataSeedContributor.AdminUserNamePropertyName, eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName])
|
||||
);
|
||||
|
||||
adminUser = new IdentityUser(
|
||||
GuidGenerator.Create(),
|
||||
adminUserName,
|
||||
adminUserName,
|
||||
eventData.TenantId
|
||||
)
|
||||
{
|
||||
Name = PlatformConsts.AbpIdentity.User.AdminNameDefaultValue,
|
||||
Surname = PlatformConsts.AbpIdentity.User.AdminSurNameDefaultValue,
|
||||
};
|
||||
adminUser.SetEmailConfirmed(true);
|
||||
adminUser.SetIsVerified(true);
|
||||
adminUser.SetPhoneNumber(PlatformConsts.AbpIdentity.User.AdminPhoneNumberDefaultValue, true);
|
||||
// await IdentityOptions.SetAsync();
|
||||
|
||||
(await UserManager.CreateAsync(adminUser, adminPassword, validatePassword: false)).CheckErrors();
|
||||
result.CreatedAdminUser = true;
|
||||
var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName));
|
||||
if (adminRole is null)
|
||||
{
|
||||
adminRole = new IdentityRole(
|
||||
GuidGenerator.Create(),
|
||||
PlatformConsts.AbpIdentity.User.AdminRoleName,
|
||||
eventData.TenantId
|
||||
)
|
||||
{
|
||||
IsStatic = true,
|
||||
IsPublic = true
|
||||
};
|
||||
// var result = new IdentityDataSeedResult();
|
||||
// var adminEmail = eventData.Properties[IdentityDataSeedContributor.AdminEmailPropertyName];
|
||||
// var adminPassword = eventData.Properties[IdentityDataSeedContributor.AdminPasswordPropertyName];
|
||||
// var adminUserName = eventData.Properties[IdentityDataSeedContributor.AdminUserNamePropertyName];
|
||||
// var adminUser = await UserRepository.FindByNormalizedUserNameAsync(
|
||||
// LookupNormalizer.NormalizeName(adminUserName)
|
||||
// );
|
||||
|
||||
(await RoleManager.CreateAsync(adminRole)).CheckErrors();
|
||||
result.CreatedAdminRole = true;
|
||||
}
|
||||
// adminUser = new IdentityUser(
|
||||
// GuidGenerator.Create(),
|
||||
// adminUserName,
|
||||
// adminUserName,
|
||||
// eventData.TenantId
|
||||
// )
|
||||
// {
|
||||
// Name = PlatformConsts.AbpIdentity.User.AdminNameDefaultValue,
|
||||
// Surname = PlatformConsts.AbpIdentity.User.AdminSurNameDefaultValue,
|
||||
// };
|
||||
// adminUser.SetEmailConfirmed(true);
|
||||
// adminUser.SetIsVerified(true);
|
||||
// adminUser.SetPhoneNumber(PlatformConsts.AbpIdentity.User.AdminPhoneNumberDefaultValue, true);
|
||||
|
||||
(await UserManager.AddToRoleAsync(adminUser, adminRole.Name)).CheckErrors();
|
||||
// (await UserManager.CreateAsync(adminUser, adminPassword, validatePassword: false)).CheckErrors();
|
||||
// result.CreatedAdminUser = true;
|
||||
// var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName));
|
||||
// if (adminRole is null)
|
||||
// {
|
||||
// adminRole = new IdentityRole(
|
||||
// GuidGenerator.Create(),
|
||||
// PlatformConsts.AbpIdentity.User.AdminRoleName,
|
||||
// eventData.TenantId
|
||||
// )
|
||||
// {
|
||||
// IsStatic = true,
|
||||
// IsPublic = true
|
||||
// };
|
||||
|
||||
/*admin rolüne ait yetkiler otomatik atanıyor*/
|
||||
var permissions = await PermissionGrantRepository.GetListAsync("R", PlatformConsts.AbpIdentity.User.AdminRoleName);
|
||||
if (permissions.Count == 0)
|
||||
{
|
||||
await PermissionGrantRepository.InsertManyAsync(
|
||||
[
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManageRoles, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.UserLookup.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
]);
|
||||
}
|
||||
// (await RoleManager.CreateAsync(adminRole)).CheckErrors();
|
||||
// result.CreatedAdminRole = true;
|
||||
// }
|
||||
|
||||
// (await UserManager.AddToRoleAsync(adminUser, adminRole.Name)).CheckErrors();
|
||||
|
||||
// /*admin rolüne ait yetkiler otomatik atanıyor*/
|
||||
// var permissions = await PermissionGrantRepository.GetListAsync("R", PlatformConsts.AbpIdentity.User.AdminRoleName);
|
||||
// if (permissions.Count == 0)
|
||||
// {
|
||||
// await PermissionGrantRepository.InsertManyAsync(
|
||||
// [
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Roles.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Create, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Delete, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Update, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManagePermissions, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.Default + ".Export", "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.Users.ManageRoles, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// new(Guid.NewGuid(), PlatformConsts.IdentityPermissions.UserLookup.Default, "R", PlatformConsts.AbpIdentity.User.AdminRoleName, eventData.TenantId),
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,22 @@
|
|||
<RootNamespace>Kurs.Platform</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Tenants\Seeds\TenantData.json" />
|
||||
<Content Include="Tenants\Seeds\TenantData.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Tenants\Seeds\TenantData.Dev.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Tenants\Seeds\TenantData.Production.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="9.0.1" />
|
||||
<ProjectReference Include="..\..\modules\Kurs.Languages\Kurs.Languages.EntityFrameworkCore\Kurs.Languages.EntityFrameworkCore.csproj" />
|
||||
|
|
|
|||
|
|
@ -144,11 +144,15 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency
|
|||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
var assemblyLocation = Path.GetDirectoryName(typeof(TenantDataSeeder).Assembly.Location)!;
|
||||
var basePath = Path.Combine(assemblyLocation, "Tenants", "Seeds");
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(Path.Combine("Seeds", "TenantData.json"))
|
||||
.AddJsonFile(Path.Combine("Seeds", $"TenantData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json"), true)
|
||||
.SetBasePath(basePath)
|
||||
.AddJsonFile("TenantData.json", optional: false, reloadOnChange: false)
|
||||
.AddJsonFile($"TenantData.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? ""}.json", optional: true)
|
||||
.Build();
|
||||
|
||||
var items = configuration.Get<TenantSeederDto>();
|
||||
|
||||
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Kurs.Platform.Extensions;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Guids;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using IdentityRole = Volo.Abp.Identity.IdentityRole;
|
||||
using IdentityUser = Volo.Abp.Identity.IdentityUser;
|
||||
|
||||
namespace Kurs.Platform.Data.Seeds;
|
||||
|
||||
[Dependency(ReplaceServices = true)]
|
||||
public class TenantIdentityDataSeeder : IdentityDataSeeder
|
||||
{
|
||||
private readonly IPermissionGrantRepository permissionGrantRepository;
|
||||
|
||||
public TenantIdentityDataSeeder(
|
||||
IGuidGenerator guidGenerator,
|
||||
IIdentityRoleRepository roleRepository,
|
||||
IIdentityUserRepository userRepository,
|
||||
ILookupNormalizer lookupNormalizer,
|
||||
IdentityUserManager userManager,
|
||||
IdentityRoleManager roleManager,
|
||||
IPermissionGrantRepository permissionGrantRepository,
|
||||
ICurrentTenant currentTenant,
|
||||
IOptions<IdentityOptions> identityOptions
|
||||
) : base(guidGenerator, roleRepository, userRepository, lookupNormalizer, userManager, roleManager, currentTenant, identityOptions)
|
||||
{
|
||||
this.permissionGrantRepository = permissionGrantRepository;
|
||||
}
|
||||
|
||||
public override async Task<IdentityDataSeedResult> SeedAsync(string adminEmail, string adminPassword, Guid? tenantId = null, string adminUserName = null)
|
||||
{
|
||||
Check.NotNullOrWhiteSpace(adminEmail, nameof(adminEmail));
|
||||
Check.NotNullOrWhiteSpace(adminPassword, nameof(adminPassword));
|
||||
|
||||
using (CurrentTenant.Change(tenantId))
|
||||
{
|
||||
await IdentityOptions.SetAsync();
|
||||
|
||||
var result = new IdentityDataSeedResult();
|
||||
|
||||
var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName));
|
||||
if (adminRole is null)
|
||||
{
|
||||
adminRole = new IdentityRole(
|
||||
GuidGenerator.Create(),
|
||||
PlatformConsts.AbpIdentity.User.AdminRoleName,
|
||||
tenantId
|
||||
)
|
||||
{
|
||||
IsStatic = true,
|
||||
IsPublic = true
|
||||
};
|
||||
|
||||
(await RoleManager.CreateAsync(adminRole)).CheckErrors();
|
||||
result.CreatedAdminRole = true;
|
||||
}
|
||||
|
||||
adminUserName ??= PlatformConsts.AbpIdentity.User.AdminEmailDefaultValue;
|
||||
var adminUser = await UserRepository.FindByNormalizedUserNameAsync(
|
||||
LookupNormalizer.NormalizeName(adminUserName)
|
||||
);
|
||||
|
||||
if (adminUser is null)
|
||||
{
|
||||
adminUser = new IdentityUser(
|
||||
GuidGenerator.Create(),
|
||||
adminUserName,
|
||||
adminEmail,
|
||||
tenantId
|
||||
)
|
||||
{
|
||||
Name = PlatformConsts.AbpIdentity.User.AdminNameDefaultValue,
|
||||
Surname = PlatformConsts.AbpIdentity.User.AdminSurNameDefaultValue,
|
||||
};
|
||||
|
||||
adminUser.SetEmailConfirmed(true);
|
||||
adminUser.SetIsVerified(true);
|
||||
adminUser.SetRocketUsername(PlatformConsts.AbpIdentity.User.AdminRocketUsernameDefaultValue);
|
||||
adminUser.SetPhoneNumber(PlatformConsts.AbpIdentity.User.AdminPhoneNumberDefaultValue, true);
|
||||
|
||||
(await UserManager.CreateAsync(adminUser, adminPassword, validatePassword: false)).CheckErrors();
|
||||
result.CreatedAdminUser = true;
|
||||
|
||||
(await UserManager.AddToRoleAsync(adminUser, PlatformConsts.AbpIdentity.User.AdminRoleName)).CheckErrors();
|
||||
}
|
||||
|
||||
// Grant all permission kısmı Abp tarafından otomatik çalıştırılıyor.
|
||||
// Ayrıca bende çalıştırınca hata veriyor.
|
||||
// Hem DbMigrator hem de burada IdentityDataSeeder var.
|
||||
// Aynı Assembly'de birden fazla IdentityDataSeeder olabilir
|
||||
// DbMigrator çalışınca kendi IdentityDataSeeder'ını çalıştırıyor.
|
||||
// Tenant seed edilince bu IdentityDataSeeder çalışıyor.
|
||||
// See: Volo.Abp.PermissionManagement.PermissionDataSeedContributor
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Kurs.Platform.Abouts;
|
||||
using Kurs.Platform.Contacts;
|
||||
using Kurs.Platform.Entities;
|
||||
using Kurs.Platform.Public;
|
||||
|
||||
namespace Kurs.Platform.Seeds;
|
||||
|
||||
Loading…
Reference in a new issue