diff --git a/src/Application/Features/AuditTrails/DTOs/AuditTrailDto.cs b/src/Application/Features/AuditTrails/DTOs/AuditTrailDto.cs index ba230d098..10bb33344 100644 --- a/src/Application/Features/AuditTrails/DTOs/AuditTrailDto.cs +++ b/src/Application/Features/AuditTrails/DTOs/AuditTrailDto.cs @@ -9,7 +9,7 @@ namespace CleanArchitecture.Blazor.Application.Features.AuditTrails.DTOs; [Description("Audit Trails")] public class AuditTrailDto { - [Description("Id")] public string Id { get; set; } = Guid.NewGuid().ToString(); + [Description("Id")] public int Id { get; set; } [Description("User Id")] public string? UserId { get; set; } diff --git a/src/Application/Features/Documents/Commands/Upload/UploadDocumentCommand.cs b/src/Application/Features/Documents/Commands/Upload/UploadDocumentCommand.cs index 5b1b77d23..76193fa4d 100644 --- a/src/Application/Features/Documents/Commands/Upload/UploadDocumentCommand.cs +++ b/src/Application/Features/Documents/Commands/Upload/UploadDocumentCommand.cs @@ -43,8 +43,12 @@ public async Task> Handle(UploadDocumentCommand request, Cancellatio var url = await _uploadService.UploadAsync(uploadRequest); var document = new Document { - Title = fileName, URL = url, Status = JobStatus.Queueing, IsPublic = true, - DocumentType = DocumentType.Image + Title = fileName, + URL = url, + Status = JobStatus.Queueing, + IsPublic = true, + DocumentType = DocumentType.Image, + }; document.AddDomainEvent(new CreatedEvent(document)); list.Add(document); @@ -55,5 +59,6 @@ public async Task> Handle(UploadDocumentCommand request, Cancellatio await _context.Documents.AddRangeAsync(list, cancellationToken); var result = await _context.SaveChangesAsync(cancellationToken); return await Result.SuccessAsync(result); + } } \ No newline at end of file diff --git a/src/Blazor.Server.UI/App.razor b/src/Blazor.Server.UI/App.razor index 5003f3432..b942447d3 100644 --- a/src/Blazor.Server.UI/App.razor +++ b/src/Blazor.Server.UI/App.razor @@ -37,9 +37,8 @@ @code{ - [Inject] - private LayoutService LayoutService { get; set; } + private LayoutService LayoutService { get; set; } = default!; protected override async Task OnInitializedAsync() { diff --git a/src/Blazor.Server.UI/Components/Shared/LoadingScreen.razor b/src/Blazor.Server.UI/Components/Shared/LoadingScreen.razor index ac0516624..c07ceaeba 100644 --- a/src/Blazor.Server.UI/Components/Shared/LoadingScreen.razor +++ b/src/Blazor.Server.UI/Components/Shared/LoadingScreen.razor @@ -126,12 +126,11 @@ else } @code { - [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment ChildContent { get; set; } = null!; [Parameter] - public LayoutService LayoutService { get; set; } + public LayoutService LayoutService { get; set; } = null!; [Parameter] public int LoadingDelayMs { get; set; } diff --git a/src/Blazor.Server.UI/appsettings.json b/src/Blazor.Server.UI/appsettings.json index 9aa421ed1..26d452c0e 100644 --- a/src/Blazor.Server.UI/appsettings.json +++ b/src/Blazor.Server.UI/appsettings.json @@ -1,10 +1,10 @@ { "UseInMemoryDatabase": false, "DatabaseSettings": { - "DBProvider": "sqlite", - "ConnectionString": "Data Source=BlazorDashboardDb.db" - //"DBProvider": "mssql", - //"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=BlazorDashboardDb;Trusted_Connection=True;MultipleActiveResultSets=true;" + //"DBProvider": "sqlite", + //"ConnectionString": "Data Source=BlazorDashboardDb.db" + "DBProvider": "mssql", + "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=BlazorDashboardDb;Trusted_Connection=True;MultipleActiveResultSets=true;" //"DBProvider": "postgresql", //"ConnectionString": "Server=127.0.0.1;Database=BlazorDashboardDb;User Id=postgres;Password=postgrespw;Port=32768" }, diff --git a/src/Domain/Entities/Audit/AuditTrail.cs b/src/Domain/Entities/Audit/AuditTrail.cs index ceeecb99f..34c01c230 100644 --- a/src/Domain/Entities/Audit/AuditTrail.cs +++ b/src/Domain/Entities/Audit/AuditTrail.cs @@ -7,9 +7,9 @@ namespace CleanArchitecture.Blazor.Domain.Entities.Audit; -public class AuditTrail : IEntity +public class AuditTrail : IEntity { - public string Id { get; set; } = Guid.NewGuid().ToString(); + public int Id { get; set; } public string? UserId { get; set; } public virtual ApplicationUser? Owner { get; set; } public AuditType AuditType { get; set; } diff --git a/src/Infrastructure/Extensions/HttpClientServiceCollectionExtensions.cs b/src/Infrastructure/Extensions/HttpClientServiceCollectionExtensions.cs index 756d096bd..c8bf81e38 100644 --- a/src/Infrastructure/Extensions/HttpClientServiceCollectionExtensions.cs +++ b/src/Infrastructure/Extensions/HttpClientServiceCollectionExtensions.cs @@ -7,7 +7,7 @@ public static class HttpClientServiceCollectionExtensions public static void AddHttpClientService(this IServiceCollection services) => services.AddHttpClient("ocr", c => { - c.BaseAddress = new Uri("https://paddleocr.i247365.net/predict/ocr_system"); - c.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + c.BaseAddress = new Uri("https://paddleocr.blazorserver.com/uploadocr"); + c.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data")); }).AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(3, _ => TimeSpan.FromSeconds(30))); } diff --git a/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs b/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs index f66a26228..45c80fab1 100644 --- a/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs +++ b/src/Infrastructure/Persistence/Interceptors/AuditableEntityInterceptor.cs @@ -12,7 +12,6 @@ public class AuditableEntityInterceptor : SaveChangesInterceptor private readonly ICurrentUserService _currentUserService; private readonly IDateTime _dateTime; private List _temporaryAuditTrailList = new(); - private List _deletingDomainEvents = new(); public AuditableEntityInterceptor( ITenantProvider tenantProvider, ICurrentUserService currentUserService, diff --git a/src/Infrastructure/Services/PaddleOCR/DocumentOcrJob.cs b/src/Infrastructure/Services/PaddleOCR/DocumentOcrJob.cs index 739d505f1..86c3f295c 100644 --- a/src/Infrastructure/Services/PaddleOCR/DocumentOcrJob.cs +++ b/src/Infrastructure/Services/PaddleOCR/DocumentOcrJob.cs @@ -72,21 +72,25 @@ public async Task Recognition(int id, CancellationToken cancellationToken) if (string.IsNullOrEmpty(doc.URL)) return; var imgFile = Path.Combine(Directory.GetCurrentDirectory(), doc.URL); if (!File.Exists(imgFile)) return; - string base64String = ReadBase64String(imgFile); - - var response = client.PostAsJsonAsync("", new { images = new string[] { base64String } }).Result; + // Create multipart/form-data content + using var form = new MultipartFormDataContent(); + using var fileStream = new FileStream(imgFile, FileMode.Open); + using var fileContent = new StreamContent(fileStream); + + form.Add(fileContent, "file", Path.GetFileName(imgFile)); // "image" is the form parameter name for the file + + var response = await client.PostAsync("", form); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var result = await response.Content.ReadAsStringAsync(); var ocrResult = JsonSerializer.Deserialize(result); - var ocrStatus = ocrResult!.status; doc.Status = JobStatus.Done; - doc.Description = "recognize the result: " + ocrStatus; - if (ocrResult.status == "000") + + if (ocrResult is not null) { - var content = _serializer.Serialize(ocrResult.results); - doc!.Content = content; - + var content = string.Join(',', ocrResult.data); + doc.Description = $"recognize the result: success"; + doc.Content = content; } await _context.SaveChangesAsync(cancellationToken); await _hubContext.Clients.All.Completed(doc.Title!); @@ -108,17 +112,9 @@ public async Task Recognition(int id, CancellationToken cancellationToken) } #pragma warning disable CS8981 -class result -{ - public decimal confidence { get; set; } - public string text { get; set; } = String.Empty; - public List text_region { get; set; } = new(); -} class OcrResult { - public string msg { get; set; } = String.Empty; - public List results { get; set; } = new(); - public string status { get; set; }=String.Empty; + public string[] data { get; set; } = Array.Empty(); } #pragma warning restore CS8981 diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20230826094051_refactor_base_entity.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20230826094051_refactor_base_entity.Designer.cs new file mode 100644 index 000000000..deae38814 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20230826094051_refactor_base_entity.Designer.cs @@ -0,0 +1,666 @@ +// +using System; +using CleanArchitecture.Blazor.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20230826094051_refactor_base_entity")] + partial class refactor_base_entity + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Audit.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrails"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Customers"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(450)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("nvarchar(450)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("URL") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Text") + .HasColumnType("nvarchar(max)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("KeyValues"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Logger.Logger", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientAgent") + .HasColumnType("nvarchar(max)"); + + b.Property("ClientIP") + .HasColumnType("nvarchar(max)"); + + b.Property("Exception") + .HasColumnType("nvarchar(max)"); + + b.Property("Level") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LogEvent") + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("MessageTemplate") + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("TimeStamp") + .HasColumnType("datetime2"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Loggers"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Brand") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Pictures") + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("Unit") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Tenant", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tenants"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasColumnType("text"); + + b.Property("Provider") + .HasColumnType("nvarchar(max)"); + + b.Property("RefreshToken") + .HasColumnType("nvarchar(max)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("SuperiorId") + .HasColumnType("nvarchar(450)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(max)"); + + b.Property("TenantName") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Audit.AuditTrail", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Entities.Document", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("CleanArchitecture.Blazor.Domain.Entities.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.Navigation("Superior"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserLogin", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("CleanArchitecture.Blazor.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20230826094051_refactor_base_entity.cs b/src/Migrators/Migrators.MSSQL/Migrations/20230826094051_refactor_base_entity.cs new file mode 100644 index 000000000..83d1e913e --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20230826094051_refactor_base_entity.cs @@ -0,0 +1,59 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CleanArchitecture.Blazor.Migrators.MSSQL.Migrations +{ + /// + public partial class refactor_base_entity : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Created", + table: "Tenants"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "Tenants"); + + migrationBuilder.DropColumn( + name: "LastModified", + table: "Tenants"); + + migrationBuilder.DropColumn( + name: "LastModifiedBy", + table: "Tenants"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Created", + table: "Tenants", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "Tenants", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModified", + table: "Tenants", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifiedBy", + table: "Tenants", + type: "nvarchar(max)", + nullable: true); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 2b81208a2..1b8fde855 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("ProductVersion", "7.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -282,21 +282,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("nvarchar(450)"); - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - b.Property("Description") .HasColumnType("nvarchar(max)"); - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - b.Property("Name") .HasColumnType("nvarchar(max)");