From cc4efd4396f38c334bdf0276d716df35d95718a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Sun, 1 Mar 2026 23:43:25 +0300 Subject: [PATCH] =?UTF-8?q?Developer=20Kit=20d=C3=BCzenlemeleri?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SqlQueryManagerDbProperties.cs | 2 +- .../DeveloperKit/CrudMigrationDto.cs | 28 - .../DeveloperKit/ICrudMigrationAppService.cs | 19 - ...tyAppService.cs => ISqlTableAppService.cs} | 10 +- .../{CustomEntityDto.cs => SqlTableDto.cs} | 16 +- .../CrudEndpointGenerateAppService.cs | 18 +- .../DeveloperKit/CrudMigrationAppService.cs | 302 ------ .../CustomEndpointAppService.cs | 0 .../DeveloperKitAutoMapperProfile.cs | 14 +- ...ityAppService.cs => SqlTableAppService.cs} | 106 +-- .../Seeds/LanguagesData.json | 6 - .../Seeds/MenusData.json | 99 +- .../Seeds/PermissionsData.json | 18 - .../Enums/TableNameEnum.cs | 9 +- .../TableNameResolver.cs | 5 +- .../DeveloperKit/IApiMigrationRepository.cs | 12 - .../DeveloperKit/CrudEndpoint.cs | 4 +- .../DeveloperKit/CrudMigration.cs | 19 - .../{CustomEntity.cs => SqlTable.cs} | 16 +- .../PlatformApiMigrationRepository.cs | 24 - .../PlatformDynamicEntityManager.cs | 10 +- .../EntityFrameworkCore/PlatformDbContext.cs | 32 +- ....cs => 20260301203437_Initial.Designer.cs} | 438 ++++----- ...3_Initial.cs => 20260301203437_Initial.cs} | 337 +++---- .../PlatformDbContextModelSnapshot.cs | 436 ++++----- .../Tenants/Seeds/TenantData.json | 4 +- .../developerKit/CrudEndpointManager.tsx | 790 ---------------- ui/src/components/developerKit/Dashboard.tsx | 529 ----------- .../components/developerKit/EntityEditor.tsx | 678 -------------- .../components/developerKit/EntityManager.tsx | 438 --------- .../developerKit/MigrationManager.tsx | 533 ----------- ui/src/components/layouts/DeveloperLayout.tsx | 12 - ui/src/contexts/EntityContext.tsx | 159 +--- ui/src/proxy/developerKit/models.ts | 36 +- ui/src/routes/route.constant.ts | 1 - ui/src/services/developerKit.service.ts | 110 +-- ui/src/utils/hooks/useDeveloperKit.ts | 128 --- ui/src/views/admin/listForm/Wizard.tsx | 2 +- .../JsonRowOpDialogWidget.tsx | 2 +- .../developerKit/CodeLayout.tsx | 0 ui/src/views/developerKit/CodePage.tsx | 8 - .../developerKit/ComponentEditor.tsx | 0 ...DetailPage.tsx => ComponentEditorPage.tsx} | 6 +- .../developerKit/ComponentManager.tsx | 36 +- ...onentPage.tsx => ComponentManagerPage.tsx} | 6 +- .../developerKit/CrudEndpointManager.tsx | 876 ++++++++++++++++++ .../views/developerKit/CrudEndpointPage.tsx | 16 - ui/src/views/developerKit/DashboardPage.tsx | 28 - .../developerKit/DynamicServiceEditor.tsx} | 8 + .../views/developerKit/DynamicServicePage.tsx | 16 - .../views/developerKit/EntityDetailPage.tsx | 16 - ui/src/views/developerKit/EntityPage.tsx | 16 - ui/src/views/developerKit/MigrationPage.tsx | 16 - .../components => developerKit}/SqlEditor.tsx | 0 .../SqlObjectExplorer.tsx | 0 .../SqlObjectProperties.tsx | 0 .../SqlQueryManager.tsx | 75 +- .../SqlResultsGrid.tsx | 0 .../SqlTableDesignerDialog.tsx} | 42 +- .../components/TemplateDialog.tsx | 292 ------ 60 files changed, 1627 insertions(+), 5232 deletions(-) delete mode 100644 api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/CrudMigrationDto.cs delete mode 100644 api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ICrudMigrationAppService.cs rename api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/{ICustomEntityAppService.cs => ISqlTableAppService.cs} (51%) rename api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/{CustomEntityDto.cs => SqlTableDto.cs} (78%) delete mode 100644 api/src/Sozsoft.Platform.Application/DeveloperKit/CrudMigrationAppService.cs rename api/src/Sozsoft.Platform.Application/{CustomEndpoints => DeveloperKit}/CustomEndpointAppService.cs (100%) rename api/src/Sozsoft.Platform.Application/DeveloperKit/{CustomEntityAppService.cs => SqlTableAppService.cs} (60%) delete mode 100644 api/src/Sozsoft.Platform.Domain/DeveloperKit/IApiMigrationRepository.cs delete mode 100644 api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudMigration.cs rename api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/{CustomEntity.cs => SqlTable.cs} (72%) delete mode 100644 api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformApiMigrationRepository.cs rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260301173343_Initial.Designer.cs => 20260301203437_Initial.Designer.cs} (98%) rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260301173343_Initial.cs => 20260301203437_Initial.cs} (97%) delete mode 100644 ui/src/components/developerKit/CrudEndpointManager.tsx delete mode 100644 ui/src/components/developerKit/Dashboard.tsx delete mode 100644 ui/src/components/developerKit/EntityEditor.tsx delete mode 100644 ui/src/components/developerKit/EntityManager.tsx delete mode 100644 ui/src/components/developerKit/MigrationManager.tsx delete mode 100644 ui/src/utils/hooks/useDeveloperKit.ts rename ui/src/{components => views}/developerKit/CodeLayout.tsx (100%) delete mode 100644 ui/src/views/developerKit/CodePage.tsx rename ui/src/{components => views}/developerKit/ComponentEditor.tsx (100%) rename ui/src/views/developerKit/{ComponentDetailPage.tsx => ComponentEditorPage.tsx} (54%) rename ui/src/{components => views}/developerKit/ComponentManager.tsx (93%) rename ui/src/views/developerKit/{ComponentPage.tsx => ComponentManagerPage.tsx} (54%) create mode 100644 ui/src/views/developerKit/CrudEndpointManager.tsx delete mode 100644 ui/src/views/developerKit/CrudEndpointPage.tsx delete mode 100644 ui/src/views/developerKit/DashboardPage.tsx rename ui/src/{components/developerKit/DynamicAppServiceEditor.tsx => views/developerKit/DynamicServiceEditor.tsx} (98%) delete mode 100644 ui/src/views/developerKit/DynamicServicePage.tsx delete mode 100644 ui/src/views/developerKit/EntityDetailPage.tsx delete mode 100644 ui/src/views/developerKit/EntityPage.tsx delete mode 100644 ui/src/views/developerKit/MigrationPage.tsx rename ui/src/views/{sqlQueryManager/components => developerKit}/SqlEditor.tsx (100%) rename ui/src/views/{sqlQueryManager/components => developerKit}/SqlObjectExplorer.tsx (100%) rename ui/src/views/{sqlQueryManager/components => developerKit}/SqlObjectProperties.tsx (100%) rename ui/src/views/{sqlQueryManager => developerKit}/SqlQueryManager.tsx (97%) rename ui/src/views/{sqlQueryManager/components => developerKit}/SqlResultsGrid.tsx (100%) rename ui/src/views/{sqlQueryManager/components/TableDesignerDialog.tsx => developerKit/SqlTableDesignerDialog.tsx} (98%) delete mode 100644 ui/src/views/sqlQueryManager/components/TemplateDialog.tsx diff --git a/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Domain/SqlQueryManagerDbProperties.cs b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Domain/SqlQueryManagerDbProperties.cs index c8213fb..06ba53e 100644 --- a/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Domain/SqlQueryManagerDbProperties.cs +++ b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Domain/SqlQueryManagerDbProperties.cs @@ -2,7 +2,7 @@ public static class Prefix { - public static string MenuPrefix { get; set; } = "Sqm"; + public static string MenuPrefix { get; set; } = "Sas"; public static string HostPrefix { get; set; } = "T"; public static string? DbSchema { get; set; } = null; diff --git a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/CrudMigrationDto.cs b/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/CrudMigrationDto.cs deleted file mode 100644 index 3694dbe..0000000 --- a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/CrudMigrationDto.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Migration DTOs -using System; -using Volo.Abp.Application.Dtos; - -namespace Sozsoft.Platform.DeveloperKit; - -public class CrudMigrationDto : AuditedEntityDto -{ - public Guid EntityId { get; set; } - public string EntityName { get; set; } = string.Empty; - public string FileName { get; set; } = string.Empty; - public string SqlScript { get; set; } = string.Empty; - public string Status { get; set; } = "Askıda"; // "pending" | "applied" | "failed" - public DateTime? AppliedAt { get; set; } - public string? ErrorMessage { get; set; } -} - -public class CreateUpdateCrudMigrationDto -{ - public Guid EntityId { get; set; } - public string EntityName { get; set; } = string.Empty; - public string FileName { get; set; } = string.Empty; - public string SqlScript { get; set; } = string.Empty; - public string Status { get; set; } = "Askıda"; - public DateTime? AppliedAt { get; set; } - public string? ErrorMessage { get; set; } -} - diff --git a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ICrudMigrationAppService.cs b/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ICrudMigrationAppService.cs deleted file mode 100644 index eaf4ea6..0000000 --- a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ICrudMigrationAppService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; - -namespace Sozsoft.Platform.DeveloperKit; - -public interface ICrudMigrationAppService : ICrudAppService< - CrudMigrationDto, - Guid, - PagedAndSortedResultRequestDto, - CreateUpdateCrudMigrationDto> -{ - Task ApplyMigrationAsync(Guid id); - Task> GetPendingMigrationsAsync(); - Task GenerateMigrationAsync(Guid entityId); -} - diff --git a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ICustomEntityAppService.cs b/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ISqlTableAppService.cs similarity index 51% rename from api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ICustomEntityAppService.cs rename to api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ISqlTableAppService.cs index 4c4fdfd..75f0701 100644 --- a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ICustomEntityAppService.cs +++ b/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/ISqlTableAppService.cs @@ -6,13 +6,13 @@ using Volo.Abp.Application.Services; namespace Sozsoft.Platform.DeveloperKit; -public interface ICustomEntityAppService : ICrudAppService< - CustomEntityDto, +public interface ISqlTableAppService : ICrudAppService< + SqlTableDto, Guid, PagedAndSortedResultRequestDto, - CreateUpdateCustomEntityDto> + CreateUpdateSqlTableDto> { - Task> GetActiveEntitiesAsync(); - Task ToggleActiveStatusAsync(Guid id); + Task> GetActiveEntitiesAsync(); + Task ToggleActiveStatusAsync(Guid id); } diff --git a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/CustomEntityDto.cs b/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/SqlTableDto.cs similarity index 78% rename from api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/CustomEntityDto.cs rename to api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/SqlTableDto.cs index cde4dd0..14bd7ab 100644 --- a/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/CustomEntityDto.cs +++ b/api/src/Sozsoft.Platform.Application.Contracts/DeveloperKit/SqlTableDto.cs @@ -4,7 +4,7 @@ using Volo.Abp.Application.Dtos; namespace Sozsoft.Platform.DeveloperKit; -public class CustomEntityDto : FullAuditedEntityDto +public class SqlTableDto : FullAuditedEntityDto { public string Menu { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; @@ -14,14 +14,12 @@ public class CustomEntityDto : FullAuditedEntityDto public bool IsActive { get; set; } = true; public bool IsFullAuditedEntity { get; set; } = true; public bool IsMultiTenant { get; set; } = false; - public string MigrationStatus { get; set; } = "Askıda"; - public Guid? MigrationId { get; set; } - public string EndpointStatus { get; set; } = "Askıda"; + public string EndpointStatus { get; set; } = "pending"; - public List Fields { get; set; } = []; + public List Fields { get; set; } = []; } -public class CreateUpdateCustomEntityDto +public class CreateUpdateSqlTableDto { public string Menu { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; @@ -32,10 +30,10 @@ public class CreateUpdateCustomEntityDto public bool IsFullAuditedEntity { get; set; } = true; public bool IsMultiTenant { get; set; } = false; - public List Fields { get; set; } = []; + public List Fields { get; set; } = []; } -public class EntityFieldDto : FullAuditedEntityDto +public class SqlTableFieldDto : FullAuditedEntityDto { public Guid EntityId { get; set; } public string Name { get; set; } = string.Empty; @@ -48,7 +46,7 @@ public class EntityFieldDto : FullAuditedEntityDto public int DisplayOrder { get; set; } = 0; } -public class CreateUpdateCustomEntityFieldDto +public class CreateUpdateSqlTableFieldDto { public Guid? Id { get; set; } diff --git a/api/src/Sozsoft.Platform.Application/DeveloperKit/CrudEndpointGenerateAppService.cs b/api/src/Sozsoft.Platform.Application/DeveloperKit/CrudEndpointGenerateAppService.cs index 45749ae..76851c5 100644 --- a/api/src/Sozsoft.Platform.Application/DeveloperKit/CrudEndpointGenerateAppService.cs +++ b/api/src/Sozsoft.Platform.Application/DeveloperKit/CrudEndpointGenerateAppService.cs @@ -18,19 +18,16 @@ public class CrudEndpointGenerateAppService : CrudAppService< PagedAndSortedResultRequestDto, CreateUpdateCrudEndpointDto>, ICrudEndpointAppService { - private readonly IRepository _entityRepository; - private readonly IRepository _migrationRepository; + private readonly IRepository _entityRepository; private readonly IRepository _endpointRepository; public CrudEndpointGenerateAppService( IRepository repository, - IRepository entityRepository, - IRepository migrationRepository, + IRepository entityRepository, IRepository endpointRepository) : base(repository) { _entityRepository = entityRepository; - _migrationRepository = migrationRepository; _endpointRepository = endpointRepository; } @@ -59,17 +56,6 @@ public class CrudEndpointGenerateAppService : CrudAppService< throw new Exception($"Entity with ID {entityId} not found"); } - // Migration kontrolü - var migrationQueryable = await _migrationRepository.GetQueryableAsync(); - var migration = await migrationQueryable - .Where(x => x.EntityId == entityId && x.Status == "applied") - .FirstOrDefaultAsync(); - - if (migration == null) - { - throw new Exception($"No applied migration found for entity {entity.Name}. Please apply migration first."); - } - // CRUD endpointleri oluştur var endpoints = new List(); var entityName = entity.Name; diff --git a/api/src/Sozsoft.Platform.Application/DeveloperKit/CrudMigrationAppService.cs b/api/src/Sozsoft.Platform.Application/DeveloperKit/CrudMigrationAppService.cs deleted file mode 100644 index 04dc158..0000000 --- a/api/src/Sozsoft.Platform.Application/DeveloperKit/CrudMigrationAppService.cs +++ /dev/null @@ -1,302 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Application.Services; -using Volo.Abp.Domain.Repositories; -using Volo.Abp.Application.Dtos; -using System.Text; -using Volo.Abp.Domain.Entities; -using Sozsoft.Platform.Entities; -using Sozsoft.Platform.DeveloperKit; -using System; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Linq; -using Sozsoft.Platform.Domain.DeveloperKit; - -namespace Platform.Api.Application; - -public class CrudMigrationAppService : CrudAppService< - CrudMigration, - CrudMigrationDto, - Guid, - PagedAndSortedResultRequestDto, - CreateUpdateCrudMigrationDto>, ICrudMigrationAppService -{ - private readonly IRepository _migrationRepository; - private readonly IRepository _entityRepository; - private readonly IRepository _fieldRepository; - private readonly IApiMigrationRepository _customSqlExecutor; - - public CrudMigrationAppService( - IRepository migrationRepository, - IRepository entityRepository, - IRepository fieldRepository, - IApiMigrationRepository customSqlExecutor - ) : base(migrationRepository) - { - _migrationRepository = migrationRepository; - _entityRepository = entityRepository; - _fieldRepository = fieldRepository; - _customSqlExecutor = customSqlExecutor; - } - - public virtual async Task ApplyMigrationAsync(Guid id) - { - var migration = await _migrationRepository.GetAsync(id); - - try - { - await _customSqlExecutor.ExecuteSqlAsync(migration.SqlScript); - - migration.Status = "Uygulandı"; - migration.AppliedAt = DateTime.UtcNow; - migration.ErrorMessage = null; - - await _migrationRepository.UpdateAsync(migration, autoSave: true); - - var entity = await _entityRepository.GetAsync(migration.EntityId); - entity.MigrationStatus = "Uygulandı"; - await _entityRepository.UpdateAsync(entity, autoSave: true); - - return ObjectMapper.Map(migration); - } - catch (Exception ex) - { - migration.Status = "failed"; - migration.ErrorMessage = ex.Message; - await _migrationRepository.UpdateAsync(migration, autoSave: true); - - var entity = await _entityRepository.GetAsync(migration.EntityId); - entity.MigrationStatus = "failed"; - await _entityRepository.UpdateAsync(entity, autoSave: true); - - throw; - } - } - - - public virtual async Task> GetPendingMigrationsAsync() - { - var queryable = await _migrationRepository.GetQueryableAsync(); - var pending = await queryable - .Where(m => m.Status == "pending") - .OrderBy(m => m.CreationTime) - .ToListAsync(); - - return ObjectMapper.Map, List>(pending); - } - - - public virtual async Task GenerateMigrationAsync(Guid entityId) - { - var queryable = await _entityRepository.GetQueryableAsync(); - var entity = await queryable - .Include(x => x.Fields) - .FirstOrDefaultAsync(x => x.Id == entityId); - - if (entity == null) - throw new EntityNotFoundException($"CustomEntity with id {entityId} not found"); - - // Check if there are any previously applied migrations for this entity - var migrationQueryable = await _migrationRepository.GetQueryableAsync(); - var lastAppliedMigration = await migrationQueryable - .Where(m => m.EntityId == entityId && m.Status == "applied") - .OrderByDescending(m => m.CreationTime) - .FirstOrDefaultAsync(); - - // Use "Update" if migrations were applied before, otherwise "Create" - var operationType = lastAppliedMigration != null ? "Update" : "Create"; - var fileName = $"{DateTime.UtcNow:yyyyMMddHHmmss}_{operationType}{entity.Name}Table.sql"; - - var sqlScript = lastAppliedMigration != null - ? GenerateAlterTableScript(entity, lastAppliedMigration) - : GenerateCreateTableScript(entity); - - var migration = new CrudMigration - { - EntityId = entityId, - EntityName = entity.Name, - FileName = fileName, - SqlScript = sqlScript, - Status = "Askıda" - }; - - migration = await _migrationRepository.InsertAsync(migration, autoSave: true); - - entity.MigrationId = migration.Id; - entity.MigrationStatus = "Askıda"; - await _entityRepository.UpdateAsync(entity, autoSave: true); - - return ObjectMapper.Map(migration); - } - - private string GenerateCreateTableScript(CustomEntity entity) - { - if (entity.Fields == null || !entity.Fields.Any()) - throw new InvalidOperationException($"Entity '{entity.Name}' does not have any fields defined."); - - var sb = new StringBuilder(); - - sb.AppendLine($@"/* - # Create {entity.DisplayName} table - - 1. New Table - - [{entity.TableName}]"); - - foreach (var field in entity.Fields) - { - sb.AppendLine($" - [{field.Name}] ({field.Type}{(field.IsRequired ? ", required" : "")})"); - } - - sb.AppendLine("*/"); - - sb.AppendLine($"\nIF OBJECT_ID(N'{entity.TableName}', N'U') IS NULL"); - sb.AppendLine($"CREATE TABLE [{entity.TableName}] ("); - sb.AppendLine(" [Id] UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),"); - - foreach (var field in entity.Fields) - { - var sqlType = GetSqlType(field.Type, field.MaxLength); - sb.Append($" [{field.Name}] {sqlType}"); - - if (field.IsRequired) - sb.Append(" NOT NULL"); - - if (!string.IsNullOrWhiteSpace(field.DefaultValue)) - sb.Append($" DEFAULT {FormatDefaultValue(field.Type, field.DefaultValue)}"); - - sb.AppendLine(","); - } - - // Add TenantId if entity is multi-tenant - if (entity.IsMultiTenant) - { - sb.AppendLine(" [TenantId] UNIQUEIDENTIFIER NULL,"); - } - - // Add Full Audited Entity fields (includes both audit and soft delete) - if (entity.IsFullAuditedEntity) - { - sb.AppendLine(" [CreationTime] DATETIME2 DEFAULT SYSUTCDATETIME() NOT NULL,"); - sb.AppendLine(" [CreatorId] UNIQUEIDENTIFIER NULL,"); - sb.AppendLine(" [LastModificationTime] DATETIME2 NULL,"); - sb.AppendLine(" [LastModifierId] UNIQUEIDENTIFIER NULL,"); - sb.AppendLine(" [IsDeleted] BIT DEFAULT 0 NOT NULL,"); - sb.AppendLine(" [DeleterId] UNIQUEIDENTIFIER NULL,"); - sb.AppendLine(" [DeletionTime] DATETIME2 NULL,"); - } - - // Remove last comma - var script = sb.ToString().TrimEnd(',', '\r', '\n'); - script += "\n);\n"; - - return script; - } - - private string GenerateAlterTableScript(CustomEntity entity, CrudMigration lastAppliedMigration) - { - if (entity.Fields == null || !entity.Fields.Any()) - throw new InvalidOperationException($"Entity '{entity.Name}' does not have any fields defined."); - - // Parse the last applied migration's SQL to understand what fields existed - var existingFieldNames = ExtractFieldNamesFromCreateScript(lastAppliedMigration.SqlScript); - - var sb = new StringBuilder(); - - sb.AppendLine($@"/* - # Update {entity.DisplayName} table - - 1. Alter Table - - [{entity.TableName}] - - Adding new fields or modifying existing ones"); - - sb.AppendLine("*/\n"); - - // Find new fields that need to be added - var newFields = entity.Fields.Where(f => !existingFieldNames.Contains(f.Name)).ToList(); - - if (newFields.Any()) - { - foreach (var field in newFields) - { - var sqlType = GetSqlType(field.Type, field.MaxLength); - sb.Append($"IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'[{entity.TableName}]') AND name = '{field.Name}')\n"); - sb.Append($"BEGIN\n"); - sb.Append($" ALTER TABLE [{entity.TableName}] ADD [{field.Name}] {sqlType}"); - - if (field.IsRequired) - sb.Append(" NOT NULL"); - else - sb.Append(" NULL"); - - if (!string.IsNullOrWhiteSpace(field.DefaultValue)) - sb.Append($" DEFAULT {FormatDefaultValue(field.Type, field.DefaultValue)}"); - - sb.AppendLine(";"); - sb.AppendLine($"END\n"); - } - } - else - { - sb.AppendLine("-- No new fields to add"); - } - - return sb.ToString(); - } - - private HashSet ExtractFieldNamesFromCreateScript(string sqlScript) - { - var fieldNames = new HashSet(StringComparer.OrdinalIgnoreCase); - - // Simple parsing - extract field names between [ and ] - var lines = sqlScript.Split('\n'); - foreach (var line in lines) - { - var trimmedLine = line.Trim(); - if (trimmedLine.StartsWith("[") && trimmedLine.Contains("]")) - { - var fieldName = trimmedLine.Substring(1, trimmedLine.IndexOf("]") - 1); - if (fieldName != "Id" && - fieldName != "TenantId" && - fieldName != "CreationTime" && - fieldName != "CreatorId" && - fieldName != "LastModificationTime" && - fieldName != "LastModifierId" && - fieldName != "IsDeleted" && - fieldName != "DeleterId" && - fieldName != "DeletionTime") - { - fieldNames.Add(fieldName); - } - } - } - - return fieldNames; - } - - private string GetSqlType(string fieldType, int? maxLength) - { - return fieldType.ToLower() switch - { - "string" => maxLength.HasValue ? $"NVARCHAR({maxLength.Value})" : "NVARCHAR(MAX)", - "number" => "INT", - "decimal" => "DECIMAL(18, 2)", - "boolean" => "BIT", - "date" => "DATETIME2", - "guid" => "UNIQUEIDENTIFIER", - _ => "NVARCHAR(MAX)" - }; - } - - private string FormatDefaultValue(string fieldType, string defaultValue) - { - return fieldType.ToLower() switch - { - "string" => $"N'{defaultValue}'", - "date" => $"'{defaultValue}'", // ISO format beklenir - "guid" => $"'{defaultValue}'", - "boolean" => (defaultValue.ToLower() == "true" || defaultValue == "1") ? "1" : "0", - _ => defaultValue - }; - } -} - diff --git a/api/src/Sozsoft.Platform.Application/CustomEndpoints/CustomEndpointAppService.cs b/api/src/Sozsoft.Platform.Application/DeveloperKit/CustomEndpointAppService.cs similarity index 100% rename from api/src/Sozsoft.Platform.Application/CustomEndpoints/CustomEndpointAppService.cs rename to api/src/Sozsoft.Platform.Application/DeveloperKit/CustomEndpointAppService.cs diff --git a/api/src/Sozsoft.Platform.Application/DeveloperKit/DeveloperKitAutoMapperProfile.cs b/api/src/Sozsoft.Platform.Application/DeveloperKit/DeveloperKitAutoMapperProfile.cs index ae07537..29e38da 100644 --- a/api/src/Sozsoft.Platform.Application/DeveloperKit/DeveloperKitAutoMapperProfile.cs +++ b/api/src/Sozsoft.Platform.Application/DeveloperKit/DeveloperKitAutoMapperProfile.cs @@ -7,13 +7,13 @@ public class DeveloperKitAutoMapperProfile : Profile { public DeveloperKitAutoMapperProfile() { - // CustomEntity mappings - CreateMap(); - CreateMap(); + // SqlTable mappings + CreateMap(); + CreateMap(); // EntityField mappings - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); // CustomComponent mappings CreateMap(); @@ -24,10 +24,6 @@ public class DeveloperKitAutoMapperProfile : Profile .ForMember(dest => dest.EntityDisplayName, opt => opt.MapFrom(src => src.Entity != null ? src.Entity.DisplayName : null)); CreateMap(); - // Migration mappings - CreateMap(); - CreateMap(); - CreateMap() .ForMember(dest => dest.CompilationStatus, opt => opt.MapFrom(src => src.CompilationStatus.ToString())); } diff --git a/api/src/Sozsoft.Platform.Application/DeveloperKit/CustomEntityAppService.cs b/api/src/Sozsoft.Platform.Application/DeveloperKit/SqlTableAppService.cs similarity index 60% rename from api/src/Sozsoft.Platform.Application/DeveloperKit/CustomEntityAppService.cs rename to api/src/Sozsoft.Platform.Application/DeveloperKit/SqlTableAppService.cs index 7e91adc..e202120 100644 --- a/api/src/Sozsoft.Platform.Application/DeveloperKit/CustomEntityAppService.cs +++ b/api/src/Sozsoft.Platform.Application/DeveloperKit/SqlTableAppService.cs @@ -9,35 +9,31 @@ using System; using System.Threading.Tasks; using System.Collections.Generic; using System.Linq; -using Microsoft.Extensions.Logging; namespace Platform.Api.Application; -public class CustomEntityAppService : CrudAppService< - CustomEntity, - CustomEntityDto, +public class SqlTableAppService : CrudAppService< + SqlTable, + SqlTableDto, Guid, PagedAndSortedResultRequestDto, - CreateUpdateCustomEntityDto>, ICustomEntityAppService + CreateUpdateSqlTableDto>, ISqlTableAppService { - private readonly IRepository _repository; - private readonly IRepository _migrationRepository; + private readonly IRepository _repository; + private readonly IRepository _fieldRepository; private readonly IRepository _endpointRepository; - private readonly IRepository _fieldRepository; - public CustomEntityAppService( - IRepository repository, - IRepository migrationRepository, - IRepository endpointRepository, - IRepository fieldRepository) : base(repository) + public SqlTableAppService( + IRepository repository, + IRepository fieldRepository, + IRepository endpointRepository) : base(repository) { _repository = repository; - _migrationRepository = migrationRepository; - _endpointRepository = endpointRepository; _fieldRepository = fieldRepository; + _endpointRepository = endpointRepository; } - public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) + public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) { var query = await _repository.GetQueryableAsync(); var fullQuery = query.Include(x => x.Fields.OrderBy(f => f.DisplayOrder)); @@ -50,12 +46,12 @@ public class CustomEntityAppService : CrudAppService< .Take(input.MaxResultCount) .ToListAsync(); - var dtos = ObjectMapper.Map, List>(entities); + var dtos = ObjectMapper.Map, List>(entities); - return new PagedResultDto(totalCount, dtos); + return new PagedResultDto(totalCount, dtos); } - public override async Task GetAsync(Guid id) + public override async Task GetAsync(Guid id) { var query = await _repository.GetQueryableAsync(); var entity = await query @@ -65,10 +61,10 @@ public class CustomEntityAppService : CrudAppService< if (entity == null) throw new EntityNotFoundException($"CustomEntity with id {id} not found"); - return ObjectMapper.Map(entity); + return ObjectMapper.Map(entity); } - public async Task> GetActiveEntitiesAsync() + public async Task> GetActiveEntitiesAsync() { var query = await _repository.GetQueryableAsync(); var entities = await query @@ -76,10 +72,10 @@ public class CustomEntityAppService : CrudAppService< .Where(x => x.IsActive) .ToListAsync(); - return ObjectMapper.Map, List>(entities); + return ObjectMapper.Map, List>(entities); } - public async Task ToggleActiveStatusAsync(Guid id) + public async Task ToggleActiveStatusAsync(Guid id) { var query = await _repository.GetQueryableAsync(); var entity = await query @@ -92,10 +88,10 @@ public class CustomEntityAppService : CrudAppService< entity.IsActive = !entity.IsActive; await _repository.UpdateAsync(entity, autoSave: true); - return ObjectMapper.Map(entity); + return ObjectMapper.Map(entity); } - public override async Task UpdateAsync(Guid id, CreateUpdateCustomEntityDto input) + public override async Task UpdateAsync(Guid id, CreateUpdateSqlTableDto input) { var query = await _repository.GetQueryableAsync(); var entity = await query @@ -103,20 +99,7 @@ public class CustomEntityAppService : CrudAppService< .FirstOrDefaultAsync(e => e.Id == id); if (entity == null) - throw new EntityNotFoundException(typeof(CustomEntity), id); - - // If entity structure has changed and migration was applied, reset migration status - bool structureChanged = entity.Name != input.Name || - entity.TableName != input.TableName || - entity.IsFullAuditedEntity != input.IsFullAuditedEntity || - entity.IsMultiTenant != input.IsMultiTenant || - FieldsHaveChanged(entity.Fields, input.Fields); - - if (structureChanged && entity.MigrationStatus == "applied") - { - entity.MigrationStatus = "Askıda"; - entity.MigrationId = null; - } + throw new EntityNotFoundException(typeof(SqlTable), id); entity.Menu = input.Menu; entity.Name = input.Name; @@ -127,12 +110,12 @@ public class CustomEntityAppService : CrudAppService< entity.IsFullAuditedEntity = input.IsFullAuditedEntity; entity.IsMultiTenant = input.IsMultiTenant; - var updatedFields = new List(); + var updatedFields = new List(); for (int i = 0; i < input.Fields.Count; i++) { var dtoField = input.Fields[i]; - CustomEntityField? existingField = null; + SqlTableField? existingField = null; if (dtoField.Id.HasValue) { @@ -154,7 +137,7 @@ public class CustomEntityAppService : CrudAppService< } else { - var newField = new CustomEntityField + var newField = new SqlTableField { EntityId = entity.Id, Name = dtoField.Name, @@ -184,13 +167,13 @@ public class CustomEntityAppService : CrudAppService< await _repository.UpdateAsync(entity, autoSave: true); - return ObjectMapper.Map(entity); + return ObjectMapper.Map(entity); } - public override async Task CreateAsync(CreateUpdateCustomEntityDto input) + public override async Task CreateAsync(CreateUpdateSqlTableDto input) { // Entity oluştur - var entity = new CustomEntity + var entity = new SqlTable { Menu = input.Menu, Name = input.Name, @@ -200,14 +183,13 @@ public class CustomEntityAppService : CrudAppService< IsActive = input.IsActive, IsFullAuditedEntity = input.IsFullAuditedEntity, IsMultiTenant = input.IsMultiTenant, - MigrationStatus = "Askıda" }; // Fields ekle - sıralama ile for (int i = 0; i < input.Fields.Count; i++) { var fieldDto = input.Fields[i]; - var field = new CustomEntityField + var field = new SqlTableField { EntityId = entity.Id, Name = fieldDto.Name, @@ -224,10 +206,10 @@ public class CustomEntityAppService : CrudAppService< entity = await _repository.InsertAsync(entity, autoSave: true); - return ObjectMapper.Map(entity); + return ObjectMapper.Map(entity); } - private bool FieldsHaveChanged(ICollection existingFields, List inputFields) + private bool FieldsHaveChanged(ICollection existingFields, List inputFields) { if (existingFields.Count != inputFields.Count) return true; @@ -252,31 +234,5 @@ public class CustomEntityAppService : CrudAppService< return false; } - - public override async Task DeleteAsync(Guid id) - { - // İlgili entity'nin var olup olmadığını kontrol et - var entity = await _repository.GetAsync(id); - - // İlgili ApiMigration kayıtlarını sil - var relatedMigrations = await _migrationRepository.GetListAsync(m => m.EntityId == id); - if (relatedMigrations.Any()) - { - Logger.LogInformation($"Deleting {relatedMigrations.Count} related migrations for entity {entity.Name} (ID: {id})"); - await _migrationRepository.DeleteManyAsync(relatedMigrations); - } - - var relatedEndpoints = await _endpointRepository.GetListAsync(e => e.EntityId == id); - if (relatedEndpoints.Any()) - { - Logger.LogInformation($"Deleting {relatedEndpoints.Count} related API endpoints for entity {entity.Name} (ID: {id})"); - await _endpointRepository.DeleteManyAsync(relatedEndpoints); - } - - Logger.LogInformation($"Deleting CustomEntity {entity.Name} (ID: {id}) and its fields"); - - // Ana entity'yi sil (CustomEntityField'lar otomatik silinecek - cascade delete) - await base.DeleteAsync(id); - } } diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json index ea653e6..7cd6819 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json @@ -624,12 +624,6 @@ "en": "Custom Entity", "tr": "Özel Varlık" }, - { - "resourceName": "Platform", - "key": "App.DeveloperKit.Migrations", - "en": "Crud Migrations", - "tr": "Crud Geçişleri" - }, { "resourceName": "Platform", "key": "App.DeveloperKit.CrudEndpoints", diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json index 2912244..20bfb54 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json @@ -283,84 +283,49 @@ { "key": "admin.sqlQueryManager", "path": "/admin/sqlQueryManager", - "componentPath": "@/views/sqlQueryManager/SqlQueryManager", + "componentPath": "@/views/developerKit/SqlQueryManager", "routeType": "protected", "authority": ["App.SqlQueryManager"] }, - { - "key": "admin.developerkit", - "path": "/admin/developerkit", - "componentPath": "@/views/developerKit/DashboardPage", - "routeType": "protected", - "authority": ["App.DeveloperKit"] - }, - { - "key": "admin.developerkit.entities", - "path": "/admin/developerkit/entities", - "componentPath": "@/views/developerKit/EntityPage", - "routeType": "protected", - "authority": ["App.DeveloperKit.Entity"] - }, - { - "key": "admin.developerkit.entities.new", - "path": "/admin/developerkit/entities/new", - "componentPath": "@/views/developerKit/EntityDetailPage", - "routeType": "protected", - "authority": ["App.DeveloperKit.Entity"] - }, - { - "key": "admin.developerkit.entities.edit", - "path": "/admin/developerkit/entities/edit/:id", - "componentPath": "@/views/developerKit/EntityDetailPage", - "routeType": "protected", - "authority": ["App.DeveloperKit.Entity"] - }, - { - "key": "admin.developerkit.migrations", - "path": "/admin/developerkit/migrations", - "componentPath": "@/views/developerKit/MigrationPage", - "routeType": "protected", - "authority": ["App.DeveloperKit.Migrations"] - }, { "key": "admin.developerkit.endpoints", "path": "/admin/developerkit/endpoints", - "componentPath": "@/views/developerKit/CrudEndpointPage", + "componentPath": "@/views/developerKit/CrudEndpointManager", "routeType": "protected", "authority": ["App.DeveloperKit.CrudEndpoints"] }, { "key": "admin.developerkit.dynamic-services", "path": "/admin/developerkit/dynamic-services", - "componentPath": "@/views/developerKit/DynamicServicePage", + "componentPath": "@/views/developerKit/DynamicServiceEditor", "routeType": "protected", "authority": ["App.DeveloperKit.DynamicServices"] }, { "key": "admin.developerkit.components", "path": "/admin/developerkit/components", - "componentPath": "@/views/developerKit/ComponentPage", + "componentPath": "@/views/developerKit/ComponentManagerPage", "routeType": "protected", "authority": ["App.DeveloperKit.Components"] }, { "key": "admin.developerkit.components.new", "path": "/admin/developerkit/components/new", - "componentPath": "@/views/developerKit/ComponentDetailPage", + "componentPath": "@/views/developerKit/ComponentEditorPage", "routeType": "protected", "authority": ["App.DeveloperKit.Components"] }, { "key": "admin.developerkit.components.view", "path": "/admin/developerkit/components/view/:id", - "componentPath": "@/views/developerKit/ComponentDetailPage", + "componentPath": "@/views/developerKit/ComponentEditorPage", "routeType": "protected", "authority": ["App.DeveloperKit.Components"] }, { "key": "admin.developerkit.components.edit", "path": "/admin/developerkit/components/edit/:id", - "componentPath": "@/views/developerKit/CodePage", + "componentPath": "@/views/developerKit/CodeLayout", "routeType": "protected", "authority": ["App.DeveloperKit.Components"] }, @@ -971,39 +936,19 @@ }, { "ParentCode": "App.DeveloperKit", - "Code": "App.DeveloperKit.Dashboard", - "DisplayName": "App.Coordinator.Classroom.Dashboard", + "Code": "App.SqlQueryManager", + "DisplayName": "App.SqlQueryManager", "Order": 1, - "Url": "/admin/developerkit", - "Icon": "FcBinoculars", - "RequiredPermissionName": "App.DeveloperKit", - "IsDisabled": false - }, - { - "ParentCode": "App.DeveloperKit", - "Code": "App.DeveloperKit.Entity", - "DisplayName": "App.DeveloperKit.Entity", - "Order": 2, - "Url": "/admin/developerkit/entities", - "Icon": "FcAddRow", - "RequiredPermissionName": "App.DeveloperKit.Entity", - "IsDisabled": false - }, - { - "ParentCode": "App.DeveloperKit", - "Code": "App.DeveloperKit.Migrations", - "DisplayName": "App.DeveloperKit.Migrations", - "Order": 3, - "Url": "/admin/developerkit/migrations", - "Icon": "FcAddDatabase", - "RequiredPermissionName": "App.DeveloperKit.Migrations", + "Url": "/admin/sqlQueryManager", + "Icon": "FaDatabase", + "RequiredPermissionName": "App.SqlQueryManager", "IsDisabled": false }, { "ParentCode": "App.DeveloperKit", "Code": "App.DeveloperKit.CrudEndpoints", "DisplayName": "App.DeveloperKit.CrudEndpoints", - "Order": 4, + "Order": 2, "Url": "/admin/developerkit/endpoints", "Icon": "FcOrgUnit", "RequiredPermissionName": "App.DeveloperKit.CrudEndpoints", @@ -1013,7 +958,7 @@ "ParentCode": "App.DeveloperKit", "Code": "App.DeveloperKit.CustomEndpoints", "DisplayName": "App.DeveloperKit.CustomEndpoints", - "Order": 5, + "Order": 3, "Url": "/admin/list/App.DeveloperKit.CustomEndpoints", "Icon": "FcMindMap", "RequiredPermissionName": "App.DeveloperKit.CustomEndpoints", @@ -1023,7 +968,7 @@ "ParentCode": "App.DeveloperKit", "Code": "App.DeveloperKit.Components", "DisplayName": "App.DeveloperKit.Components", - "Order": 6, + "Order": 4, "Url": "/admin/developerkit/components", "Icon": "FcBiohazard", "RequiredPermissionName": "App.DeveloperKit.Components", @@ -1033,27 +978,17 @@ "ParentCode": "App.DeveloperKit", "Code": "App.DeveloperKit.DynamicServices", "DisplayName": "App.DeveloperKit.DynamicServices", - "Order": 7, + "Order": 5, "Url": "/admin/developerkit/dynamic-services", "Icon": "FcCommandLine", "RequiredPermissionName": "App.DeveloperKit.DynamicServices", "IsDisabled": false }, - { - "ParentCode": "App.DeveloperKit", - "Code": "App.SqlQueryManager", - "DisplayName": "App.SqlQueryManager", - "Order": 8, - "Url": "/admin/sqlQueryManager", - "Icon": "FaDatabase", - "RequiredPermissionName": "App.SqlQueryManager", - "IsDisabled": false - }, { "ParentCode": "App.DeveloperKit", "Code": "App.Listforms.Wizard", "DisplayName": "App.Listforms.Wizard", - "Order": 9, + "Order": 6, "Url": "/admin/listform/wizard", "Icon": "FcFlashAuto", "RequiredPermissionName": "App.Listforms.Wizard", diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json index 742bdcc..243fe4b 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json @@ -2233,24 +2233,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp|Kurs" }, - { - "GroupName": "App.Administration", - "Name": "App.DeveloperKit.Entity", - "ParentName": "App.DeveloperKit", - "DisplayName": "App.DeveloperKit.Entity", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp|Kurs" - }, - { - "GroupName": "App.Administration", - "Name": "App.DeveloperKit.Migrations", - "ParentName": "App.DeveloperKit", - "DisplayName": "App.DeveloperKit.Migrations", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp|Kurs" - }, { "GroupName": "App.Administration", "Name": "App.DeveloperKit.CrudEndpoints", diff --git a/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs b/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs index 81e7283..09bd82b 100644 --- a/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs +++ b/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs @@ -29,10 +29,13 @@ public enum TableNameEnum ForumCategory, ForumTopic, ForumPost, + SqlTable, + SqlTableField, + SqlView, + SqlStoredProcedure, + SqlFunction, + SqlQuery, CrudEndpoint, - CrudMigration, - CustomEntity, - CustomEntityField, CustomEndpoint, CustomComponent, DynamicService, diff --git a/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs b/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs index 9280779..17c2e16 100644 --- a/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs +++ b/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs @@ -50,9 +50,8 @@ public static class TableNameResolver { nameof(TableNameEnum.Branch), (TablePrefix.TenantByName, MenuPrefix.Saas) }, { nameof(TableNameEnum.BranchUsers), (TablePrefix.TenantByName, MenuPrefix.Saas) }, { nameof(TableNameEnum.GlobalSearch), (TablePrefix.TenantByName, MenuPrefix.Saas) }, - { nameof(TableNameEnum.CustomEntity), (TablePrefix.TenantByName, MenuPrefix.Saas) }, - { nameof(TableNameEnum.CustomEntityField), (TablePrefix.TenantByName, MenuPrefix.Saas) }, - { nameof(TableNameEnum.CrudMigration), (TablePrefix.TenantByName, MenuPrefix.Saas) }, + { nameof(TableNameEnum.SqlTable), (TablePrefix.TenantByName, MenuPrefix.Saas) }, + { nameof(TableNameEnum.SqlTableField), (TablePrefix.TenantByName, MenuPrefix.Saas) }, { nameof(TableNameEnum.CrudEndpoint), (TablePrefix.TenantByName, MenuPrefix.Saas) }, { nameof(TableNameEnum.CustomEndpoint), (TablePrefix.TenantByName, MenuPrefix.Saas) }, { nameof(TableNameEnum.CustomComponent), (TablePrefix.TenantByName, MenuPrefix.Saas) }, diff --git a/api/src/Sozsoft.Platform.Domain/DeveloperKit/IApiMigrationRepository.cs b/api/src/Sozsoft.Platform.Domain/DeveloperKit/IApiMigrationRepository.cs deleted file mode 100644 index c91d32b..0000000 --- a/api/src/Sozsoft.Platform.Domain/DeveloperKit/IApiMigrationRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Threading.Tasks; -using Sozsoft.Platform.Entities; -using Volo.Abp.Domain.Repositories; - -namespace Sozsoft.Platform.Domain.DeveloperKit; - -public interface IApiMigrationRepository : IRepository -{ - Task ExecuteSqlAsync(string sql); -} - diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudEndpoint.cs b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudEndpoint.cs index c14c98e..b0f5dec 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudEndpoint.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudEndpoint.cs @@ -15,9 +15,9 @@ public class CrudEndpoint : FullAuditedEntity, IMultiTenant public string CsharpCode { get; set; } = string.Empty; public bool IsActive { get; set; } = true; - // Foreign key to CustomEntity + // Foreign key to SqlTable public Guid EntityId { get; set; } - public virtual CustomEntity Entity { get; set; } = null!; + public virtual SqlTable Entity { get; set; } = null!; public CrudEndpoint() { Id = Guid.NewGuid(); diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudMigration.cs b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudMigration.cs deleted file mode 100644 index 56d20bb..0000000 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CrudMigration.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; - -namespace Sozsoft.Platform.Entities; - -public class CrudMigration : AuditedEntity, IMultiTenant -{ - public virtual Guid? TenantId { get; protected set; } - - public Guid EntityId { get; set; } - public string EntityName { get; set; } = string.Empty; - public string FileName { get; set; } = string.Empty; - public string SqlScript { get; set; } = string.Empty; - public string Status { get; set; } = "Askıda"; // "pending" | "applied" | "failed" - public DateTime? AppliedAt { get; set; } - public string? ErrorMessage { get; set; } - public virtual CustomEntity Entity { get; set; } = null!; -} diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomEntity.cs b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/SqlTable.cs similarity index 72% rename from api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomEntity.cs rename to api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/SqlTable.cs index dcf930c..1748eee 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/CustomEntity.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/DeveloperKit/SqlTable.cs @@ -5,7 +5,7 @@ using Volo.Abp.MultiTenancy; namespace Sozsoft.Platform.Entities; -public class CustomEntity : FullAuditedEntity, IMultiTenant +public class SqlTable : FullAuditedEntity, IMultiTenant { public virtual Guid? TenantId { get; protected set; } @@ -17,19 +17,17 @@ public class CustomEntity : FullAuditedEntity, IMultiTenant public bool IsActive { get; set; } = true; public bool IsFullAuditedEntity { get; set; } = true; public bool IsMultiTenant { get; set; } = false; - public string MigrationStatus { get; set; } = "Askıda"; - public Guid? MigrationId { get; set; } - public string EndpointStatus { get; set; } = "Askıda"; // "pending" | "applied" | "failed" + public string EndpointStatus { get; set; } = "pending"; // "pending" | "applied" | "failed" - public virtual ICollection Fields { get; set; } = []; + public virtual ICollection Fields { get; set; } = []; - public CustomEntity() + public SqlTable() { Id = Guid.NewGuid(); // Burada erişim mümkün çünkü sınıfın içi } } -public class CustomEntityField : FullAuditedEntity +public class SqlTableField : FullAuditedEntity { public Guid EntityId { get; set; } = Guid.NewGuid(); public string Name { get; set; } = string.Empty; @@ -41,9 +39,9 @@ public class CustomEntityField : FullAuditedEntity public string? Description { get; set; } public int DisplayOrder { get; set; } = 0; - public virtual CustomEntity Entity { get; set; } = null!; + public virtual SqlTable Entity { get; set; } = null!; - public CustomEntityField() + public SqlTableField() { Id = Guid.NewGuid(); // Burada erişim mümkün çünkü sınıfın içi } diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformApiMigrationRepository.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformApiMigrationRepository.cs deleted file mode 100644 index 1d06525..0000000 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformApiMigrationRepository.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Threading.Tasks; -using Sozsoft.Platform.Entities; -using Sozsoft.Platform.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Domain.Repositories.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore; - -namespace Sozsoft.Platform.Domain.DeveloperKit; - -public class PlatformApiMigrationRepository : EfCoreRepository, IApiMigrationRepository -{ - public PlatformApiMigrationRepository(IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } - - public async Task ExecuteSqlAsync(string sql) - { - var dbContext = await GetDbContextAsync(); - await dbContext.Database.ExecuteSqlRawAsync(sql); - } -} - diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformDynamicEntityManager.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformDynamicEntityManager.cs index db05cd0..49bc8c6 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformDynamicEntityManager.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/DeveloperKit/PlatformDynamicEntityManager.cs @@ -15,14 +15,14 @@ using Volo.Abp.EntityFrameworkCore; public class DynamicEntityManager : IDynamicEntityManager { private readonly IDbContextProvider _dbContextProvider; - private readonly IRepository _customEntityRepository; + private readonly IRepository _sqlTableRepository; public DynamicEntityManager( IDbContextProvider dbContextProvider, - IRepository customEntityRepository) + IRepository sqlTableRepository) { _dbContextProvider = dbContextProvider; - _customEntityRepository = customEntityRepository; + _sqlTableRepository = sqlTableRepository; } public async Task?> GetEntityListAsync(string entityName) @@ -167,9 +167,9 @@ public class DynamicEntityManager : IDynamicEntityManager } } - private async Task GetEntityDefinitionAsync(string entityName) + private async Task GetEntityDefinitionAsync(string entityName) { - var queryable = await _customEntityRepository.WithDetailsAsync(x => x.Fields); + var queryable = await _sqlTableRepository.WithDetailsAsync(x => x.Fields); var entity = await queryable.FirstOrDefaultAsync(x => x.Name.ToLower() == entityName.ToLower()); return entity ?? throw new UserFriendlyException($"Entity '{entityName}' not found."); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index e22e45a..795ba3d 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -58,9 +58,8 @@ public class PlatformDbContext : public DbSet ForumCategories { get; set; } public DbSet ForumTopics { get; set; } public DbSet ForumPosts { get; set; } - public DbSet CustomEntities { get; set; } - public DbSet EntityFields { get; set; } - public DbSet Migrations { get; set; } + public DbSet CustomEntities { get; set; } + public DbSet EntityFields { get; set; } public DbSet GeneratedEndpoints { get; set; } public DbSet CustomEndpoints { get; set; } public DbSet CustomComponents { get; set; } @@ -516,9 +515,9 @@ public class PlatformDbContext : .OnDelete(DeleteBehavior.Restrict); }); - builder.Entity(b => + builder.Entity(b => { - b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.CustomEntity)), Prefix.DbSchema); + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.SqlTable)), Prefix.DbSchema); b.ConfigureByConvention(); b.HasKey(x => x.Id); @@ -526,7 +525,6 @@ public class PlatformDbContext : b.Property(x => x.DisplayName).IsRequired().HasMaxLength(128); b.Property(x => x.TableName).IsRequired().HasMaxLength(128); b.Property(x => x.Description).HasMaxLength(512); - b.Property(x => x.MigrationStatus).IsRequired().HasMaxLength(64); b.Property(x => x.EndpointStatus).IsRequired().HasMaxLength(64); b.Property(x => x.Menu).IsRequired().HasMaxLength(128); @@ -536,9 +534,9 @@ public class PlatformDbContext : .OnDelete(DeleteBehavior.Cascade); }); - builder.Entity(b => + builder.Entity(b => { - b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.CustomEntityField)), Prefix.DbSchema); + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.SqlTableField)), Prefix.DbSchema); b.ConfigureByConvention(); b.HasKey(x => x.Id); @@ -548,24 +546,6 @@ public class PlatformDbContext : b.Property(x => x.DefaultValue).HasMaxLength(256); }); - builder.Entity(b => - { - b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.CrudMigration)), Prefix.DbSchema); - b.ConfigureByConvention(); - - b.HasKey(x => x.Id); - b.Property(x => x.EntityName).IsRequired().HasMaxLength(128); - b.Property(x => x.FileName).IsRequired().HasMaxLength(256); - b.Property(x => x.SqlScript).IsRequired(); - b.Property(x => x.Status).IsRequired().HasMaxLength(64); - b.Property(x => x.ErrorMessage).HasMaxLength(1024); - - b.HasOne(x => x.Entity) - .WithMany() - .HasForeignKey(x => x.EntityId) - .OnDelete(DeleteBehavior.Restrict); - }); - builder.Entity(b => { b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.CrudEndpoint)), Prefix.DbSchema); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301173343_Initial.Designer.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301203437_Initial.Designer.cs similarity index 98% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301173343_Initial.Designer.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301203437_Initial.Designer.cs index 1b02102..46df41d 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301173343_Initial.Designer.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301203437_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Sozsoft.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20260301173343_Initial")] + [Migration("20260301203437_Initial")] partial class Initial { /// @@ -1419,67 +1419,6 @@ namespace Sozsoft.Platform.Migrations b.ToTable("Sas_T_CrudEndpoint", (string)null); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CrudMigration", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AppliedAt") - .HasColumnType("datetime2"); - - b.Property("CreationTime") - .HasColumnType("datetime2") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("uniqueidentifier") - .HasColumnName("CreatorId"); - - b.Property("EntityId") - .HasColumnType("uniqueidentifier"); - - b.Property("EntityName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("ErrorMessage") - .HasMaxLength(1024) - .HasColumnType("nvarchar(1024)"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("LastModificationTime") - .HasColumnType("datetime2") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("uniqueidentifier") - .HasColumnName("LastModifierId"); - - b.Property("SqlScript") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("EntityId"); - - b.ToTable("Sas_T_CrudMigration", (string)null); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.Currency", b => { b.Property("Id") @@ -1688,171 +1627,6 @@ namespace Sozsoft.Platform.Migrations b.ToTable("Sas_T_CustomEndpoint", (string)null); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntity", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnType("datetime2") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("uniqueidentifier") - .HasColumnName("CreatorId"); - - b.Property("DeleterId") - .HasColumnType("uniqueidentifier") - .HasColumnName("DeleterId"); - - b.Property("DeletionTime") - .HasColumnType("datetime2") - .HasColumnName("DeletionTime"); - - b.Property("Description") - .HasMaxLength(512) - .HasColumnType("nvarchar(512)"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("EndpointStatus") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("IsActive") - .HasColumnType("bit"); - - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(false) - .HasColumnName("IsDeleted"); - - b.Property("IsFullAuditedEntity") - .HasColumnType("bit"); - - b.Property("IsMultiTenant") - .HasColumnType("bit"); - - b.Property("LastModificationTime") - .HasColumnType("datetime2") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("uniqueidentifier") - .HasColumnName("LastModifierId"); - - b.Property("Menu") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("MigrationId") - .HasColumnType("uniqueidentifier"); - - b.Property("MigrationStatus") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("TableName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.ToTable("Sas_T_CustomEntity", (string)null); - }); - - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntityField", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnType("datetime2") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("uniqueidentifier") - .HasColumnName("CreatorId"); - - b.Property("DefaultValue") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("DeleterId") - .HasColumnType("uniqueidentifier") - .HasColumnName("DeleterId"); - - b.Property("DeletionTime") - .HasColumnType("datetime2") - .HasColumnName("DeletionTime"); - - b.Property("Description") - .HasMaxLength(512) - .HasColumnType("nvarchar(512)"); - - b.Property("DisplayOrder") - .HasColumnType("int"); - - b.Property("EntityId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(false) - .HasColumnName("IsDeleted"); - - b.Property("IsRequired") - .HasColumnType("bit"); - - b.Property("IsUnique") - .HasColumnType("bit"); - - b.Property("LastModificationTime") - .HasColumnType("datetime2") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("uniqueidentifier") - .HasColumnName("LastModifierId"); - - b.Property("MaxLength") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.HasKey("Id"); - - b.HasIndex("EntityId"); - - b.ToTable("Sas_T_CustomEntityField", (string)null); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.DataSource", b => { b.Property("Id") @@ -4001,6 +3775,163 @@ namespace Sozsoft.Platform.Migrations b.ToTable("Adm_T_SkillType", (string)null); }); + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTable", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("EndpointStatus") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsFullAuditedEntity") + .HasColumnType("bit"); + + b.Property("IsMultiTenant") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Menu") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TableName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("Sas_T_SqlTable", (string)null); + }); + + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTableField", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("DisplayOrder") + .HasColumnType("int"); + + b.Property("EntityId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsRequired") + .HasColumnType("bit"); + + b.Property("IsUnique") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaxLength") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("EntityId"); + + b.ToTable("Sas_T_SqlTableField", (string)null); + }); + modelBuilder.Entity("Sozsoft.Platform.Entities.Uom", b => { b.Property("Id") @@ -4663,7 +4594,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SchemaName", "FunctionName"); - b.ToTable("Sqm_T_SqlFunction", (string)null); + b.ToTable("Sas_T_SqlFunction", (string)null); }); modelBuilder.Entity("Sozsoft.SqlQueryManager.Domain.Entities.SqlQuery", b => @@ -4763,7 +4694,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("Status"); - b.ToTable("Sqm_T_SqlQuery", (string)null); + b.ToTable("Sas_T_SqlQuery", (string)null); }); modelBuilder.Entity("Sozsoft.SqlQueryManager.Domain.Entities.SqlStoredProcedure", b => @@ -4861,7 +4792,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SchemaName", "ProcedureName"); - b.ToTable("Sqm_T_SqlStoredProcedure", (string)null); + b.ToTable("Sas_T_SqlStoredProcedure", (string)null); }); modelBuilder.Entity("Sozsoft.SqlQueryManager.Domain.Entities.SqlView", b => @@ -4958,7 +4889,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SchemaName", "ViewName"); - b.ToTable("Sqm_T_SqlView", (string)null); + b.ToTable("Sas_T_SqlView", (string)null); }); modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => @@ -6879,7 +6810,7 @@ namespace Sozsoft.Platform.Migrations modelBuilder.Entity("Sozsoft.Platform.Entities.CrudEndpoint", b => { - b.HasOne("Sozsoft.Platform.Entities.CustomEntity", "Entity") + b.HasOne("Sozsoft.Platform.Entities.SqlTable", "Entity") .WithMany() .HasForeignKey("EntityId") .OnDelete(DeleteBehavior.Cascade) @@ -6888,28 +6819,6 @@ namespace Sozsoft.Platform.Migrations b.Navigation("Entity"); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CrudMigration", b => - { - b.HasOne("Sozsoft.Platform.Entities.CustomEntity", "Entity") - .WithMany() - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Entity"); - }); - - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntityField", b => - { - b.HasOne("Sozsoft.Platform.Entities.CustomEntity", "Entity") - .WithMany("Fields") - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Entity"); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.District", b => { b.HasOne("Sozsoft.Platform.Entities.City", null) @@ -7000,6 +6909,17 @@ namespace Sozsoft.Platform.Migrations b.Navigation("SkillType"); }); + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTableField", b => + { + b.HasOne("Sozsoft.Platform.Entities.SqlTable", "Entity") + .WithMany("Fields") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Entity"); + }); + modelBuilder.Entity("Sozsoft.Platform.Entities.Uom", b => { b.HasOne("Sozsoft.Platform.Entities.UomCategory", "UomCategory") @@ -7222,11 +7142,6 @@ namespace Sozsoft.Platform.Migrations b.Navigation("Cities"); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntity", b => - { - b.Navigation("Fields"); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.Order", b => { b.Navigation("Items"); @@ -7244,6 +7159,11 @@ namespace Sozsoft.Platform.Migrations b.Navigation("Skills"); }); + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTable", b => + { + b.Navigation("Fields"); + }); + modelBuilder.Entity("Sozsoft.Platform.Entities.UomCategory", b => { b.Navigation("Uoms"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301173343_Initial.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301203437_Initial.cs similarity index 97% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301173343_Initial.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301203437_Initial.cs index 9cd72c5..94bea2c 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301173343_Initial.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260301203437_Initial.cs @@ -1362,36 +1362,6 @@ namespace Sozsoft.Platform.Migrations table.PrimaryKey("PK_Sas_T_CustomEndpoint", x => x.Id); }); - migrationBuilder.CreateTable( - name: "Sas_T_CustomEntity", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Menu = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - TableName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Description = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - IsActive = table.Column(type: "bit", nullable: false), - IsFullAuditedEntity = table.Column(type: "bit", nullable: false), - IsMultiTenant = table.Column(type: "bit", nullable: false), - MigrationStatus = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - MigrationId = table.Column(type: "uniqueidentifier", nullable: true), - EndpointStatus = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Sas_T_CustomEntity", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Sas_T_DynamicService", columns: table => new @@ -1531,7 +1501,7 @@ namespace Sozsoft.Platform.Migrations }); migrationBuilder.CreateTable( - name: "Sqm_T_SqlFunction", + name: "Sas_T_SqlFunction", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), @@ -1559,11 +1529,11 @@ namespace Sozsoft.Platform.Migrations }, constraints: table => { - table.PrimaryKey("PK_Sqm_T_SqlFunction", x => x.Id); + table.PrimaryKey("PK_Sas_T_SqlFunction", x => x.Id); }); migrationBuilder.CreateTable( - name: "Sqm_T_SqlQuery", + name: "Sas_T_SqlQuery", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), @@ -1590,11 +1560,11 @@ namespace Sozsoft.Platform.Migrations }, constraints: table => { - table.PrimaryKey("PK_Sqm_T_SqlQuery", x => x.Id); + table.PrimaryKey("PK_Sas_T_SqlQuery", x => x.Id); }); migrationBuilder.CreateTable( - name: "Sqm_T_SqlStoredProcedure", + name: "Sas_T_SqlStoredProcedure", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), @@ -1620,11 +1590,39 @@ namespace Sozsoft.Platform.Migrations }, constraints: table => { - table.PrimaryKey("PK_Sqm_T_SqlStoredProcedure", x => x.Id); + table.PrimaryKey("PK_Sas_T_SqlStoredProcedure", x => x.Id); }); migrationBuilder.CreateTable( - name: "Sqm_T_SqlView", + name: "Sas_T_SqlTable", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Menu = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + TableName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Description = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + IsActive = table.Column(type: "bit", nullable: false), + IsFullAuditedEntity = table.Column(type: "bit", nullable: false), + IsMultiTenant = table.Column(type: "bit", nullable: false), + EndpointStatus = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Sas_T_SqlTable", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Sas_T_SqlView", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), @@ -1650,7 +1648,7 @@ namespace Sozsoft.Platform.Migrations }, constraints: table => { - table.PrimaryKey("PK_Sqm_T_SqlView", x => x.Id); + table.PrimaryKey("PK_Sas_T_SqlView", x => x.Id); }); migrationBuilder.CreateTable( @@ -2376,100 +2374,6 @@ namespace Sozsoft.Platform.Migrations onDelete: ReferentialAction.Restrict); }); - migrationBuilder.CreateTable( - name: "Sas_T_CrudEndpoint", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Method = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: false), - Path = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - OperationType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - CsharpCode = table.Column(type: "nvarchar(max)", nullable: false), - IsActive = table.Column(type: "bit", nullable: false), - EntityId = table.Column(type: "uniqueidentifier", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Sas_T_CrudEndpoint", x => x.Id); - table.ForeignKey( - name: "FK_Sas_T_CrudEndpoint_Sas_T_CustomEntity_EntityId", - column: x => x.EntityId, - principalTable: "Sas_T_CustomEntity", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Sas_T_CrudMigration", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityId = table.Column(type: "uniqueidentifier", nullable: false), - EntityName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - FileName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - SqlScript = table.Column(type: "nvarchar(max)", nullable: false), - Status = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - AppliedAt = table.Column(type: "datetime2", nullable: true), - ErrorMessage = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Sas_T_CrudMigration", x => x.Id); - table.ForeignKey( - name: "FK_Sas_T_CrudMigration_Sas_T_CustomEntity_EntityId", - column: x => x.EntityId, - principalTable: "Sas_T_CustomEntity", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Sas_T_CustomEntityField", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - EntityId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Type = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - IsRequired = table.Column(type: "bit", nullable: false), - MaxLength = table.Column(type: "int", nullable: true), - IsUnique = table.Column(type: "bit", nullable: false), - DefaultValue = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Description = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - DisplayOrder = table.Column(type: "int", nullable: false), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Sas_T_CustomEntityField", x => x.Id); - table.ForeignKey( - name: "FK_Sas_T_CustomEntityField_Sas_T_CustomEntity_EntityId", - column: x => x.EntityId, - principalTable: "Sas_T_CustomEntity", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "Sas_T_ReportTemplate", columns: table => new @@ -2500,6 +2404,71 @@ namespace Sozsoft.Platform.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "Sas_T_CrudEndpoint", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Method = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: false), + Path = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + OperationType = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + CsharpCode = table.Column(type: "nvarchar(max)", nullable: false), + IsActive = table.Column(type: "bit", nullable: false), + EntityId = table.Column(type: "uniqueidentifier", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Sas_T_CrudEndpoint", x => x.Id); + table.ForeignKey( + name: "FK_Sas_T_CrudEndpoint_Sas_T_SqlTable_EntityId", + column: x => x.EntityId, + principalTable: "Sas_T_SqlTable", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Sas_T_SqlTableField", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + EntityId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Type = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + IsRequired = table.Column(type: "bit", nullable: false), + MaxLength = table.Column(type: "int", nullable: true), + IsUnique = table.Column(type: "bit", nullable: false), + DefaultValue = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Description = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + DisplayOrder = table.Column(type: "int", nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Sas_T_SqlTableField", x => x.Id); + table.ForeignKey( + name: "FK_Sas_T_SqlTableField_Sas_T_SqlTable_EntityId", + column: x => x.EntityId, + principalTable: "Sas_T_SqlTable", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "AbpEntityPropertyChanges", columns: table => new @@ -3148,104 +3117,99 @@ namespace Sozsoft.Platform.Migrations table: "Sas_T_CrudEndpoint", column: "EntityId"); - migrationBuilder.CreateIndex( - name: "IX_Sas_T_CrudMigration_EntityId", - table: "Sas_T_CrudMigration", - column: "EntityId"); - - migrationBuilder.CreateIndex( - name: "IX_Sas_T_CustomEntityField_EntityId", - table: "Sas_T_CustomEntityField", - column: "EntityId"); - migrationBuilder.CreateIndex( name: "IX_Sas_T_ReportTemplate_CategoryId", table: "Sas_T_ReportTemplate", column: "CategoryId"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlFunction_DataSourceCode", - table: "Sqm_T_SqlFunction", + name: "IX_Sas_T_SqlFunction_DataSourceCode", + table: "Sas_T_SqlFunction", column: "DataSourceCode"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlFunction_FunctionType", - table: "Sqm_T_SqlFunction", + name: "IX_Sas_T_SqlFunction_FunctionType", + table: "Sas_T_SqlFunction", column: "FunctionType"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlFunction_IsDeployed", - table: "Sqm_T_SqlFunction", + name: "IX_Sas_T_SqlFunction_IsDeployed", + table: "Sas_T_SqlFunction", column: "IsDeployed"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlFunction_SchemaName_FunctionName", - table: "Sqm_T_SqlFunction", + name: "IX_Sas_T_SqlFunction_SchemaName_FunctionName", + table: "Sas_T_SqlFunction", columns: new[] { "SchemaName", "FunctionName" }); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlFunction_Status", - table: "Sqm_T_SqlFunction", + name: "IX_Sas_T_SqlFunction_Status", + table: "Sas_T_SqlFunction", column: "Status"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlQuery_Category", - table: "Sqm_T_SqlQuery", + name: "IX_Sas_T_SqlQuery_Category", + table: "Sas_T_SqlQuery", column: "Category"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlQuery_Code", - table: "Sqm_T_SqlQuery", + name: "IX_Sas_T_SqlQuery_Code", + table: "Sas_T_SqlQuery", column: "Code"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlQuery_DataSourceCode", - table: "Sqm_T_SqlQuery", + name: "IX_Sas_T_SqlQuery_DataSourceCode", + table: "Sas_T_SqlQuery", column: "DataSourceCode"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlQuery_Status", - table: "Sqm_T_SqlQuery", + name: "IX_Sas_T_SqlQuery_Status", + table: "Sas_T_SqlQuery", column: "Status"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlStoredProcedure_DataSourceCode", - table: "Sqm_T_SqlStoredProcedure", + name: "IX_Sas_T_SqlStoredProcedure_DataSourceCode", + table: "Sas_T_SqlStoredProcedure", column: "DataSourceCode"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlStoredProcedure_IsDeployed", - table: "Sqm_T_SqlStoredProcedure", + name: "IX_Sas_T_SqlStoredProcedure_IsDeployed", + table: "Sas_T_SqlStoredProcedure", column: "IsDeployed"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlStoredProcedure_SchemaName_ProcedureName", - table: "Sqm_T_SqlStoredProcedure", + name: "IX_Sas_T_SqlStoredProcedure_SchemaName_ProcedureName", + table: "Sas_T_SqlStoredProcedure", columns: new[] { "SchemaName", "ProcedureName" }); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlStoredProcedure_Status", - table: "Sqm_T_SqlStoredProcedure", + name: "IX_Sas_T_SqlStoredProcedure_Status", + table: "Sas_T_SqlStoredProcedure", column: "Status"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlView_DataSourceCode", - table: "Sqm_T_SqlView", + name: "IX_Sas_T_SqlTableField_EntityId", + table: "Sas_T_SqlTableField", + column: "EntityId"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_T_SqlView_DataSourceCode", + table: "Sas_T_SqlView", column: "DataSourceCode"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlView_IsDeployed", - table: "Sqm_T_SqlView", + name: "IX_Sas_T_SqlView_IsDeployed", + table: "Sas_T_SqlView", column: "IsDeployed"); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlView_SchemaName_ViewName", - table: "Sqm_T_SqlView", + name: "IX_Sas_T_SqlView_SchemaName_ViewName", + table: "Sas_T_SqlView", columns: new[] { "SchemaName", "ViewName" }); migrationBuilder.CreateIndex( - name: "IX_Sqm_T_SqlView_Status", - table: "Sqm_T_SqlView", + name: "IX_Sas_T_SqlView_Status", + table: "Sas_T_SqlView", column: "Status"); } @@ -3426,18 +3390,12 @@ namespace Sozsoft.Platform.Migrations migrationBuilder.DropTable( name: "Sas_T_CrudEndpoint"); - migrationBuilder.DropTable( - name: "Sas_T_CrudMigration"); - migrationBuilder.DropTable( name: "Sas_T_CustomComponent"); migrationBuilder.DropTable( name: "Sas_T_CustomEndpoint"); - migrationBuilder.DropTable( - name: "Sas_T_CustomEntityField"); - migrationBuilder.DropTable( name: "Sas_T_DynamicService"); @@ -3457,16 +3415,19 @@ namespace Sozsoft.Platform.Migrations name: "Sas_T_Sector"); migrationBuilder.DropTable( - name: "Sqm_T_SqlFunction"); + name: "Sas_T_SqlFunction"); migrationBuilder.DropTable( - name: "Sqm_T_SqlQuery"); + name: "Sas_T_SqlQuery"); migrationBuilder.DropTable( - name: "Sqm_T_SqlStoredProcedure"); + name: "Sas_T_SqlStoredProcedure"); migrationBuilder.DropTable( - name: "Sqm_T_SqlView"); + name: "Sas_T_SqlTableField"); + + migrationBuilder.DropTable( + name: "Sas_T_SqlView"); migrationBuilder.DropTable( name: "AbpEntityChanges"); @@ -3523,10 +3484,10 @@ namespace Sozsoft.Platform.Migrations name: "Sas_T_Branch"); migrationBuilder.DropTable( - name: "Sas_T_CustomEntity"); + name: "Sas_T_ReportCategory"); migrationBuilder.DropTable( - name: "Sas_T_ReportCategory"); + name: "Sas_T_SqlTable"); migrationBuilder.DropTable( name: "AbpAuditLogs"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index b9b13df..bf88778 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -1416,67 +1416,6 @@ namespace Sozsoft.Platform.Migrations b.ToTable("Sas_T_CrudEndpoint", (string)null); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CrudMigration", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AppliedAt") - .HasColumnType("datetime2"); - - b.Property("CreationTime") - .HasColumnType("datetime2") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("uniqueidentifier") - .HasColumnName("CreatorId"); - - b.Property("EntityId") - .HasColumnType("uniqueidentifier"); - - b.Property("EntityName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("ErrorMessage") - .HasMaxLength(1024) - .HasColumnType("nvarchar(1024)"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("LastModificationTime") - .HasColumnType("datetime2") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("uniqueidentifier") - .HasColumnName("LastModifierId"); - - b.Property("SqlScript") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("EntityId"); - - b.ToTable("Sas_T_CrudMigration", (string)null); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.Currency", b => { b.Property("Id") @@ -1685,171 +1624,6 @@ namespace Sozsoft.Platform.Migrations b.ToTable("Sas_T_CustomEndpoint", (string)null); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntity", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnType("datetime2") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("uniqueidentifier") - .HasColumnName("CreatorId"); - - b.Property("DeleterId") - .HasColumnType("uniqueidentifier") - .HasColumnName("DeleterId"); - - b.Property("DeletionTime") - .HasColumnType("datetime2") - .HasColumnName("DeletionTime"); - - b.Property("Description") - .HasMaxLength(512) - .HasColumnType("nvarchar(512)"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("EndpointStatus") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("IsActive") - .HasColumnType("bit"); - - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(false) - .HasColumnName("IsDeleted"); - - b.Property("IsFullAuditedEntity") - .HasColumnType("bit"); - - b.Property("IsMultiTenant") - .HasColumnType("bit"); - - b.Property("LastModificationTime") - .HasColumnType("datetime2") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("uniqueidentifier") - .HasColumnName("LastModifierId"); - - b.Property("Menu") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("MigrationId") - .HasColumnType("uniqueidentifier"); - - b.Property("MigrationStatus") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("TableName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("TenantId") - .HasColumnType("uniqueidentifier") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.ToTable("Sas_T_CustomEntity", (string)null); - }); - - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntityField", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnType("datetime2") - .HasColumnName("CreationTime"); - - b.Property("CreatorId") - .HasColumnType("uniqueidentifier") - .HasColumnName("CreatorId"); - - b.Property("DefaultValue") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("DeleterId") - .HasColumnType("uniqueidentifier") - .HasColumnName("DeleterId"); - - b.Property("DeletionTime") - .HasColumnType("datetime2") - .HasColumnName("DeletionTime"); - - b.Property("Description") - .HasMaxLength(512) - .HasColumnType("nvarchar(512)"); - - b.Property("DisplayOrder") - .HasColumnType("int"); - - b.Property("EntityId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnType("bit") - .HasDefaultValue(false) - .HasColumnName("IsDeleted"); - - b.Property("IsRequired") - .HasColumnType("bit"); - - b.Property("IsUnique") - .HasColumnType("bit"); - - b.Property("LastModificationTime") - .HasColumnType("datetime2") - .HasColumnName("LastModificationTime"); - - b.Property("LastModifierId") - .HasColumnType("uniqueidentifier") - .HasColumnName("LastModifierId"); - - b.Property("MaxLength") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.HasKey("Id"); - - b.HasIndex("EntityId"); - - b.ToTable("Sas_T_CustomEntityField", (string)null); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.DataSource", b => { b.Property("Id") @@ -3998,6 +3772,163 @@ namespace Sozsoft.Platform.Migrations b.ToTable("Adm_T_SkillType", (string)null); }); + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTable", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("EndpointStatus") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsFullAuditedEntity") + .HasColumnType("bit"); + + b.Property("IsMultiTenant") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Menu") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TableName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("Sas_T_SqlTable", (string)null); + }); + + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTableField", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("DisplayOrder") + .HasColumnType("int"); + + b.Property("EntityId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsRequired") + .HasColumnType("bit"); + + b.Property("IsUnique") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaxLength") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("EntityId"); + + b.ToTable("Sas_T_SqlTableField", (string)null); + }); + modelBuilder.Entity("Sozsoft.Platform.Entities.Uom", b => { b.Property("Id") @@ -4660,7 +4591,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SchemaName", "FunctionName"); - b.ToTable("Sqm_T_SqlFunction", (string)null); + b.ToTable("Sas_T_SqlFunction", (string)null); }); modelBuilder.Entity("Sozsoft.SqlQueryManager.Domain.Entities.SqlQuery", b => @@ -4760,7 +4691,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("Status"); - b.ToTable("Sqm_T_SqlQuery", (string)null); + b.ToTable("Sas_T_SqlQuery", (string)null); }); modelBuilder.Entity("Sozsoft.SqlQueryManager.Domain.Entities.SqlStoredProcedure", b => @@ -4858,7 +4789,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SchemaName", "ProcedureName"); - b.ToTable("Sqm_T_SqlStoredProcedure", (string)null); + b.ToTable("Sas_T_SqlStoredProcedure", (string)null); }); modelBuilder.Entity("Sozsoft.SqlQueryManager.Domain.Entities.SqlView", b => @@ -4955,7 +4886,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SchemaName", "ViewName"); - b.ToTable("Sqm_T_SqlView", (string)null); + b.ToTable("Sas_T_SqlView", (string)null); }); modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => @@ -6876,7 +6807,7 @@ namespace Sozsoft.Platform.Migrations modelBuilder.Entity("Sozsoft.Platform.Entities.CrudEndpoint", b => { - b.HasOne("Sozsoft.Platform.Entities.CustomEntity", "Entity") + b.HasOne("Sozsoft.Platform.Entities.SqlTable", "Entity") .WithMany() .HasForeignKey("EntityId") .OnDelete(DeleteBehavior.Cascade) @@ -6885,28 +6816,6 @@ namespace Sozsoft.Platform.Migrations b.Navigation("Entity"); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CrudMigration", b => - { - b.HasOne("Sozsoft.Platform.Entities.CustomEntity", "Entity") - .WithMany() - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Entity"); - }); - - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntityField", b => - { - b.HasOne("Sozsoft.Platform.Entities.CustomEntity", "Entity") - .WithMany("Fields") - .HasForeignKey("EntityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Entity"); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.District", b => { b.HasOne("Sozsoft.Platform.Entities.City", null) @@ -6997,6 +6906,17 @@ namespace Sozsoft.Platform.Migrations b.Navigation("SkillType"); }); + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTableField", b => + { + b.HasOne("Sozsoft.Platform.Entities.SqlTable", "Entity") + .WithMany("Fields") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Entity"); + }); + modelBuilder.Entity("Sozsoft.Platform.Entities.Uom", b => { b.HasOne("Sozsoft.Platform.Entities.UomCategory", "UomCategory") @@ -7219,11 +7139,6 @@ namespace Sozsoft.Platform.Migrations b.Navigation("Cities"); }); - modelBuilder.Entity("Sozsoft.Platform.Entities.CustomEntity", b => - { - b.Navigation("Fields"); - }); - modelBuilder.Entity("Sozsoft.Platform.Entities.Order", b => { b.Navigation("Items"); @@ -7241,6 +7156,11 @@ namespace Sozsoft.Platform.Migrations b.Navigation("Skills"); }); + modelBuilder.Entity("Sozsoft.Platform.Entities.SqlTable", b => + { + b.Navigation("Fields"); + }); + modelBuilder.Entity("Sozsoft.Platform.Entities.UomCategory", b => { b.Navigation("Uoms"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json b/api/src/Sozsoft.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json index c66cf85..eaf8a06 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json @@ -95,8 +95,8 @@ "dependencies": [] }, { - "name": "ProductListComponent", - "code": "const ProductListComponent = ({\n title = \"Product\"\n}) => {\n return (\n \n );\n};\n\nexport default ProductListComponent;", + "name": "RoleListComponent", + "code": "const RoleListComponent = ({\n title = \"AbpRoles\"\n}) => {\n return (\n \n );\n};\n\nexport default RoleListComponent;", "props": null, "description": null, "isActive": true, diff --git a/ui/src/components/developerKit/CrudEndpointManager.tsx b/ui/src/components/developerKit/CrudEndpointManager.tsx deleted file mode 100644 index 64801ba..0000000 --- a/ui/src/components/developerKit/CrudEndpointManager.tsx +++ /dev/null @@ -1,790 +0,0 @@ -import React, { useState } from 'react' -import { useEntities } from '../../contexts/EntityContext' -import axios from 'axios' -import { - FaBook, - FaSearch, - FaFilter, - FaGlobe, - FaCopy, - FaCheckCircle, - FaExclamationCircle, - FaDatabase, - FaSyncAlt, - FaPaperPlane, - FaPlusCircle, - FaEdit, - FaTrash, -} from 'react-icons/fa' -import { useLocalization } from '@/utils/hooks/useLocalization' - -interface EndpointType { - id: string - name: string - method: string - path: string - description?: string - type: 'generated' - operationType?: string - entityName?: string -} - -interface TestResult { - success: boolean - status: number - data?: unknown - error?: unknown - timestamp: string -} - -interface ParameterInput { - name: string - value: string - type: 'path' | 'query' | 'body' - required: boolean - description?: string -} - -const CrudEndpointManager: React.FC = () => { - const { generatedEndpoints } = useEntities() - const { translate } = useLocalization() - - const [searchTerm, setSearchTerm] = useState('') - const [filterMethod, setFilterMethod] = useState<'all' | 'GET' | 'POST' | 'PUT' | 'DELETE'>('all') - const [selectedEndpoint, setSelectedEndpoint] = useState(null) - const [testResults, setTestResults] = useState>({}) - const [loadingEndpoints, setLoadingEndpoints] = useState>(new Set()) - const [parameterValues, setParameterValues] = useState>>({}) - const [requestBodies, setRequestBodies] = useState>({}) - - // Only show generated CRUD endpoints - const allEndpoints: EndpointType[] = [ - ...generatedEndpoints - .filter((e) => e.isActive) - .map((e) => ({ - id: e.id, - name: `${e.entityName} ${e.operationType}`, - method: e.method, - path: e.path, - description: `${e.operationType} operation for ${e.entityName} entity`, - type: 'generated' as const, - operationType: e.operationType, - entityName: e.entityName, - })), - ] - - const filteredEndpoints = allEndpoints.filter((endpoint) => { - const matchesSearch = - endpoint.name.toLowerCase().includes(searchTerm.toLowerCase()) || - endpoint.path.toLowerCase().includes(searchTerm.toLowerCase()) || - (endpoint.description || '').toLowerCase().includes(searchTerm.toLowerCase()) - - const matchesMethodFilter = filterMethod === 'all' || endpoint.method === filterMethod - - return matchesSearch && matchesMethodFilter - }) - - const getMethodColor = (method: string) => { - switch (method) { - case 'GET': - return 'bg-blue-100 text-blue-800 border-blue-200' - case 'POST': - return 'bg-green-100 text-green-800 border-green-200' - case 'PUT': - return 'bg-yellow-100 text-yellow-800 border-yellow-200' - case 'DELETE': - return 'bg-red-100 text-red-800 border-red-200' - default: - return 'bg-slate-100 text-slate-800 border-slate-200' - } - } - - const getResponseExample = (endpoint: EndpointType) => { - switch (endpoint.operationType) { - case 'GetList': - case 'GetPaged': - return { - data: [ - { - id: '3fa85f64-5717-4562-b3fc-2c963f66afa6', - name: 'Sample Item', - creationTime: '2024-01-15T10:30:00Z', - }, - ], - totalCount: 1, - pageSize: 10, - currentPage: 1, - } - case 'GetById': - return { - id: '3fa85f64-5717-4562-b3fc-2c963f66afa6', - name: 'Sample Item', - creationTime: '2024-01-15T10:30:00Z', - lastModificationTime: '2024-01-15T10:30:00Z', - } - case 'Create': - case 'Update': - return { - id: '3fa85f64-5717-4562-b3fc-2c963f66afa6', - name: 'Sample Item', - creationTime: '2024-01-15T10:30:00Z', - lastModificationTime: '2024-01-15T10:30:00Z', - } - case 'Delete': - return { - success: true, - message: 'Item deleted successfully', - } - default: - return { - message: 'Hello from API!', - timestamp: '2024-01-15T10:30:00Z', - success: true, - } - } - } - - const getRequestExample = (endpoint: EndpointType) => { - if (endpoint.operationType === 'Create' || endpoint.operationType === 'Update') { - return { - Name: 'New Item', - Description: 'Item description', - IsActive: true, - } - } - return null - } - - const copyToClipboard = (text: string) => { - navigator.clipboard.writeText(text) - } - - // Get required parameters for each endpoint type - const getEndpointParameters = (endpoint: EndpointType): ParameterInput[] => { - const parameters: ParameterInput[] = [] - const currentValues = parameterValues[endpoint.id] || {} - - switch (endpoint.operationType) { - case 'GetById': - case 'Update': - case 'Delete': - parameters.push({ - name: 'id', - value: currentValues.id || '3fa85f64-5717-4562-b3fc-2c963f66afa6', - type: 'path', - required: true, - description: 'Unique identifier for the entity', - }) - break - case 'GetList': - case 'GetPaged': - parameters.push( - { - name: 'SkipCount', - value: currentValues.SkipCount || '0', - type: 'query', - required: false, - description: 'Number of records to skip', - }, - { - name: 'MaxResultCount', - value: currentValues.MaxResultCount || '10', - type: 'query', - required: false, - description: 'Maximum number of records to return', - }, - ) - break - } - - return parameters - } - - // Check if endpoint needs request body - const needsRequestBody = (endpoint: EndpointType): boolean => { - return endpoint.operationType === 'Create' || endpoint.operationType === 'Update' - } - - // Update parameter value - const updateParameterValue = (endpointId: string, paramName: string, value: string) => { - setParameterValues((prev) => ({ - ...prev, - [endpointId]: { - ...prev[endpointId], - [paramName]: value, - }, - })) - } - - // Update request body - const updateRequestBody = (endpointId: string, body: string) => { - setRequestBodies((prev) => ({ - ...prev, - [endpointId]: body, - })) - } - - // Initialize default values for endpoint when first opened - const initializeEndpointDefaults = (endpoint: EndpointType) => { - if (!parameterValues[endpoint.id]) { - const parameters = getEndpointParameters(endpoint) - const defaultValues: Record = {} - - parameters.forEach((param) => { - defaultValues[param.name] = param.value - }) - - setParameterValues((prev) => ({ - ...prev, - [endpoint.id]: defaultValues, - })) - } - - if (!requestBodies[endpoint.id] && needsRequestBody(endpoint)) { - const example = getRequestExample(endpoint) - if (example) { - setRequestBodies((prev) => ({ - ...prev, - [endpoint.id]: JSON.stringify(example, null, 2), - })) - } - } - } - - // Get current request body for endpoint - const getCurrentRequestBody = (endpoint: EndpointType): string => { - const stored = requestBodies[endpoint.id] - if (stored) return stored - - const example = getRequestExample(endpoint) - return example ? JSON.stringify(example, null, 2) : '' - } - - const testEndpoint = async (endpoint: EndpointType) => { - const endpointId = endpoint.id - - // Add to loading set - setLoadingEndpoints((prev) => new Set(prev).add(endpointId)) - - try { - let url = '' - const method = endpoint.method - let data = null - - // For generated endpoints, use the Crud API - url = `${import.meta.env.VITE_API_URL}/api/app/crudendpoint/${endpoint.entityName}` - - // Get parameters and modify URL based on operation type - const parameters = getEndpointParameters(endpoint) - const pathParams = parameters.filter((p) => p.type === 'path') - const queryParams = parameters.filter((p) => p.type === 'query') - - // Handle path parameters - if (pathParams.length > 0) { - const idParam = pathParams.find((p) => p.name === 'id') - if (idParam) { - url += `/${idParam.value}` - } - } - - // Handle query parameters - if (queryParams.length > 0) { - const queryString = queryParams - .filter((p) => p.value.trim() !== '') - .map((p) => `${p.name}=${encodeURIComponent(p.value)}`) - .join('&') - if (queryString) { - url += `?${queryString}` - } - } - - // Handle request body - if (needsRequestBody(endpoint)) { - const requestBodyText = getCurrentRequestBody(endpoint) - try { - data = requestBodyText ? JSON.parse(requestBodyText) : getRequestExample(endpoint) - } catch (e) { - throw new Error(`Invalid JSON in request body: ${e}`) - } - } - - const config = { - method, - url, - timeout: 10000, - headers: { - 'Content-Type': 'application/json', - }, - data: data || undefined, - } - - const response = await axios(config) - - setTestResults((prev) => ({ - ...prev, - [endpointId]: { - success: true, - status: response.status, - data: response.data, - timestamp: new Date().toISOString(), - }, - })) - } catch (error: unknown) { - const axiosError = error as { - response?: { status?: number; data?: unknown } - message?: string - } - setTestResults((prev) => ({ - ...prev, - [endpointId]: { - success: false, - status: axiosError.response?.status || 0, - error: axiosError.response?.data || axiosError.message, - timestamp: new Date().toISOString(), - }, - })) - } finally { - // Remove from loading set - setLoadingEndpoints((prev) => { - const newSet = new Set(prev) - newSet.delete(endpointId) - return newSet - }) - } - } - - const stats = { - total: allEndpoints.length, - custom: 0, // No more custom endpoints - generated: generatedEndpoints.filter((e) => e.isActive).length, - byMethod: { - GET: allEndpoints.filter((e) => e.method === 'GET').length, - POST: allEndpoints.filter((e) => e.method === 'POST').length, - PUT: allEndpoints.filter((e) => e.method === 'PUT').length, - DELETE: allEndpoints.filter((e) => e.method === 'DELETE').length, - }, - } - - return ( -
-
-
-

- {translate('::App.DeveloperKit.CrudEndpoints')} -

-

{translate('::App.DeveloperKit.Endpoint.Description')}

-
-
-
- - {translate('::App.DeveloperKit.Endpoint.SwaggerCompatible')} -
-
-
- - {/* Stats Cards */} -
-
-
-
-

- {translate('::App.DeveloperKit.Endpoint.GeneratedCrud')} -

-

{stats.generated}

-
-
- -
-
-
-
-
-
-

- {translate('::App.DeveloperKit.Endpoint.GetCount')} -

-

{stats.byMethod.GET}

-
-
- -
-
-
-
-
-
-

- {translate('::App.DeveloperKit.Endpoint.PostCount')} -

-

{stats.byMethod.POST}

-
-
- -
-
-
-
-
-
-

- {translate('::App.DeveloperKit.Endpoint.PutCount')} -

-

{stats.byMethod.PUT}

-
-
- -
-
-
-
-
-
-

- {translate('::App.DeveloperKit.Endpoint.DeleteCount')} -

-

{stats.byMethod.DELETE}

-
-
- -
-
-
-
- - {/* Filters */} -
-
- - setSearchTerm(e.target.value)} - className="w-full pl-10 pr-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" - /> -
-
-
- - -
-
-
- - {/* Endpoints List */} - {filteredEndpoints.length > 0 ? ( -
- {filteredEndpoints.map((endpoint) => ( -
-
{ - const newSelectedEndpoint = selectedEndpoint === endpoint.id ? null : endpoint.id - setSelectedEndpoint(newSelectedEndpoint) - if (newSelectedEndpoint === endpoint.id) { - initializeEndpointDefaults(endpoint) - } - }} - > -
- {/* Sol taraf */} -
- - {endpoint.method} - -
-

{endpoint.name}

-
-
- - {/* Sağ taraf */} -
-
- - - {translate('::App.Status.Active')} - -
-
-
- -
- - {endpoint.path} - - {endpoint.description && ( -

{endpoint.description}

- )} -
-
- - {/* Expanded Details */} - {selectedEndpoint === endpoint.id && ( -
-
- {/* Request Details */} -
-

- {translate('::App.DeveloperKit.Endpoint.RequestTitle')} -

-
-
- -
- - {endpoint.method} {endpoint.path} - - -
-
- - {/* Parameters Section */} - {getEndpointParameters(endpoint).length > 0 && ( -
- -
- {getEndpointParameters(endpoint).map((param) => ( -
-
- - {param.name} - - - {param.type} - - {param.required && ( - - {translate('::App.Required')} - - )} -
- {param.description && ( -

- {param.description} -

- )} - - updateParameterValue(endpoint.id, param.name, e.target.value) - } - placeholder={`Enter ${param.name}`} - className="w-full px-3 py-2 text-sm border border-slate-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-transparent" - /> -
- ))} -
-
- )} - - {/* Request Body Section */} - {needsRequestBody(endpoint) && ( -
- -
-