From 549bb1aa76742865e1d7eba9ef02ab40ee5a4f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Sun, 17 May 2026 21:20:44 +0300 Subject: [PATCH] Sequence --- .../ListForms/Dto/ColumnFormatDto.cs | 2 + .../ListForms/IListFormSelectAppService.cs | 1 + .../ListForms/ListFormSelectAppService.cs | 10 +- .../Seeds/LanguagesData.json | 64 ++- .../Seeds/ListFormSeeder_Administration.cs | 4 +- .../Seeds/ListFormSeeder_DefaultJsons.cs | 2 +- .../Seeds/ListFormSeeder_Saas.cs | 299 +++++++++++++ .../Seeds/MenusData.json | 10 + .../Seeds/PermissionsData.json | 66 ++- .../Enums/DefaultValueDict.cs | 8 + .../Enums/FieldCustomValueTypeEnum.cs | 1 + .../Enums/SequenceResetPeriodEnum.cs | 11 + .../Enums/TableNameEnum.cs | 3 +- .../TableNameResolver.cs | 1 + .../Data/SeedConsts.cs | 1 + .../Entities/Tenant/Saas/Sequence.cs | 132 ++++++ .../ListForms/ListFormManager.cs | 2 +- .../Queries/DefaultValueManager.cs | 26 +- .../Sequences/SequenceManager.cs | 59 +++ .../EntityFrameworkCore/PlatformDbContext.cs | 158 ++++--- ....cs => 20260517100701_Initial.Designer.cs} | 310 ++++++++++++-- ...1_Initial.cs => 20260517100701_Initial.cs} | 397 ++++++++++++++---- .../PlatformDbContextModelSnapshot.cs | 308 ++++++++++++-- .../Seeds/TenantData.json | 24 ++ .../Seeds/TenantDataSeeder.cs | 51 +++ ui/src/proxy/form/models.ts | 2 + ui/src/services/form.service.ts | 9 +- .../JsonRowOpDialogDatabase.tsx | 35 +- ui/src/views/admin/listForm/edit/options.ts | 1 + ui/src/views/list/Grid.tsx | 147 ++++--- 30 files changed, 1831 insertions(+), 313 deletions(-) create mode 100644 api/src/Sozsoft.Platform.Domain.Shared/Enums/DefaultValueDict.cs create mode 100644 api/src/Sozsoft.Platform.Domain.Shared/Enums/SequenceResetPeriodEnum.cs create mode 100644 api/src/Sozsoft.Platform.Domain/Entities/Tenant/Saas/Sequence.cs create mode 100644 api/src/Sozsoft.Platform.Domain/Sequences/SequenceManager.cs rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260511093511_Initial.Designer.cs => 20260517100701_Initial.Designer.cs} (97%) rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260511093511_Initial.cs => 20260517100701_Initial.cs} (95%) diff --git a/api/src/Sozsoft.Platform.Application.Contracts/ListForms/Dto/ColumnFormatDto.cs b/api/src/Sozsoft.Platform.Application.Contracts/ListForms/Dto/ColumnFormatDto.cs index db089b1..d8b7106 100644 --- a/api/src/Sozsoft.Platform.Application.Contracts/ListForms/Dto/ColumnFormatDto.cs +++ b/api/src/Sozsoft.Platform.Application.Contracts/ListForms/Dto/ColumnFormatDto.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Data; using System.Text.Json; using System.Text.Json.Serialization; +using Sozsoft.Platform.Enums; using Volo.Abp.Application.Dtos; namespace Sozsoft.Platform.ListForms; @@ -222,6 +223,7 @@ public class ColumnFormatDto : AuditedEntityDto public bool CanExport { get; set; } public object DefaultValue { get; set; } + public FieldCustomValueTypeEnum DefaultValueType { get; set; } [JsonIgnore] public string PivotSettingsJson { get; set; } diff --git a/api/src/Sozsoft.Platform.Application.Contracts/ListForms/IListFormSelectAppService.cs b/api/src/Sozsoft.Platform.Application.Contracts/ListForms/IListFormSelectAppService.cs index 8bc0d73..7e80904 100644 --- a/api/src/Sozsoft.Platform.Application.Contracts/ListForms/IListFormSelectAppService.cs +++ b/api/src/Sozsoft.Platform.Application.Contracts/ListForms/IListFormSelectAppService.cs @@ -6,5 +6,6 @@ public interface IListFormSelectAppService { Task GetSelectAsync(SelectRequestDto input); Task GetGridAsync(string ListFormCode); + Task GetNextSequenceValueAsync(string SequenceName); } diff --git a/api/src/Sozsoft.Platform.Application/ListForms/ListFormSelectAppService.cs b/api/src/Sozsoft.Platform.Application/ListForms/ListFormSelectAppService.cs index dd862f3..084671f 100644 --- a/api/src/Sozsoft.Platform.Application/ListForms/ListFormSelectAppService.cs +++ b/api/src/Sozsoft.Platform.Application/ListForms/ListFormSelectAppService.cs @@ -314,7 +314,8 @@ public class ListFormSelectAppService : PlatformAppService, IListFormSelectAppSe { if (columnFormatsDict.TryGetValue(field.Key, out var columnFormat)) { - columnFormat.DefaultValue = field.Value; + columnFormat.DefaultValue = field.Value.CustomValue; + columnFormat.DefaultValueType = field.Value.CustomValueType; } } @@ -397,6 +398,13 @@ public class ListFormSelectAppService : PlatformAppService, IListFormSelectAppSe return new List(); } + public async Task GetNextSequenceValueAsync(string SequenceName) + { + var sequenceManager = LazyServiceProvider.LazyGetRequiredService(); + + return await sequenceManager.GetNextSequenceAsync(SequenceName); + } + private static string WrapLookupQueryWithInFilter( string lookupQuery, string listFormSelectCommand, diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json index 6486d73..e35b670 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json @@ -948,6 +948,12 @@ "en": "No record found...", "tr": "Kayıt Bulunamadı..." }, + { + "resourceName": "Platform", + "key": "App.Definitions.Sequence", + "en": "Sequences", + "tr": "Diziler" + }, { "resourceName": "Platform", "key": "App.Definitions.OrgChart", @@ -1830,7 +1836,6 @@ "en": "Background Workers", "tr": "Arkaplan İşleri" }, - { "resourceName": "Platform", "key": "App.BackgroundWorkers.RecurringJobs", @@ -1843,7 +1848,6 @@ "en": "Jobs", "tr": "İşler" }, - { "resourceName": "Platform", "key": "App.Notifications", @@ -14620,6 +14624,60 @@ "en": "Is Active", "tr": "Aktif" }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.Prefix", + "en": "Prefix", + "tr": "Önek" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.Suffix", + "en": "Suffix", + "tr": "Sonek" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.PaddingSize", + "en": "Sequence Size", + "tr": "Sıra Boyutu" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.IncrementStep", + "en": "Increment Step", + "tr": "Artış Adımı" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.NextNumber", + "en": "Next Number", + "tr": "Sonraki Numara" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.StartNumber", + "en": "Start Number", + "tr": "Başlangıç Numarası" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.ResetPeriod", + "en": "Reset Period", + "tr": "Sıfırlama Dönemi" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.LastPeriodKey", + "en": "Last Period Key", + "tr": "Son Dönem Anahtarı" + }, + { + "resourceName": "Platform", + "key": "App.Listform.ListformField.FormatTemplate", + "en": "Format Template", + "tr": "Format Şablonu" + }, { "resourceName": "Platform", "key": "App.Listform.ListformField.MaxConcurrentUsers", @@ -18605,4 +18663,4 @@ "tr": "Başarıyla Kaydedildi" } ] -} +} \ No newline at end of file diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs index 57392a9..6366ef3 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Administration.cs @@ -1740,7 +1740,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep { ListFormCode = listForm.ListFormCode, CultureName = LanguageCodes.En, - SourceDbType = DbType.String, + SourceDbType = DbType.Guid, FieldName = "Id", CaptionName = "App.Listform.ListformField.Id", Width = 0, @@ -2527,7 +2527,7 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep PagerOptionJson = DefaultPagerOptionJson, TreeOptionJson = DefaultTreeOptionJson("Id", "ParentId", true), InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson(), - EditingOptionJson = DefaultEditingOptionJson(listFormName, 400, 650, true, true, true, true, false), + EditingOptionJson = DefaultEditingOptionJson(listFormName, 400, 350, true, true, true, true, false), EditingFormJson = JsonSerializer.Serialize(new List { new() { diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_DefaultJsons.cs b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_DefaultJsons.cs index bb8e00f..d33065f 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_DefaultJsons.cs +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_DefaultJsons.cs @@ -17,7 +17,7 @@ public static class ListFormSeeder_DefaultJsons public static string DefaultInsertFieldsDefaultValueJson(DbType dbType = DbType.Guid, string newId = "@NEWID") => JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { FieldName = "CreationTime", FieldDbType = DbType.DateTime, Value = "@NOW", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + new() { FieldName = "CreationTime", FieldDbType = DbType.DateTimeOffset, Value = "@NOW", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, new() { FieldName = "CreatorId", FieldDbType = DbType.Guid, Value = "@USERID", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, new() { FieldName = "Id", FieldDbType = dbType, Value = newId, CustomValueType = FieldCustomValueTypeEnum.CustomKey } }); diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs index e2173fe..141f4ae 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/ListFormSeeder_Saas.cs @@ -2466,6 +2466,305 @@ public class ListFormSeeder_Saas : IDataSeedContributor, ITransientDependency } #endregion + #region Sequence + listFormName = AppCodes.Definitions.Sequence; + if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == listFormName)) + { + var listForm = await _listFormRepository.InsertAsync( + new ListForm() + { + ListFormType = ListFormTypeEnum.List, + PageSize = 10, + ExportJson = DefaultExportJson, + IsSubForm = false, + ShowNote = true, + LayoutJson = DefaultLayoutJson(), + CultureName = LanguageCodes.En, + ListFormCode = listFormName, + Name = listFormName, + Title = listFormName, + DataSourceCode = SeedConsts.DataSources.DefaultCode, + IsTenant = false, + IsBranch = false, + IsOrganizationUnit = false, + Description = listFormName, + SelectCommandType = SelectCommandTypeEnum.Table, + SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Sequence)), + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + DefaultFilter = DefaultFilterJson, + SortMode = GridOptions.SortModeSingle, + FilterRowJson = DefaultFilterRowJson, + HeaderFilterJson = DefaultHeaderFilterJson, + SearchPanelJson = JsonSerializer.Serialize(new { Visible = false }), + GroupPanelJson = JsonSerializer.Serialize(new { Visible = false }), + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson(), + PermissionJson = DefaultPermissionJson(listFormName), + DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.Sequence)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson(), + PagerOptionJson = DefaultPagerOptionJson, + EditingOptionJson = DefaultEditingOptionJson(listFormName, 700, 500, true, true, true, true, false), + EditingFormJson = JsonSerializer.Serialize(new List + { + new() { + Order = 1, ColCount = 2, ColSpan = 1, ItemType = "group", Items = + [ + new EditingFormItemDto { Order = 1, DataField = "Name", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, + new EditingFormItemDto { Order = 2, DataField = "IsActive", ColSpan = 1, EditorType2 = EditorTypes.dxCheckBox }, + new EditingFormItemDto { Order = 3, DataField = "Prefix", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, + new EditingFormItemDto { Order = 4, DataField = "Suffix", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox }, + new EditingFormItemDto { Order = 5, DataField = "PaddingSize", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox }, + new EditingFormItemDto { Order = 6, DataField = "IncrementStep", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox }, + new EditingFormItemDto { Order = 7, DataField = "ResetPeriod", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions = EditorOptionValues.ShowClearButton }, + new EditingFormItemDto { Order = 8, DataField = "StartNumber", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox }, + new EditingFormItemDto { Order = 9, DataField = "FormatTemplate", ColSpan = 2, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, + ] + } + }), + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson(), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "IsActive", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "PaddingSize", FieldDbType = DbType.Int16, Value = "5", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "IncrementStep", FieldDbType = DbType.Int16, Value = "1", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "StartNumber", FieldDbType = DbType.Int16, Value = "1", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "FormatTemplate", FieldDbType = DbType.String, Value = "{Prefix}{Number}{Suffix}", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "ResetPeriod", FieldDbType = DbType.Int16, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value }, + }), + }); + + #region Sequence Fields + await _listFormFieldRepository.InsertManyAsync([ + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "Id", + CaptionName = "App.Listform.ListformField.Id", + Width = 0, + ListOrderNo = 1, + Visible = false, + IsActive = true, + + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Name", + CaptionName = "App.Listform.ListformField.Name", + Width = 0, + ListOrderNo = 2, + Visible = true, + IsActive = true, + + SortIndex = 1, + SortDirection = GridColumnOptions.SortOrderAsc, + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Prefix", + CaptionName = "App.Listform.ListformField.Prefix", + Width = 0, + ListOrderNo = 3, + Visible = true, + IsActive = true, + + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Suffix", + CaptionName = "App.Listform.ListformField.Suffix", + Width = 0, + ListOrderNo = 4, + Visible = true, + IsActive = true, + + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Boolean, + FieldName = "IsActive", + CaptionName = "App.Listform.ListformField.IsActive", + Width = 0, + ListOrderNo = 5, + Visible = true, + IsActive = true, + Alignment = "center", + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Int32, + FieldName = "PaddingSize", + CaptionName = "App.Listform.ListformField.PaddingSize", + Width = 0, + ListOrderNo = 6, + Visible = true, + IsActive = true, + + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Int32, + FieldName = "IncrementStep", + CaptionName = "App.Listform.ListformField.IncrementStep", + Width = 0, + ListOrderNo = 7, + Visible = true, + IsActive = true, + + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Int32, + FieldName = "NextNumber", + CaptionName = "App.Listform.ListformField.NextNumber", + Width = 0, + ListOrderNo = 8, + Visible = true, + IsActive = true, + + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Int32, + FieldName = "ResetPeriod", + CaptionName = "App.Listform.ListformField.ResetPeriod", + Width = 0, + ListOrderNo = 9, + Visible = true, + IsActive = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.StaticData, + DisplayExpr = "name", + ValueExpr = "key", + LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { + new() { Key=0, Name="None" }, + new() { Key=1, Name="Yearly"}, + new() { Key=2, Name="Monthly"}, + new() { Key=3, Name="Daily"}, + new() { Key=4, Name="Hourly"}, + new() { Key=5, Name="Minutely"}, + }), + }), + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Int32, + FieldName = "StartNumber", + CaptionName = "App.Listform.ListformField.StartNumber", + Width = 0, + ListOrderNo = 10, + Visible = true, + IsActive = true, + + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "LastPeriodKey", + CaptionName = "App.Listform.ListformField.LastPeriodKey", + Width = 0, + ListOrderNo = 11, + Visible = true, + IsActive = true, + + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() + { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "FormatTemplate", + CaptionName = "App.Listform.ListformField.FormatTemplate", + Width = 0, + ListOrderNo = 12, + Visible = true, + IsActive = true, + PlaceHolder="{Prefix}-{yyyy}{MM}{dd}-{Number}-{Suffix}", + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ]); + #endregion + } + #endregion + #region SkillType listFormName = AppCodes.Definitions.SkillType; if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == listFormName)) diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json index 97ff58a..a74edbe 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/MenusData.json @@ -578,6 +578,16 @@ "RequiredPermissionName": "App.Definitions.UomCategory", "IsDisabled": false }, + { + "ParentCode": "App.Saas.Definitions", + "Code": "App.Definitions.Sequence", + "DisplayName": "App.Definitions.Sequence", + "Order": 11, + "Url": "/admin/list/App.Definitions.Sequence", + "Icon": "FcNumericalSorting12", + "RequiredPermissionName": "App.Definitions.Sequence", + "IsDisabled": false + }, { "ParentCode": "App.Saas", "Code": "App.SettingDefinitions", diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json index 8d5b40a..c836c28 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json @@ -865,6 +865,60 @@ "MultiTenancySide": 2, "MenuGroup": "Erp|Kurs" }, + { + "GroupName": "App.Saas", + "Name": "App.Definitions.Sequence", + "ParentName": null, + "DisplayName": "App.Definitions.Sequence", + "IsEnabled": true, + "MultiTenancySide": 2, + "MenuGroup": "Erp|Kurs" + }, + { + "GroupName": "App.Saas", + "Name": "App.Definitions.Sequence.Create", + "ParentName": "App.Definitions.Sequence", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 2, + "MenuGroup": "Erp|Kurs" + }, + { + "GroupName": "App.Saas", + "Name": "App.Definitions.Sequence.Update", + "ParentName": "App.Definitions.Sequence", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 2, + "MenuGroup": "Erp|Kurs" + }, + { + "GroupName": "App.Saas", + "Name": "App.Definitions.Sequence.Delete", + "ParentName": "App.Definitions.Sequence", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 2, + "MenuGroup": "Erp|Kurs" + }, + { + "GroupName": "App.Saas", + "Name": "App.Definitions.Sequence.Export", + "ParentName": "App.Definitions.Sequence", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 2, + "MenuGroup": "Erp|Kurs" + }, + { + "GroupName": "App.Saas", + "Name": "App.Definitions.Sequence.Import", + "ParentName": "App.Definitions.Sequence", + "DisplayName": "Import", + "IsEnabled": true, + "MultiTenancySide": 2, + "MenuGroup": "Erp|Kurs" + }, { "GroupName": "App.Saas", "Name": "App.SettingDefinitions", @@ -1198,7 +1252,6 @@ "MultiTenancySide": 2, "MenuGroup": "Erp|Kurs" }, - { "GroupName": "App.Saas", "Name": "App.Notifications.NotificationTypes", @@ -1253,7 +1306,6 @@ "MultiTenancySide": 2, "MenuGroup": "Erp|Kurs" }, - { "GroupName": "App.Saas", "Name": "App.Notifications.NotificationRules", @@ -1416,7 +1468,6 @@ "MultiTenancySide": 2, "MenuGroup": "Erp|Kurs" }, - { "GroupName": "App.Saas", "Name": "App.BackgroundWorkers.Jobs", @@ -1471,7 +1522,6 @@ "MultiTenancySide": 2, "MenuGroup": "Erp|Kurs" }, - { "GroupName": "App.Saas", "Name": "App.Home", @@ -3650,7 +3700,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp|Kurs" }, - { "GroupName": "App.Administration", "Name": "App.Intranet.Events.EventLike", @@ -3714,7 +3763,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp|Kurs" }, - { "GroupName": "App.Administration", "Name": "App.Intranet.Announcement", @@ -4057,7 +4105,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp" }, - { "GroupName": "App.Administration", "Name": "App.Intranet.SurveyQuestionOption", @@ -4121,7 +4168,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp" }, - { "GroupName": "App.Administration", "Name": "App.Intranet.SurveyResponse", @@ -4185,7 +4231,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp" }, - { "GroupName": "App.Administration", "Name": "App.Intranet.SurveyAnswer", @@ -4249,7 +4294,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp" }, - { "GroupName": "App.Administration", "Name": "App.Videoroom", @@ -4287,4 +4331,4 @@ "MenuGroup": "Kurs" } ] -} +} \ No newline at end of file diff --git a/api/src/Sozsoft.Platform.Domain.Shared/Enums/DefaultValueDict.cs b/api/src/Sozsoft.Platform.Domain.Shared/Enums/DefaultValueDict.cs new file mode 100644 index 0000000..afdd4ed --- /dev/null +++ b/api/src/Sozsoft.Platform.Domain.Shared/Enums/DefaultValueDict.cs @@ -0,0 +1,8 @@ +namespace Sozsoft.Platform.Enums; + +public class DefaultValueDict +{ + public object CustomValue { get; set; } + public FieldCustomValueTypeEnum CustomValueType { get; set; } +} + diff --git a/api/src/Sozsoft.Platform.Domain.Shared/Enums/FieldCustomValueTypeEnum.cs b/api/src/Sozsoft.Platform.Domain.Shared/Enums/FieldCustomValueTypeEnum.cs index 83df483..71b8752 100644 --- a/api/src/Sozsoft.Platform.Domain.Shared/Enums/FieldCustomValueTypeEnum.cs +++ b/api/src/Sozsoft.Platform.Domain.Shared/Enums/FieldCustomValueTypeEnum.cs @@ -12,5 +12,6 @@ public enum FieldCustomValueTypeEnum /// DbQuery = 3, QueryParams = 4, + Sequence = 5 } diff --git a/api/src/Sozsoft.Platform.Domain.Shared/Enums/SequenceResetPeriodEnum.cs b/api/src/Sozsoft.Platform.Domain.Shared/Enums/SequenceResetPeriodEnum.cs new file mode 100644 index 0000000..669eef5 --- /dev/null +++ b/api/src/Sozsoft.Platform.Domain.Shared/Enums/SequenceResetPeriodEnum.cs @@ -0,0 +1,11 @@ +namespace Sozsoft.Platform.Enums; + +public enum SequenceResetPeriod +{ + None = 0, + Yearly = 1, + Monthly = 2, + Daily = 3, + Hourly = 4, + Minutely = 5 +} \ No newline at end of file diff --git a/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs b/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs index 85ebb42..436e67e 100644 --- a/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs +++ b/api/src/Sozsoft.Platform.Domain.Shared/Enums/TableNameEnum.cs @@ -87,5 +87,6 @@ public enum TableNameEnum Videoroom, VideoroomParticipant, VideoroomAttandance, - VideoroomChat + VideoroomChat, + Sequence, } diff --git a/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs b/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs index 79b6abe..caf7a63 100644 --- a/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs +++ b/api/src/Sozsoft.Platform.Domain.Shared/TableNameResolver.cs @@ -82,6 +82,7 @@ public static class TableNameResolver { nameof(TableNameEnum.VideoroomParticipant), (TablePrefix.TenantByName, MenuPrefix.Administration) }, { nameof(TableNameEnum.VideoroomAttandance), (TablePrefix.TenantByName, MenuPrefix.Administration) }, { nameof(TableNameEnum.VideoroomChat), (TablePrefix.TenantByName, MenuPrefix.Administration) }, + { nameof(TableNameEnum.Sequence), (TablePrefix.TenantByName, MenuPrefix.Administration) }, // 🔹 INTRANET TABLOLARI { nameof(TableNameEnum.Announcement), (TablePrefix.TenantByName, MenuPrefix.Administration) }, diff --git a/api/src/Sozsoft.Platform.Domain/Data/SeedConsts.cs b/api/src/Sozsoft.Platform.Domain/Data/SeedConsts.cs index 1a55a5f..bd98dc7 100644 --- a/api/src/Sozsoft.Platform.Domain/Data/SeedConsts.cs +++ b/api/src/Sozsoft.Platform.Domain/Data/SeedConsts.cs @@ -349,6 +349,7 @@ public static class SeedConsts public const string Default = Prefix.App + ".Definitions"; public const string AiBot = Default + ".AiBot"; + public const string Sequence = Default + ".Sequence"; public const string GlobalSearch = Default + ".GlobalSearch"; public const string ContactTitle = Default + ".ContactTitle"; public const string Currency = Default + ".Currency"; diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Saas/Sequence.cs b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Saas/Sequence.cs new file mode 100644 index 0000000..29e6bfa --- /dev/null +++ b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Saas/Sequence.cs @@ -0,0 +1,132 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; +using Sozsoft.Platform.Enums; + +public class Sequence : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public string Name { get; set; } = null!; + + public bool IsActive { get; set; } = true; + + public string? Prefix { get; set; } + + public string? Suffix { get; set; } + + public int PaddingSize { get; set; } = 5; + + public int IncrementStep { get; set; } = 1; + + public long StartNumber { get; set; } = 1; + + public long NextNumber { get; set; } = 1; + + public SequenceResetPeriod ResetPeriod { get; set; } = SequenceResetPeriod.None; + + public string? LastPeriodKey { get; set; } + + public string FormatTemplate { get; set; } = "{Prefix}{Number}{Suffix}"; + + public string GetNextSequence() + { + return GetNextSequence(DateTime.Now); + } + + public string GetNextSequence(DateTime dateTime) + { + ResetIfPeriodChanged(dateTime); + + var sequenceValue = FormatSequence(NextNumber, dateTime); + + NextNumber += IncrementStep; + + return sequenceValue; + } + + public string GetPreviewSequence() + { + return GetPreviewSequence(DateTime.Now); + } + + public string GetPreviewSequence(DateTime dateTime) + { + var previewNumber = NextNumber; + + if (ShouldReset(dateTime)) + { + previewNumber = StartNumber; + } + + return FormatSequence(previewNumber, dateTime); + } + + private void ResetIfPeriodChanged(DateTime dateTime) + { + if (!ShouldReset(dateTime)) + { + return; + } + + NextNumber = StartNumber; + LastPeriodKey = GetPeriodKey(dateTime); + } + + private bool ShouldReset(DateTime dateTime) + { + if (ResetPeriod == SequenceResetPeriod.None) + { + return false; + } + + var currentPeriodKey = GetPeriodKey(dateTime); + + return LastPeriodKey != currentPeriodKey; + } + + private string FormatSequence(long number, DateTime dateTime) + { + var template = string.IsNullOrWhiteSpace(FormatTemplate) + ? "{Prefix}{Number}{Suffix}" + : FormatTemplate; + + var numberText = number.ToString().PadLeft(PaddingSize, '0'); + + return template + .Replace("{Prefix}", Prefix ?? string.Empty) + .Replace("{Suffix}", Suffix ?? string.Empty) + .Replace("{Number}", numberText) + + .Replace("{yyyy}", dateTime.ToString("yyyy")) + .Replace("{yy}", dateTime.ToString("yy")) + + .Replace("{MM}", dateTime.ToString("MM")) + .Replace("{M}", dateTime.ToString("%M")) + + .Replace("{dd}", dateTime.ToString("dd")) + .Replace("{d}", dateTime.ToString("%d")) + + .Replace("{HH}", dateTime.ToString("HH")) + .Replace("{H}", dateTime.ToString("%H")) + + .Replace("{mm}", dateTime.ToString("mm")) + .Replace("{m}", dateTime.ToString("%m")) + + .Replace("{ss}", dateTime.ToString("ss")) + .Replace("{s}", dateTime.ToString("%s")); + } + + private string? GetPeriodKey(DateTime dateTime) + { + return ResetPeriod switch + { + SequenceResetPeriod.Yearly => dateTime.ToString("yyyy"), + SequenceResetPeriod.Monthly => dateTime.ToString("yyyyMM"), + SequenceResetPeriod.Daily => dateTime.ToString("yyyyMMdd"), + SequenceResetPeriod.Hourly => dateTime.ToString("yyyyMMddHH"), + SequenceResetPeriod.Minutely => dateTime.ToString("yyyyMMddHHmm"), + _ => null + }; + } +} \ No newline at end of file diff --git a/api/src/Sozsoft.Platform.Domain/ListForms/ListFormManager.cs b/api/src/Sozsoft.Platform.Domain/ListForms/ListFormManager.cs index 1a9c048..f1cea60 100644 --- a/api/src/Sozsoft.Platform.Domain/ListForms/ListFormManager.cs +++ b/api/src/Sozsoft.Platform.Domain/ListForms/ListFormManager.cs @@ -151,7 +151,7 @@ public class ListFormManager : PlatformDomainService, IListFormManager foreach (var item in defaultFields) { - fields[item.Key] = item.Value; + fields[item.Key] = item.Value.CustomValue; } return fields; diff --git a/api/src/Sozsoft.Platform.Domain/Queries/DefaultValueManager.cs b/api/src/Sozsoft.Platform.Domain/Queries/DefaultValueManager.cs index 291cbba..0263bc3 100644 --- a/api/src/Sozsoft.Platform.Domain/Queries/DefaultValueManager.cs +++ b/api/src/Sozsoft.Platform.Domain/Queries/DefaultValueManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text.Json; using System.Threading.Tasks; @@ -18,7 +19,7 @@ namespace Sozsoft.Platform.Queries; public interface IDefaultValueManager { - Task> GenerateDefaultValuesAsync( + Task> GenerateDefaultValuesAsync( ListForm listForm, List listFormFields, OperationEnum op, @@ -39,7 +40,7 @@ public class DefaultValueManager : PlatformDomainService, IDefaultValueManager { } - public async Task> GenerateDefaultValuesAsync( + public async Task> GenerateDefaultValuesAsync( ListForm listForm, List listFormFields, OperationEnum op, @@ -47,7 +48,7 @@ public class DefaultValueManager : PlatformDomainService, IDefaultValueManager Dictionary queryParameters = null, dynamic inputParams = null) { - var fields = new Dictionary(); + var fields = new Dictionary(); var defaultFieldsJson = op switch { @@ -132,6 +133,21 @@ public class DefaultValueManager : PlatformDomainService, IDefaultValueManager value = await dynamicDataRepository.ExecuteScalarAsync(defaultField.SqlQuery, connectionString); } break; + case FieldCustomValueTypeEnum.Sequence: + if (!string.IsNullOrWhiteSpace(defaultField.Value)) + { + if (op == OperationEnum.Select) + { + // Select operasyonunda sequence adını dön; frontend API çağrısıyla çözecek + value = defaultField.Value; + } + else + { + var sequenceManager = LazyServiceProvider.LazyGetRequiredService(); + value = await sequenceManager.GetNextSequenceAsync(defaultField.Value); + } + } + break; case FieldCustomValueTypeEnum.Value: default: value = defaultField.Value; @@ -142,11 +158,11 @@ public class DefaultValueManager : PlatformDomainService, IDefaultValueManager var formattedValue = QueryHelper.GetFormattedValue(defaultField.FieldDbType, value); if (fields.ContainsKey(defaultField.FieldName)) { - fields[defaultField.FieldName] = formattedValue; + fields[defaultField.FieldName] = new DefaultValueDict { CustomValue = formattedValue, CustomValueType = defaultField.CustomValueType }; } else { - fields.Add(defaultField.FieldName, formattedValue); + fields.Add(defaultField.FieldName, new DefaultValueDict { CustomValue = formattedValue, CustomValueType = defaultField.CustomValueType }); } } } diff --git a/api/src/Sozsoft.Platform.Domain/Sequences/SequenceManager.cs b/api/src/Sozsoft.Platform.Domain/Sequences/SequenceManager.cs new file mode 100644 index 0000000..d1e61d9 --- /dev/null +++ b/api/src/Sozsoft.Platform.Domain/Sequences/SequenceManager.cs @@ -0,0 +1,59 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Localization; +using Sozsoft.Platform; +using Sozsoft.Platform.Localization; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Settings; +using Volo.Abp.Users; + +public class SequenceManager : PlatformDomainService +{ + private readonly IRepository _sequenceRepository; + + public SequenceManager( + ISettingProvider settingProvider, + IStringLocalizer localizer, + ICurrentUser currentUser, + IObjectMapper objectMapper, + IRepository sequenceRepository) + : base(settingProvider, localizer, currentUser, objectMapper) + { + _sequenceRepository = sequenceRepository; + } + + public async Task GetNextSequenceAsync(string name) + { + var sequence = await _sequenceRepository.FirstOrDefaultAsync(x => + x.Name == name && + x.IsActive + ); + + if (sequence == null) + { + throw new Exception($"Sequence bulunamadı: {name}"); + } + + var nextSequence = sequence.GetNextSequence(DateTime.Now); + + await _sequenceRepository.UpdateAsync(sequence, autoSave: true); + + return nextSequence; + } + + public async Task GetPreviewSequenceAsync(string name) + { + var sequence = await _sequenceRepository.FirstOrDefaultAsync(x => + x.Name == name && + x.IsActive + ); + + if (sequence == null) + { + throw new Exception($"Sequence bulunamadı: {name}"); + } + + return sequence.GetPreviewSequence(DateTime.Now); + } +} \ No newline at end of file diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index fec66f4..2ca802c 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -73,6 +73,7 @@ public class PlatformDbContext : public DbSet Countries { get; set; } public DbSet Cities { get; set; } public DbSet Districts { get; set; } + public DbSet Sequences { get; set; } #endregion #region Administrator @@ -184,6 +185,8 @@ public class PlatformDbContext : b.Property(a => a.Name).IsRequired().HasMaxLength(128); b.Property(a => a.Description).HasMaxLength(256); b.Property(a => a.ApiUrl).HasMaxLength(256); + + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter(null); }); builder.Entity(b => @@ -208,6 +211,8 @@ public class PlatformDbContext : b.Property(a => a.Email).HasMaxLength(128); b.Property(a => a.Website).HasMaxLength(128); b.Property(a => a.IsActive).HasDefaultValue(true); + + b.HasIndex(x => new { x.Code }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -215,11 +220,11 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.BranchUsers)), Prefix.DbSchema); b.ConfigureByConvention(); - b.HasKey(x => new { x.UserId, x.BranchId }); b.Property(a => a.UserId).IsRequired(); b.Property(a => a.BranchId).IsRequired(); - b.Property(a => a.TenantId); + b.HasIndex(x => new { x.TenantId, x.BranchId, x.UserId }).IsUnique().HasFilter(null); + b.HasOne(x => x.Branch) .WithMany(x => x.UserBranches) .HasForeignKey(x => x.BranchId) @@ -258,6 +263,9 @@ public class PlatformDbContext : c => c.ToArray() ) ); + + b.HasIndex(x => new { x.Key }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasIndex(x => new { x.Path }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -266,6 +274,8 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(a => a.Name).IsRequired().HasMaxLength(128); + + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter(null); }); builder.Entity(b => @@ -285,6 +295,8 @@ public class PlatformDbContext : b.Property(a => a.UserId).HasMaxLength(256); b.Property(a => a.RoleId).HasMaxLength(256); b.Property(a => a.CultureName).HasMaxLength(64); + + b.HasIndex(x => new { x.Code }).IsUnique().HasFilter(null); }); builder.Entity(b => @@ -295,6 +307,8 @@ public class PlatformDbContext : b.Property(a => a.Code).IsRequired().HasMaxLength(128); b.Property(a => a.ConnectionString).HasMaxLength(256); b.Property(a => a.DataSourceType).IsRequired(); + + b.HasIndex(x => new { x.Code }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -302,9 +316,6 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.ListForm)), Prefix.DbSchema); b.ConfigureByConvention(); // base class props - // Anahtar - b.HasKey(x => x.Id); - // Özellikler b.Property(a => a.ListFormCode).IsRequired().HasMaxLength(64); b.Property(a => a.CultureName).HasMaxLength(10).IsRequired(); @@ -377,6 +388,8 @@ public class PlatformDbContext : b.Property(a => a.ValueAxisJson).HasColumnType("text"); b.Property(a => a.ZoomAndPanJson).HasColumnType("text"); + b.HasIndex(x => new { x.ListFormCode }).IsUnique().HasFilter(null); + b.HasMany().WithOne().HasForeignKey(x => x.ListFormCode).HasPrincipalKey(x => x.ListFormCode).IsRequired(); b.HasMany().WithOne().HasForeignKey(x => x.ListFormCode).HasPrincipalKey(x => x.ListFormCode).IsRequired(); b.HasMany().WithOne().HasForeignKey(x => x.ListFormCode).HasPrincipalKey(x => x.ListFormCode).IsRequired(); @@ -387,9 +400,6 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.ListFormField)), Prefix.DbSchema); b.ConfigureByConvention(); - // Anahtar - b.HasKey(x => x.Id); - // Zorunlu alanlar b.Property(a => a.ListFormCode).IsRequired().HasMaxLength(64); b.Property(a => a.UserId).HasMaxLength(256); @@ -430,6 +440,8 @@ public class PlatformDbContext : b.Property(a => a.Alignment).HasMaxLength(20).HasDefaultValue("left"); b.Property(a => a.Format).HasMaxLength(128); b.Property(a => a.EditorOptions).HasColumnType("text"); + + b.HasIndex(x => new { x.ListFormCode, x.UserId, x.RoleId, x.CultureName, x.FieldName }).IsUnique().HasFilter(null); }); builder.Entity(b => @@ -493,6 +505,8 @@ public class PlatformDbContext : b.Property(a => a.BeforeSp).HasMaxLength(128); b.Property(a => a.AfterSp).HasMaxLength(128); b.Property(a => a.Options).HasColumnType("text"); + + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -506,7 +520,7 @@ public class PlatformDbContext : b.Property(x => x.Icon).HasMaxLength(64); b.Property(x => x.LastPostUserName).HasMaxLength(256); - b.HasIndex(x => x.DisplayOrder); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); b.HasMany(x => x.Topics) .WithOne(x => x.Category) @@ -524,10 +538,6 @@ public class PlatformDbContext : b.Property(x => x.AuthorName).HasMaxLength(128); b.Property(x => x.LastPostUserName).HasMaxLength(128); - b.HasIndex(x => x.CategoryId); - b.HasIndex(x => x.IsPinned); - b.HasIndex(x => x.LastPostDate); - b.HasMany(x => x.Posts) .WithOne(x => x.Topic) .HasForeignKey(x => x.TopicId) @@ -542,8 +552,6 @@ public class PlatformDbContext : b.Property(x => x.Content).IsRequired(); b.Property(x => x.AuthorName).HasMaxLength(128); - b.HasIndex(x => x.TopicId); - b.HasOne(x => x.Topic) .WithMany(x => x.Posts) .HasForeignKey(x => x.TopicId) @@ -560,12 +568,13 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.CrudEndpoint)), Prefix.DbSchema); b.ConfigureByConvention(); - b.HasKey(x => x.Id); b.Property(x => x.EntityName).IsRequired().HasMaxLength(128); b.Property(x => x.Method).IsRequired().HasMaxLength(10); b.Property(x => x.Path).IsRequired().HasMaxLength(256); b.Property(x => x.OperationType).IsRequired().HasMaxLength(64); b.Property(x => x.CsharpCode).IsRequired(); + + b.HasIndex(x => new { x.TenantId, x.EntityName, x.Method, x.Path }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -581,6 +590,8 @@ public class PlatformDbContext : b.Property(a => a.Sql).IsRequired(); b.Property(a => a.ParametersJson).HasColumnType("text"); b.Property(a => a.PermissionsJson).HasColumnType("text"); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -588,12 +599,13 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.CustomComponent)), Prefix.DbSchema); b.ConfigureByConvention(); - b.HasKey(x => x.Id); b.Property(x => x.Name).IsRequired().HasMaxLength(128); b.Property(x => x.Code).IsRequired(); b.Property(x => x.Props).HasMaxLength(1024); b.Property(x => x.Description).HasMaxLength(512); b.Property(x => x.Dependencies).HasMaxLength(2048); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -605,6 +617,8 @@ public class PlatformDbContext : b.Property(x => x.Description).HasMaxLength(4096); // JSON string b.Property(x => x.Icon).HasMaxLength(64); + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasMany(x => x.ReportTemplates) .WithOne(x => x.ReportCategory) .HasForeignKey(x => x.CategoryId) @@ -621,6 +635,8 @@ public class PlatformDbContext : b.Property(x => x.Description).HasMaxLength(1024); b.Property(x => x.HtmlContent).IsRequired(); b.Property(x => x.Status).HasMaxLength(20); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); //Administration @@ -632,6 +648,8 @@ public class PlatformDbContext : b.Property(a => a.ResourceType).IsRequired().HasMaxLength(10); b.Property(a => a.ResourceId).HasMaxLength(32); b.Property(a => a.IP).IsRequired().HasMaxLength(32); + + b.HasIndex(x => new { x.TenantId, x.ResourceType, x.ResourceId, x.IP }).IsUnique().HasFilter("[IsDeleted] = 0"); }); // Definitions @@ -641,6 +659,8 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(128); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -650,6 +670,8 @@ public class PlatformDbContext : b.Property(x => x.Title).IsRequired().HasMaxLength(128); b.Property(x => x.Abbreviation).HasMaxLength(64); + + b.HasIndex(x => new { x.Title }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -662,7 +684,8 @@ public class PlatformDbContext : b.Property(x => x.Name).IsRequired().HasMaxLength(128); b.Property(x => x.Rate).HasPrecision(18, 6); b.Property(x => x.IsActive).HasDefaultValue(true); - b.Property(x => x.LastUpdated); + + b.HasIndex(x => new {x.Id, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -671,7 +694,8 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(128); - b.HasIndex(x => x.Name).IsUnique(); + + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -685,8 +709,7 @@ public class PlatformDbContext : b.Property(x => x.TaxLabel).HasMaxLength(64); b.Property(x => x.Currency).IsRequired().HasMaxLength(8); - b.HasIndex(x => x.Name).IsUnique(); - b.HasIndex(x => x.GroupName); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); b.HasOne() .WithMany() @@ -704,7 +727,7 @@ public class PlatformDbContext : b.Property(x => x.Name).IsRequired().HasMaxLength(128); b.Property(x => x.PlateCode).HasMaxLength(20); - b.HasIndex(x => new { x.Country, x.Name }).IsUnique(); + b.HasIndex(x => new { x.Country, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -717,7 +740,7 @@ public class PlatformDbContext : b.Property(x => x.Name).IsRequired().HasMaxLength(128); b.Property(x => x.Township).HasMaxLength(128); - b.HasIndex(x => new { x.Country, x.City, x.Name, x.Township }).IsUnique(); + b.HasIndex(x => new { x.Country, x.City, x.Name, x.Township }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -728,6 +751,8 @@ public class PlatformDbContext : b.Property(x => x.Id).HasMaxLength(128); b.Property(x => x.Name).IsRequired().HasMaxLength(128); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasMany(x => x.Skills) .WithOne(x => x.SkillType) .HasForeignKey(x => x.SkillTypeId) @@ -749,6 +774,8 @@ public class PlatformDbContext : b.Property(x => x.Id).HasMaxLength(128); b.Property(x => x.SkillTypeId).IsRequired().HasMaxLength(128); b.Property(x => x.Name).IsRequired().HasMaxLength(128); + + b.HasIndex(x => new { x.SkillTypeId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -761,6 +788,8 @@ public class PlatformDbContext : b.Property(x => x.Name).IsRequired().HasMaxLength(128); b.Property(x => x.Progress).HasDefaultValue(0); b.Property(x => x.IsDefault).HasDefaultValue(false); + + b.HasIndex(x => new { x.SkillTypeId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -771,6 +800,7 @@ public class PlatformDbContext : b.Property(x => x.Id).HasMaxLength(128); b.Property(x => x.Name).IsRequired().HasMaxLength(128); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -785,6 +815,8 @@ public class PlatformDbContext : b.Property(x => x.Rounding).HasPrecision(18, 6); b.Property(x => x.UomCategoryId).IsRequired().HasMaxLength(128); + b.HasIndex(x => new { x.Name, x.UomCategoryId }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasOne(x => x.UomCategory) .WithMany(x => x.Uoms) .HasPrincipalKey(x => x.Id) @@ -808,6 +840,8 @@ public class PlatformDbContext : b.Property(x => x.Friday); b.Property(x => x.Saturday); b.Property(x => x.Sunday); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -816,6 +850,8 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(64); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -826,6 +862,8 @@ public class PlatformDbContext : b.Property(x => x.Name).IsRequired().HasMaxLength(64); b.Property(x => x.DepartmentId).IsRequired(); + b.HasIndex(x => new { x.TenantId, x.Name, x.DepartmentId }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasOne(x => x.Department) .WithMany(x => x.JobPositions) .HasForeignKey(x => x.DepartmentId) @@ -874,10 +912,10 @@ public class PlatformDbContext : b.Property(x => x.Type).HasMaxLength(64); b.Property(x => x.Features) - .HasConversion( - v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null), - v => JsonSerializer.Deserialize(v, (JsonSerializerOptions)null) - ) + .HasConversion( + v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null), + v => JsonSerializer.Deserialize(v, (JsonSerializerOptions)null) + ) .Metadata .SetValueComparer( new ValueComparer( @@ -886,6 +924,8 @@ public class PlatformDbContext : a => a.ToArray() ) ); + + b.HasIndex(x => new { x.Title }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -893,13 +933,14 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.Product)), Prefix.DbSchema); b.ConfigureByConvention(); - b.HasKey(x => x.Id); b.Property(x => x.Name).IsRequired().HasMaxLength(128); b.Property(x => x.Description).HasMaxLength(1024); b.Property(x => x.Category).IsRequired().HasMaxLength(64); b.Property(x => x.MonthlyPrice).HasPrecision(18, 2); b.Property(x => x.YearlyPrice).HasPrecision(18, 2); b.Property(x => x.ImageUrl).HasMaxLength(512); + + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -910,6 +951,8 @@ public class PlatformDbContext : b.Property(x => x.Name).IsRequired().HasMaxLength(64); b.Property(x => x.Logo).HasMaxLength(32); b.Property(x => x.Commission).HasPrecision(5, 3); + + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -917,9 +960,10 @@ public class PlatformDbContext : b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.InstallmentOption)), Prefix.DbSchema); b.ConfigureByConvention(); - b.HasKey(x => x.Id); b.Property(x => x.Name).IsRequired().HasMaxLength(32); b.Property(x => x.Commission).HasPrecision(5, 3); + + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -976,7 +1020,7 @@ public class PlatformDbContext : b.Property(x => x.Description).HasMaxLength(512); b.Property(x => x.Icon).HasMaxLength(128); - b.HasIndex(x => x.Slug); + b.HasIndex(x => new { x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -992,9 +1036,7 @@ public class PlatformDbContext : b.Property(x => x.CoverImage).HasMaxLength(512); b.Property(x => x.ReadTime).HasMaxLength(64); - b.HasIndex(x => x.Slug); - b.HasIndex(x => x.IsPublished); - b.HasIndex(x => x.PublishedAt); + b.HasIndex(x => new { x.CategoryId, x.Title }).IsUnique().HasFilter("[IsDeleted] = 0"); b.HasOne(x => x.Category) .WithMany(x => x.Posts) @@ -1055,6 +1097,8 @@ public class PlatformDbContext : b.Property(x => x.CodeHash).HasMaxLength(64); b.Property(x => x.PrimaryEntityType).HasMaxLength(256); b.Property(x => x.ControllerName).HasMaxLength(256); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -1070,6 +1114,8 @@ public class PlatformDbContext : b.Property(x => x.Attachments).HasMaxLength(2048); b.Property(x => x.ViewCount).HasDefaultValue(0); b.Property(x => x.ImageUrl).HasColumnType("text"); + + b.HasIndex(x => new { x.TenantId, x.Title }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -1082,6 +1128,8 @@ public class PlatformDbContext : b.Property(x => x.Deadline).IsRequired(); b.Property(x => x.Responses).HasDefaultValue(0); b.Property(x => x.Status).IsRequired().HasMaxLength(10); + + b.HasIndex(x => new { x.TenantId, x.Title }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -1228,6 +1276,8 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(128); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -1236,6 +1286,8 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.Name).IsRequired().HasMaxLength(128); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); builder.Entity(b => @@ -1250,6 +1302,8 @@ public class PlatformDbContext : b.Property(x => x.isPublished).HasDefaultValue(false); b.Property(x => x.Photos).HasColumnType("text"); + b.HasIndex(x => new { x.TenantId, x.CategoryId, x.TypeId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); + b.HasOne(x => x.Category) .WithMany(x => x.Events) .HasForeignKey(x => x.CategoryId) @@ -1269,7 +1323,6 @@ public class PlatformDbContext : b.Property(x => x.Content).HasMaxLength(512); b.Property(x => x.Likes).HasDefaultValue(0); - // Event -> EventComment (1 - N) b.HasOne(x => x.Event) .WithMany(x => x.Comments) .HasForeignKey(x => x.EventId) @@ -1298,8 +1351,7 @@ public class PlatformDbContext : b.Property(x => x.Subject).HasMaxLength(128); b.Property(x => x.TeacherName).IsRequired().HasMaxLength(128); - b.HasIndex(x => x.TeacherId); - b.HasIndex(x => x.ScheduledStartTime); + b.HasIndex(x => new { x.TenantId, x.BranchId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); b.HasMany(x => x.Participants) .WithOne(x => x.Session) @@ -1326,10 +1378,6 @@ public class PlatformDbContext : b.Property(x => x.ConnectionId).HasMaxLength(128); b.Property(x => x.IsActive).HasDefaultValue(true); b.Property(x => x.IsKicked).HasDefaultValue(false); - - b.HasIndex(x => x.SessionId); - b.HasIndex(x => x.UserId); - b.HasIndex(x => new { x.SessionId, x.UserId }).IsUnique(); }); builder.Entity(b => @@ -1338,10 +1386,6 @@ public class PlatformDbContext : b.ConfigureByConvention(); b.Property(x => x.StudentName).IsRequired().HasMaxLength(128); - - b.HasIndex(x => x.SessionId); - b.HasIndex(x => x.StudentId); - b.HasIndex(x => x.JoinTime); }); builder.Entity(b => @@ -1353,10 +1397,30 @@ public class PlatformDbContext : b.Property(x => x.Message).IsRequired().HasMaxLength(2048); b.Property(x => x.MessageType).HasMaxLength(64); b.Property(x => x.RecipientName).HasMaxLength(256); + }); - b.HasIndex(x => x.SessionId); - b.HasIndex(x => x.SenderId); - b.HasIndex(x => x.Timestamp); + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.Sequence)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.Name).HasMaxLength(128).IsRequired(); + + b.Property(x => x.Prefix).HasMaxLength(32); + b.Property(x => x.Suffix).HasMaxLength(32); + + b.Property(x => x.FormatTemplate).HasMaxLength(256).IsRequired().HasDefaultValue("{Prefix}{Number}{Suffix}"); + + b.Property(x => x.PaddingSize).IsRequired().HasDefaultValue(6); + b.Property(x => x.IncrementStep).IsRequired().HasDefaultValue(1); + b.Property(x => x.NextNumber).IsRequired().HasDefaultValue(1); + + b.Property(x => x.ResetPeriod).IsRequired().HasConversion().HasDefaultValue(SequenceResetPeriod.None); + b.Property(x => x.LastPeriodKey).HasMaxLength(20); + + b.Property(x => x.IsActive).IsRequired().HasDefaultValue(true); + + b.HasIndex(x => new { x.TenantId, x.Name }).IsUnique().HasFilter("[IsDeleted] = 0"); }); } } diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260511093511_Initial.Designer.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260517100701_Initial.Designer.cs similarity index 97% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260511093511_Initial.Designer.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260517100701_Initial.Designer.cs index d2c8445..ae9804f 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260511093511_Initial.Designer.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260517100701_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Sozsoft.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20260511093511_Initial")] + [Migration("20260517100701_Initial")] partial class Initial { /// @@ -27,6 +27,106 @@ namespace Sozsoft.Platform.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("Sequence", 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("FormatTemplate") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasDefaultValue("{Prefix}{Number}{Suffix}"); + + b.Property("IncrementStep") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("LastPeriodKey") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("NextNumber") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(1L); + + b.Property("PaddingSize") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(6); + + b.Property("Prefix") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("ResetPeriod") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("StartNumber") + .HasColumnType("bigint"); + + b.Property("Suffix") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + + b.ToTable("Adm_T_Sequence", (string)null); + }); + modelBuilder.Entity("Sozsoft.Languages.Entities.Language", b => { b.Property("Id") @@ -602,6 +702,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique(); + b.ToTable("Sas_H_AiBot", (string)null); }); @@ -690,6 +793,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Announcement", (string)null); }); @@ -763,6 +870,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_BackgroundWorker", (string)null); }); @@ -830,7 +941,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("Slug"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_BlogCategory", (string)null); }); @@ -924,13 +1037,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("CategoryId"); - - b.HasIndex("IsPublished"); - - b.HasIndex("PublishedAt"); - - b.HasIndex("Slug"); + b.HasIndex("CategoryId", "Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_BlogPost", (string)null); }); @@ -1046,28 +1155,35 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Code") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_T_Branch", (string)null); }); modelBuilder.Entity("Sozsoft.Platform.Entities.BranchUsers", b => { - b.Property("UserId") + b.Property("Id") .HasColumnType("uniqueidentifier"); b.Property("BranchId") .HasColumnType("uniqueidentifier"); - b.Property("Id") - .HasColumnType("uniqueidentifier"); - b.Property("TenantId") .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); - b.HasKey("UserId", "BranchId"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); b.HasIndex("BranchId"); + b.HasIndex("TenantId", "BranchId", "UserId") + .IsUnique(); + b.ToTable("Sas_T_BranchUsers", (string)null); }); @@ -1128,7 +1244,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("Country", "Name") .IsUnique() - .HasFilter("[Country] IS NOT NULL"); + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_City", (string)null); }); @@ -1247,6 +1363,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_ContactTitle", (string)null); }); @@ -1318,7 +1438,8 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("GroupName"); b.HasIndex("Name") - .IsUnique(); + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_Country", (string)null); }); @@ -1366,7 +1487,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); b.HasIndex("Name") - .IsUnique(); + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_CountryGroup", (string)null); }); @@ -1439,6 +1561,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "EntityName", "Method", "Path") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_CrudEndpoint", (string)null); }); @@ -1501,6 +1627,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Id", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Currency", (string)null); }); @@ -1569,6 +1699,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_CustomComponent", (string)null); }); @@ -1647,6 +1781,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_CustomEndpoint", (string)null); }); @@ -1699,6 +1837,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Code") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_DataSource", (string)null); }); @@ -1827,6 +1969,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Department", (string)null); }); @@ -1892,7 +2038,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("Country", "City", "Name", "Township") .IsUnique() - .HasFilter("[Country] IS NOT NULL AND [Township] IS NOT NULL"); + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_District", (string)null); }); @@ -1988,6 +2134,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_DynamicService", (string)null); }); @@ -2079,6 +2229,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("TypeId"); + b.HasIndex("TenantId", "CategoryId", "TypeId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Event", (string)null); }); @@ -2128,6 +2282,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_EventCategory", (string)null); }); @@ -2290,6 +2448,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_EventType", (string)null); }); @@ -2472,6 +2634,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_InstallmentOption", (string)null); }); @@ -2530,6 +2696,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "ResourceType", "ResourceId", "IP") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_IpRestriction", (string)null); }); @@ -2587,6 +2757,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("DepartmentId"); + b.HasIndex("TenantId", "Name", "DepartmentId") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_JobPosition", (string)null); }); @@ -2884,6 +3058,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("ListFormCode") + .IsUnique(); + b.ToTable("Sas_H_ListForm", (string)null); }); @@ -3096,7 +3273,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("ListFormCode"); + b.HasIndex("ListFormCode", "UserId", "RoleId", "CultureName", "FieldName") + .IsUnique(); b.ToTable("Sas_H_ListFormField", (string)null); }); @@ -3325,6 +3503,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Code") + .IsUnique(); + b.ToTable("Sas_H_Menu", (string)null); }); @@ -3340,6 +3521,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique(); + b.ToTable("Sas_H_MenuGroup", (string)null); }); @@ -3662,6 +3846,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_PaymentMethod", (string)null); }); @@ -3734,6 +3922,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Product", (string)null); }); @@ -3791,6 +3983,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_ReportCategory", (string)null); }); @@ -3857,6 +4053,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("CategoryId"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_ReportTemplate", (string)null); }); @@ -3919,6 +4119,14 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Key") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + + b.HasIndex("Path") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Route", (string)null); }); @@ -3968,6 +4176,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Sector", (string)null); }); @@ -4028,6 +4240,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Service", (string)null); }); @@ -4079,7 +4295,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("SkillTypeId"); + b.HasIndex("SkillTypeId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_Skill", (string)null); }); @@ -4142,7 +4360,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("SkillTypeId"); + b.HasIndex("SkillTypeId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_SkillLevel", (string)null); }); @@ -4190,6 +4410,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_SkillType", (string)null); }); @@ -4633,6 +4857,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Survey", (string)null); }); @@ -4943,6 +5171,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("UomCategoryId"); + b.HasIndex("Name", "UomCategoryId") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Uom", (string)null); }); @@ -4989,6 +5221,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_UomCategory", (string)null); }); @@ -5081,9 +5317,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("ScheduledStartTime"); - - b.HasIndex("TeacherId"); + b.HasIndex("TenantId", "BranchId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Adm_T_Videoroom", (string)null); }); @@ -5152,12 +5388,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("JoinTime"); - b.HasIndex("SessionId"); - b.HasIndex("StudentId"); - b.ToTable("Adm_T_VideoroomAttandance", (string)null); }); @@ -5238,12 +5470,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("SenderId"); - b.HasIndex("SessionId"); - b.HasIndex("Timestamp"); - b.ToTable("Adm_T_VideoroomChat", (string)null); }); @@ -5333,12 +5561,6 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SessionId"); - b.HasIndex("UserId"); - - b.HasIndex("SessionId", "UserId") - .IsUnique() - .HasFilter("[UserId] IS NOT NULL"); - b.ToTable("Adm_T_VideoroomParticipant", (string)null); }); @@ -5417,6 +5639,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_WorkHour", (string)null); }); @@ -5506,7 +5732,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("DisplayOrder"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_T_ForumCategory", (string)null); }); @@ -5673,10 +5901,6 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("CategoryId"); - b.HasIndex("IsPinned"); - - b.HasIndex("LastPostDate"); - b.ToTable("Sas_T_ForumTopic", (string)null); }); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260511093511_Initial.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260517100701_Initial.cs similarity index 95% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260511093511_Initial.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260517100701_Initial.cs index 7c8f420..ada6360 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260511093511_Initial.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260517100701_Initial.cs @@ -642,6 +642,36 @@ namespace Sozsoft.Platform.Migrations table.PrimaryKey("PK_Adm_T_Sector", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Adm_T_Sequence", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + Prefix = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: true), + Suffix = table.Column(type: "nvarchar(32)", maxLength: 32, nullable: true), + PaddingSize = table.Column(type: "int", nullable: false, defaultValue: 6), + IncrementStep = table.Column(type: "int", nullable: false, defaultValue: 1), + StartNumber = table.Column(type: "bigint", nullable: false), + NextNumber = table.Column(type: "bigint", nullable: false, defaultValue: 1L), + ResetPeriod = table.Column(type: "int", nullable: false, defaultValue: 0), + LastPeriodKey = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), + FormatTemplate = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false, defaultValue: "{Prefix}{Number}{Suffix}"), + 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_Adm_T_Sequence", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Adm_T_SocialPost", columns: table => new @@ -2753,14 +2783,14 @@ namespace Sozsoft.Platform.Migrations name: "Sas_T_BranchUsers", columns: table => new { - BranchId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), + Id = table.Column(type: "uniqueidentifier", nullable: false), TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Id = table.Column(type: "uniqueidentifier", nullable: false) + BranchId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Sas_T_BranchUsers", x => new { x.UserId, x.BranchId }); + table.PrimaryKey("PK_Sas_T_BranchUsers", x => x.Id); table.ForeignKey( name: "FK_Sas_T_BranchUsers_Sas_T_Branch_BranchId", column: x => x.BranchId, @@ -3424,16 +3454,44 @@ namespace Sozsoft.Platform.Migrations table: "AbpUsers", column: "UserName"); + migrationBuilder.CreateIndex( + name: "IX_Adm_T_Announcement_TenantId_Title", + table: "Adm_T_Announcement", + columns: new[] { "TenantId", "Title" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Adm_T_Department_TenantId_Name", + table: "Adm_T_Department", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Adm_T_Event_CategoryId", table: "Adm_T_Event", column: "CategoryId"); + migrationBuilder.CreateIndex( + name: "IX_Adm_T_Event_TenantId_CategoryId_TypeId_Name", + table: "Adm_T_Event", + columns: new[] { "TenantId", "CategoryId", "TypeId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Adm_T_Event_TypeId", table: "Adm_T_Event", column: "TypeId"); + migrationBuilder.CreateIndex( + name: "IX_Adm_T_EventCategory_TenantId_Name", + table: "Adm_T_EventCategory", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Adm_T_EventComment_EventId", table: "Adm_T_EventComment", @@ -3444,16 +3502,65 @@ namespace Sozsoft.Platform.Migrations table: "Adm_T_EventLike", column: "EventId"); + migrationBuilder.CreateIndex( + name: "IX_Adm_T_EventType_TenantId_Name", + table: "Adm_T_EventType", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Adm_T_IpRestriction_TenantId_ResourceType_ResourceId_IP", + table: "Adm_T_IpRestriction", + columns: new[] { "TenantId", "ResourceType", "ResourceId", "IP" }, + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Adm_T_JobPosition_DepartmentId", table: "Adm_T_JobPosition", column: "DepartmentId"); + migrationBuilder.CreateIndex( + name: "IX_Adm_T_JobPosition_TenantId_Name_DepartmentId", + table: "Adm_T_JobPosition", + columns: new[] { "TenantId", "Name", "DepartmentId" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Adm_T_ReportCategory_TenantId_Name", + table: "Adm_T_ReportCategory", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Adm_T_ReportTemplate_CategoryId", table: "Adm_T_ReportTemplate", column: "CategoryId"); + migrationBuilder.CreateIndex( + name: "IX_Adm_T_ReportTemplate_TenantId_Name", + table: "Adm_T_ReportTemplate", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Adm_T_Sector_TenantId_Name", + table: "Adm_T_Sector", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Adm_T_Sequence_TenantId_Name", + table: "Adm_T_Sequence", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Adm_T_SocialComment_SocialPostId", table: "Adm_T_SocialComment", @@ -3481,6 +3588,13 @@ namespace Sozsoft.Platform.Migrations table: "Adm_T_SocialPollOption", column: "SocialMediaId"); + migrationBuilder.CreateIndex( + name: "IX_Adm_T_Survey_TenantId_Title", + table: "Adm_T_Survey", + columns: new[] { "TenantId", "Title" }, + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Adm_T_SurveyAnswer_QuestionId", table: "Adm_T_SurveyAnswer", @@ -3507,61 +3621,33 @@ namespace Sozsoft.Platform.Migrations column: "SurveyId"); migrationBuilder.CreateIndex( - name: "IX_Adm_T_Videoroom_ScheduledStartTime", + name: "IX_Adm_T_Videoroom_TenantId_BranchId_Name", table: "Adm_T_Videoroom", - column: "ScheduledStartTime"); - - migrationBuilder.CreateIndex( - name: "IX_Adm_T_Videoroom_TeacherId", - table: "Adm_T_Videoroom", - column: "TeacherId"); - - migrationBuilder.CreateIndex( - name: "IX_Adm_T_VideoroomAttandance_JoinTime", - table: "Adm_T_VideoroomAttandance", - column: "JoinTime"); + columns: new[] { "TenantId", "BranchId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Adm_T_VideoroomAttandance_SessionId", table: "Adm_T_VideoroomAttandance", column: "SessionId"); - migrationBuilder.CreateIndex( - name: "IX_Adm_T_VideoroomAttandance_StudentId", - table: "Adm_T_VideoroomAttandance", - column: "StudentId"); - - migrationBuilder.CreateIndex( - name: "IX_Adm_T_VideoroomChat_SenderId", - table: "Adm_T_VideoroomChat", - column: "SenderId"); - migrationBuilder.CreateIndex( name: "IX_Adm_T_VideoroomChat_SessionId", table: "Adm_T_VideoroomChat", column: "SessionId"); - migrationBuilder.CreateIndex( - name: "IX_Adm_T_VideoroomChat_Timestamp", - table: "Adm_T_VideoroomChat", - column: "Timestamp"); - migrationBuilder.CreateIndex( name: "IX_Adm_T_VideoroomParticipant_SessionId", table: "Adm_T_VideoroomParticipant", column: "SessionId"); migrationBuilder.CreateIndex( - name: "IX_Adm_T_VideoroomParticipant_SessionId_UserId", - table: "Adm_T_VideoroomParticipant", - columns: new[] { "SessionId", "UserId" }, + name: "IX_Adm_T_WorkHour_TenantId_Name", + table: "Adm_T_WorkHour", + columns: new[] { "TenantId", "Name" }, unique: true, - filter: "[UserId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_Adm_T_VideoroomParticipant_UserId", - table: "Adm_T_VideoroomParticipant", - column: "UserId"); + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_OpenIddictApplications_ClientId", @@ -3593,6 +3679,19 @@ namespace Sozsoft.Platform.Migrations table: "OpenIddictTokens", column: "ReferenceId"); + migrationBuilder.CreateIndex( + name: "IX_Sas_H_AiBot_Name", + table: "Sas_H_AiBot", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_BackgroundWorker_Name", + table: "Sas_H_BackgroundWorker", + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Sas_H_BackgroundWorker_MailQueue_TableName", table: "Sas_H_BackgroundWorker_MailQueue", @@ -3610,42 +3709,38 @@ namespace Sozsoft.Platform.Migrations unique: true); migrationBuilder.CreateIndex( - name: "IX_Sas_H_BlogCategory_Slug", + name: "IX_Sas_H_BlogCategory_Name", table: "Sas_H_BlogCategory", - column: "Slug"); + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_BlogPost_CategoryId", + name: "IX_Sas_H_BlogPost_CategoryId_Title", table: "Sas_H_BlogPost", - column: "CategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_Sas_H_BlogPost_IsPublished", - table: "Sas_H_BlogPost", - column: "IsPublished"); - - migrationBuilder.CreateIndex( - name: "IX_Sas_H_BlogPost_PublishedAt", - table: "Sas_H_BlogPost", - column: "PublishedAt"); - - migrationBuilder.CreateIndex( - name: "IX_Sas_H_BlogPost_Slug", - table: "Sas_H_BlogPost", - column: "Slug"); + columns: new[] { "CategoryId", "Title" }, + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Sas_H_City_Country_Name", table: "Sas_H_City", columns: new[] { "Country", "Name" }, unique: true, - filter: "[Country] IS NOT NULL"); + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Sas_H_City_CountryId", table: "Sas_H_City", column: "CountryId"); + migrationBuilder.CreateIndex( + name: "IX_Sas_H_ContactTitle_Title", + table: "Sas_H_ContactTitle", + column: "Title", + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Sas_H_Country_GroupName", table: "Sas_H_Country", @@ -3655,13 +3750,50 @@ namespace Sozsoft.Platform.Migrations name: "IX_Sas_H_Country_Name", table: "Sas_H_Country", column: "Name", - unique: true); + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Sas_H_CountryGroup_Name", table: "Sas_H_CountryGroup", column: "Name", - unique: true); + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_CrudEndpoint_TenantId_EntityName_Method_Path", + table: "Sas_H_CrudEndpoint", + columns: new[] { "TenantId", "EntityName", "Method", "Path" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_Currency_Id_Name", + table: "Sas_H_Currency", + columns: new[] { "Id", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_CustomComponent_TenantId_Name", + table: "Sas_H_CustomComponent", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_CustomEndpoint_TenantId_Name", + table: "Sas_H_CustomEndpoint", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_DataSource_Code", + table: "Sas_H_DataSource", + column: "Code", + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Sas_H_District_CityId", @@ -3673,7 +3805,21 @@ namespace Sozsoft.Platform.Migrations table: "Sas_H_District", columns: new[] { "Country", "City", "Name", "Township" }, unique: true, - filter: "[Country] IS NOT NULL AND [Township] IS NOT NULL"); + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_DynamicService_TenantId_Name", + table: "Sas_H_DynamicService", + columns: new[] { "TenantId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_InstallmentOption_Name", + table: "Sas_H_InstallmentOption", + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Sas_H_LanguageKey_ResourceName_Key", @@ -3691,15 +3837,22 @@ namespace Sozsoft.Platform.Migrations table: "Sas_H_LanguageText", columns: new[] { "ResourceName", "Key" }); + migrationBuilder.CreateIndex( + name: "IX_Sas_H_ListForm_ListFormCode", + table: "Sas_H_ListForm", + column: "ListFormCode", + unique: true); + migrationBuilder.CreateIndex( name: "IX_Sas_H_ListFormCustomization_ListFormCode", table: "Sas_H_ListFormCustomization", column: "ListFormCode"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_ListFormField_ListFormCode", + name: "IX_Sas_H_ListFormField_ListFormCode_UserId_RoleId_CultureName_FieldName", table: "Sas_H_ListFormField", - column: "ListFormCode"); + columns: new[] { "ListFormCode", "UserId", "RoleId", "CultureName", "FieldName" }, + unique: true); migrationBuilder.CreateIndex( name: "IX_Sas_H_ListFormImport_ListFormCode", @@ -3711,6 +3864,18 @@ namespace Sozsoft.Platform.Migrations table: "Sas_H_ListFormImportExecute", column: "ImportId"); + migrationBuilder.CreateIndex( + name: "IX_Sas_H_Menu_Code", + table: "Sas_H_Menu", + column: "Code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_MenuGroup_Name", + table: "Sas_H_MenuGroup", + column: "Name", + unique: true); + migrationBuilder.CreateIndex( name: "IX_Sas_H_Notification_NotificationRuleId", table: "Sas_H_Notification", @@ -3732,29 +3897,104 @@ namespace Sozsoft.Platform.Migrations column: "OrderId"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_Skill_SkillTypeId", - table: "Sas_H_Skill", - column: "SkillTypeId"); + name: "IX_Sas_H_PaymentMethod_Name", + table: "Sas_H_PaymentMethod", + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( - name: "IX_Sas_H_SkillLevel_SkillTypeId", + name: "IX_Sas_H_Product_Name", + table: "Sas_H_Product", + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_Route_Key", + table: "Sas_H_Route", + column: "Key", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_Route_Path", + table: "Sas_H_Route", + column: "Path", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_Service_Title", + table: "Sas_H_Service", + column: "Title", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_Skill_SkillTypeId_Name", + table: "Sas_H_Skill", + columns: new[] { "SkillTypeId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_SkillLevel_SkillTypeId_Name", table: "Sas_H_SkillLevel", - column: "SkillTypeId"); + columns: new[] { "SkillTypeId", "Name" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_SkillType_Name", + table: "Sas_H_SkillType", + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_H_Uom_Name_UomCategoryId", + table: "Sas_H_Uom", + columns: new[] { "Name", "UomCategoryId" }, + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Sas_H_Uom_UomCategoryId", table: "Sas_H_Uom", column: "UomCategoryId"); + migrationBuilder.CreateIndex( + name: "IX_Sas_H_UomCategory_Name", + table: "Sas_H_UomCategory", + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Sas_T_Branch_Code", + table: "Sas_T_Branch", + column: "Code", + unique: true, + filter: "[IsDeleted] = 0"); + migrationBuilder.CreateIndex( name: "IX_Sas_T_BranchUsers_BranchId", table: "Sas_T_BranchUsers", column: "BranchId"); migrationBuilder.CreateIndex( - name: "IX_Sas_T_ForumCategory_DisplayOrder", + name: "IX_Sas_T_BranchUsers_TenantId_BranchId_UserId", + table: "Sas_T_BranchUsers", + columns: new[] { "TenantId", "BranchId", "UserId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Sas_T_ForumCategory_Name", table: "Sas_T_ForumCategory", - column: "DisplayOrder"); + column: "Name", + unique: true, + filter: "[IsDeleted] = 0"); migrationBuilder.CreateIndex( name: "IX_Sas_T_ForumPost_ParentPostId", @@ -3770,16 +4010,6 @@ namespace Sozsoft.Platform.Migrations name: "IX_Sas_T_ForumTopic_CategoryId", table: "Sas_T_ForumTopic", column: "CategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_Sas_T_ForumTopic_IsPinned", - table: "Sas_T_ForumTopic", - column: "IsPinned"); - - migrationBuilder.CreateIndex( - name: "IX_Sas_T_ForumTopic_LastPostDate", - table: "Sas_T_ForumTopic", - column: "LastPostDate"); } /// @@ -3881,6 +4111,9 @@ namespace Sozsoft.Platform.Migrations migrationBuilder.DropTable( name: "Adm_T_Sector"); + migrationBuilder.DropTable( + name: "Adm_T_Sequence"); + migrationBuilder.DropTable( name: "Adm_T_SocialComment"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index b46656c..87c577e 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -24,6 +24,106 @@ namespace Sozsoft.Platform.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("Sequence", 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("FormatTemplate") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasDefaultValue("{Prefix}{Number}{Suffix}"); + + b.Property("IncrementStep") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("LastPeriodKey") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("NextNumber") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(1L); + + b.Property("PaddingSize") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(6); + + b.Property("Prefix") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("ResetPeriod") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("StartNumber") + .HasColumnType("bigint"); + + b.Property("Suffix") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + + b.ToTable("Adm_T_Sequence", (string)null); + }); + modelBuilder.Entity("Sozsoft.Languages.Entities.Language", b => { b.Property("Id") @@ -599,6 +699,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique(); + b.ToTable("Sas_H_AiBot", (string)null); }); @@ -687,6 +790,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Announcement", (string)null); }); @@ -760,6 +867,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_BackgroundWorker", (string)null); }); @@ -827,7 +938,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("Slug"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_BlogCategory", (string)null); }); @@ -921,13 +1034,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("CategoryId"); - - b.HasIndex("IsPublished"); - - b.HasIndex("PublishedAt"); - - b.HasIndex("Slug"); + b.HasIndex("CategoryId", "Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_BlogPost", (string)null); }); @@ -1043,28 +1152,35 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Code") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_T_Branch", (string)null); }); modelBuilder.Entity("Sozsoft.Platform.Entities.BranchUsers", b => { - b.Property("UserId") + b.Property("Id") .HasColumnType("uniqueidentifier"); b.Property("BranchId") .HasColumnType("uniqueidentifier"); - b.Property("Id") - .HasColumnType("uniqueidentifier"); - b.Property("TenantId") .HasColumnType("uniqueidentifier") .HasColumnName("TenantId"); - b.HasKey("UserId", "BranchId"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); b.HasIndex("BranchId"); + b.HasIndex("TenantId", "BranchId", "UserId") + .IsUnique(); + b.ToTable("Sas_T_BranchUsers", (string)null); }); @@ -1125,7 +1241,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("Country", "Name") .IsUnique() - .HasFilter("[Country] IS NOT NULL"); + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_City", (string)null); }); @@ -1244,6 +1360,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_ContactTitle", (string)null); }); @@ -1315,7 +1435,8 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("GroupName"); b.HasIndex("Name") - .IsUnique(); + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_Country", (string)null); }); @@ -1363,7 +1484,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); b.HasIndex("Name") - .IsUnique(); + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_CountryGroup", (string)null); }); @@ -1436,6 +1558,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "EntityName", "Method", "Path") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_CrudEndpoint", (string)null); }); @@ -1498,6 +1624,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Id", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Currency", (string)null); }); @@ -1566,6 +1696,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_CustomComponent", (string)null); }); @@ -1644,6 +1778,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_CustomEndpoint", (string)null); }); @@ -1696,6 +1834,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Code") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_DataSource", (string)null); }); @@ -1824,6 +1966,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Department", (string)null); }); @@ -1889,7 +2035,7 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("Country", "City", "Name", "Township") .IsUnique() - .HasFilter("[Country] IS NOT NULL AND [Township] IS NOT NULL"); + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_District", (string)null); }); @@ -1985,6 +2131,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_DynamicService", (string)null); }); @@ -2076,6 +2226,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("TypeId"); + b.HasIndex("TenantId", "CategoryId", "TypeId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Event", (string)null); }); @@ -2125,6 +2279,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_EventCategory", (string)null); }); @@ -2287,6 +2445,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_EventType", (string)null); }); @@ -2469,6 +2631,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_InstallmentOption", (string)null); }); @@ -2527,6 +2693,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "ResourceType", "ResourceId", "IP") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_IpRestriction", (string)null); }); @@ -2584,6 +2754,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("DepartmentId"); + b.HasIndex("TenantId", "Name", "DepartmentId") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_JobPosition", (string)null); }); @@ -2881,6 +3055,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("ListFormCode") + .IsUnique(); + b.ToTable("Sas_H_ListForm", (string)null); }); @@ -3093,7 +3270,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("ListFormCode"); + b.HasIndex("ListFormCode", "UserId", "RoleId", "CultureName", "FieldName") + .IsUnique(); b.ToTable("Sas_H_ListFormField", (string)null); }); @@ -3322,6 +3500,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Code") + .IsUnique(); + b.ToTable("Sas_H_Menu", (string)null); }); @@ -3337,6 +3518,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique(); + b.ToTable("Sas_H_MenuGroup", (string)null); }); @@ -3659,6 +3843,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_PaymentMethod", (string)null); }); @@ -3731,6 +3919,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Product", (string)null); }); @@ -3788,6 +3980,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_ReportCategory", (string)null); }); @@ -3854,6 +4050,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("CategoryId"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_ReportTemplate", (string)null); }); @@ -3916,6 +4116,14 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Key") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + + b.HasIndex("Path") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Route", (string)null); }); @@ -3965,6 +4173,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Sector", (string)null); }); @@ -4025,6 +4237,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Service", (string)null); }); @@ -4076,7 +4292,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("SkillTypeId"); + b.HasIndex("SkillTypeId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_Skill", (string)null); }); @@ -4139,7 +4357,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("SkillTypeId"); + b.HasIndex("SkillTypeId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_H_SkillLevel", (string)null); }); @@ -4187,6 +4407,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_SkillType", (string)null); }); @@ -4630,6 +4854,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Title") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_Survey", (string)null); }); @@ -4940,6 +5168,10 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("UomCategoryId"); + b.HasIndex("Name", "UomCategoryId") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_Uom", (string)null); }); @@ -4986,6 +5218,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Sas_H_UomCategory", (string)null); }); @@ -5078,9 +5314,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("ScheduledStartTime"); - - b.HasIndex("TeacherId"); + b.HasIndex("TenantId", "BranchId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Adm_T_Videoroom", (string)null); }); @@ -5149,12 +5385,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("JoinTime"); - b.HasIndex("SessionId"); - b.HasIndex("StudentId"); - b.ToTable("Adm_T_VideoroomAttandance", (string)null); }); @@ -5235,12 +5467,8 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("SenderId"); - b.HasIndex("SessionId"); - b.HasIndex("Timestamp"); - b.ToTable("Adm_T_VideoroomChat", (string)null); }); @@ -5330,12 +5558,6 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("SessionId"); - b.HasIndex("UserId"); - - b.HasIndex("SessionId", "UserId") - .IsUnique() - .HasFilter("[UserId] IS NOT NULL"); - b.ToTable("Adm_T_VideoroomParticipant", (string)null); }); @@ -5414,6 +5636,10 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); + b.HasIndex("TenantId", "Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); + b.ToTable("Adm_T_WorkHour", (string)null); }); @@ -5503,7 +5729,9 @@ namespace Sozsoft.Platform.Migrations b.HasKey("Id"); - b.HasIndex("DisplayOrder"); + b.HasIndex("Name") + .IsUnique() + .HasFilter("[IsDeleted] = 0"); b.ToTable("Sas_T_ForumCategory", (string)null); }); @@ -5670,10 +5898,6 @@ namespace Sozsoft.Platform.Migrations b.HasIndex("CategoryId"); - b.HasIndex("IsPinned"); - - b.HasIndex("LastPostDate"); - b.ToTable("Sas_T_ForumTopic", (string)null); }); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json index def8cee..07cfce9 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json @@ -2033,5 +2033,29 @@ "EventName": "Kültür Gezisi: Kapadokya", "Url": "https://images.unsplash.com/photo-1515405295579-ba7b45403062?w=800" } + ], + "Sequences": [ + { + "Name": "PurchaseCode1", + "Prefix": "PO", + "Suffix": "", + "PaddingSize": 6, + "IncrementStep": 1, + "StartNumber": 1, + "NextNumber": 1, + "FormatTemplate": "{Prefix}{Number}{Suffix}", + "ResetPeriod": "None" + }, + { + "Name": "PurchaseCode2", + "Prefix": "PO", + "Suffix": "", + "PaddingSize": 5, + "IncrementStep": 1, + "StartNumber": 1, + "NextNumber": 1, + "FormatTemplate": "{Prefix}-{yyyy}{MM}{dd}-{Number}", + "ResetPeriod": "Daily" + } ] } \ No newline at end of file diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs index 96b095e..b04ed73 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using Volo.Abp.MultiTenancy; using Sozsoft.Platform.Extensions; using System.Linq; +using Sozsoft.Platform.Enums; namespace Sozsoft.Platform.Data.Seeds; @@ -25,6 +26,7 @@ public class TenantSeederDto public List GlobalSearch { get; set; } public List CustomEndpoints { get; set; } public List CustomComponents { get; set; } + public List Sequences { get; set; } //Definitions public List Sectors { get; set; } @@ -72,6 +74,19 @@ public class TenantSeederDto public List EventComments { get; set; } } +public class SequenceSeedDto +{ + public string Name { get; set; } = null!; + public string? Prefix { get; set; } + public string? Suffix { get; set; } + public int PaddingSize { get; set; } = 5; + public int IncrementStep { get; set; } = 1; + public long StartNumber { get; set; } = 1; + public long NextNumber { get; set; } = 1; + public string? FormatTemplate { get; set; } + public SequenceResetPeriod ResetPeriod { get; set; } = SequenceResetPeriod.None; +} + public class SocialPostSeedDto { public string Content { get; set; } @@ -455,6 +470,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency private readonly IRepository _socialPollOptionRepository; private readonly IRepository _socialCommentRepository; private readonly IRepository _socialLikeRepository; + private readonly IRepository _sequenceRepository; private readonly IRepository _eventTypeRepository; private readonly IRepository _eventCategoryRepository; @@ -505,6 +521,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency IRepository eventTypeRepository, IRepository eventCategoryRepository, IRepository eventRepository, + IRepository sequenceRepository, OrganizationUnitManager organizationUnitManager, ICurrentTenant currentTenant @@ -551,6 +568,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency _eventTypeRepository = eventTypeRepository; _eventCategoryRepository = eventCategoryRepository; _eventRepository = eventRepository; + _sequenceRepository = sequenceRepository; _organizationUnitManager = organizationUnitManager; _currentTenant = currentTenant; } @@ -1220,6 +1238,39 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency } } + foreach (var item in items.Sequences) + { + var exists = await _sequenceRepository.AnyAsync(x => x.Name == item.Name); + + if (!exists) + { + await _sequenceRepository.InsertAsync( + new Sequence + { + Name = item.Name, + + Prefix = item.Prefix, + Suffix = item.Suffix, + + PaddingSize = item.PaddingSize, + IncrementStep = item.IncrementStep, + + StartNumber = item.StartNumber, + NextNumber = item.NextNumber, + + FormatTemplate = string.IsNullOrWhiteSpace(item.FormatTemplate) + ? "{Prefix}{Number}{Suffix}" + : item.FormatTemplate, + + ResetPeriod = item.ResetPeriod, + + IsActive = true + }, + autoSave: true + ); + } + } + //admin kullanının departmen ve pozisyonunu default olarak belirliyoruz var adminUser = await _repositoryUser.FindByNormalizedEmailAsync(PlatformConsts.AbpIdentity.User.AdminEmailDefaultValue); if (adminUser != null) diff --git a/ui/src/proxy/form/models.ts b/ui/src/proxy/form/models.ts index eb744f2..01bcb27 100644 --- a/ui/src/proxy/form/models.ts +++ b/ui/src/proxy/form/models.ts @@ -122,6 +122,7 @@ export enum FieldCustomValueTypeEnum { CustomKey = 2, DbQuery = 3, QueryParams = 4, + Sequence = 5, } export enum ColumnValidationTypeListEnum { @@ -238,6 +239,7 @@ export interface ColumnFormatDto extends AuditedEntityDto { canUpdate: boolean canExport: boolean defaultValue: object + defaultValueType: FieldCustomValueTypeEnum pivotSettingsJson?: string pivotSettingsDto: ListFormFieldPivotSettingsDto alignment?: HorizontalAlignment diff --git a/ui/src/services/form.service.ts b/ui/src/services/form.service.ts index 018e6bf..ce45a06 100644 --- a/ui/src/services/form.service.ts +++ b/ui/src/services/form.service.ts @@ -1,5 +1,4 @@ import { AxiosError, Method } from 'axios' -import { URLSearchParams } from 'url' import { GridDto } from '../proxy/form/models' import apiService from './api.service' @@ -17,6 +16,14 @@ export const getList = (data: Record) => { } } +export const getNextSequenceValue = (sequenceName: string) => { + return apiService.fetchData({ + method: 'GET', + url: '/api/app/list-form-select/next-sequence-value', + params: { sequenceName }, + }) +} + export const dynamicFetch = ( url: string, method: Method | string, diff --git a/ui/src/views/admin/listForm/edit/json-row-operations/JsonRowOpDialogDatabase.tsx b/ui/src/views/admin/listForm/edit/json-row-operations/JsonRowOpDialogDatabase.tsx index 8086d31..4d4e345 100644 --- a/ui/src/views/admin/listForm/edit/json-row-operations/JsonRowOpDialogDatabase.tsx +++ b/ui/src/views/admin/listForm/edit/json-row-operations/JsonRowOpDialogDatabase.tsx @@ -216,20 +216,27 @@ function JsonRowOpDialogDatabase({ component={Input} /> - - - + {values.customValueType === FieldCustomValueTypeEnum.DbQuery && ( + + + + )}