From 4bf6b4c2570cd82f6b089506d4fdb39044655549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:48:03 +0300 Subject: [PATCH] seed/data Seeder Departments --- .../ListFormSeeder_Administration.cs | 8 ++ .../Seeds/TenantData.json | 80 ------------------- .../Seeds/TenantDataSeeder.cs | 58 -------------- .../host/data/App.Definitions.Department.json | 38 +++++++++ .../data/App.Definitions.JobPosition.json | 56 +++++++++++++ 5 files changed, 102 insertions(+), 138 deletions(-) create mode 100644 configs/seeds/host/data/App.Definitions.Department.json create mode 100644 configs/seeds/host/data/App.Definitions.JobPosition.json diff --git a/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Administration.cs b/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Administration.cs index c5fd4d45..9c6141df 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Administration.cs +++ b/api/src/Sozsoft.Platform.DbMigrator/Migrations/ListFormSeeder_Administration.cs @@ -2648,6 +2648,10 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep Description = $"{listFormName}.Description", SelectCommandType = SelectCommandTypeEnum.Table, SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.Department)), + SeedFilePath = SeedPathResolver.GetDataFilePath(listFormName), + SeedSyncInsert = false, + SeedSyncUpdate = false, + SeedSyncDelete = false, KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, DefaultFilter = DefaultFilterJson, @@ -2767,6 +2771,10 @@ public class ListFormSeeder_Administration : IDataSeedContributor, ITransientDep Description = $"{listFormName}.Description", SelectCommandType = SelectCommandTypeEnum.Table, SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.JobPosition)), + SeedFilePath = SeedPathResolver.GetDataFilePath(listFormName), + SeedSyncInsert = false, + SeedSyncUpdate = false, + SeedSyncDelete = false, KeyFieldName = "Id", KeyFieldDbSourceType = DbType.Guid, DefaultFilter = DefaultFilterJson, diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json index e99e3d4a..864c5da6 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json @@ -391,86 +391,6 @@ } } ], - "Departments": [ - { - "Id": "8f14e45f-ea2d-4d9f-9f1d-1a2b3c4d5e6f", - "Name": "Yönetim" - }, - { - "Id": "2c1743a3-91b7-4b57-a6c8-7d8e9f0a1b2c", - "Name": "Üretim", - "ParentName": "Yönetim" - }, - { - "Id": "987bcab0-1b92-4a4e-8d7f-3c2b1a0f9e8d", - "Name": "Satış", - "ParentName": "Yönetim" - }, - { - "Id": "05b048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d", - "Name": "Finans", - "ParentName": "Yönetim" - }, - { - "Id": "051048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d", - "Name": "Muhasebe", - "ParentName": "Finans" - }, - { - "Id": "3cd38ab3-7e6f-4b8d-9c0a-5f4e3d2c1b0a", - "Name": "Bilgi İşlem", - "ParentName": "Yönetim" - } - ], - "JobPositions": [ - { - "Id": "d1f7c6a2-3b4e-4c8d-9f0a-1b2c3d4e5f60", - "DepartmentName": "Yönetim", - "Name": "Genel Müdür" - }, - { - "Id": "b7c8d9e0-f1a2-4b3c-8d9e-0f1a2b3c4d2e", - "DepartmentName": "Bilgi İşlem", - "Name": "Bilgi İşlem Müdürü", - "ParentName": "Genel Müdür" - }, - { - "Id": "b7c8d9e0-f1b2-4b3c-1d9e-0f1a2b3c4d2e", - "DepartmentName": "Satış", - "Name": "İhracat Müdürü", - "ParentName": "Genel Müdür" - }, - { - "Id": "b2c8d9e0-f1b2-4b3c-1d9e-0f1a2b3c4d2e", - "DepartmentName": "Satış", - "Name": "İç Piyasa Müdürü", - "ParentName": "Genel Müdür" - }, - { - "Id": "b2c8d9e0-f1b2-2b3c-1d9e-0f1a2b3c4d2e", - "DepartmentName": "Üretim", - "Name": "Üretim Müdürü", - "ParentName": "Genel Müdür" - }, - { - "Id": "b7c8d9e0-f1a2-4b3c-1d9e-0f1a2b3c4d2e", - "DepartmentName": "Finans", - "Name": "Finans Müdürü", - "ParentName": "Genel Müdür" - }, - { - "Id": "b7c8d9e0-f1a2-4b3c-8d9e-0f1a2b3c4d5e", - "DepartmentName": "Muhasebe", - "Name": "Muhasebe Müdürü", - "ParentName": "Finans Müdürü" - }, - { - "Id": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f", - "DepartmentName": "Muhasebe", - "Name": "Muhasebe Şefi", - "ParentName": "Muhasebe Müdürü" - } - ], "Announcements": [ { "title": "🎉 Yeni Ofis Açılışı", diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs index 55ed1d57..0800b676 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs @@ -24,8 +24,6 @@ public class TenantSeederDto public List Sequences { get; set; } //Definitions - public List Departments { get; set; } - public List JobPositions { get; set; } //Public public List Homes { get; set; } @@ -193,23 +191,6 @@ public class AnnouncementSeedDto public string DepartmentNames { get; set; } } -public class JobPositionSeedDto -{ - public Guid Id { get; set; } - public string DepartmentName { get; set; } - public string Name { get; set; } - public string BranchCode { get; set; } - public string ParentName { get; set; } -} - -public class DepartmentSeedDto -{ - public Guid Id { get; set; } - public string Name { get; set; } - public string BranchCode { get; set; } - public string ParentName { get; set; } -} - public class ForumCategorySeedDto { public string Name { get; set; } @@ -308,8 +289,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency private readonly IRepository _contactRepository; private readonly IRepository _forumCategoryRepository; private readonly IIdentityUserRepository _repositoryUser; - private readonly IRepository _departmentRepository; - private readonly IRepository _jobPositionRepository; private readonly IRepository _announcementRepository; private readonly IRepository _surveyRepository; private readonly IRepository _surveyQuestionRepository; @@ -335,8 +314,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency IRepository servicesRepository, IRepository contactRepository, IRepository forumCategoryRepository, - IRepository departmentRepository, - IRepository jobPositionRepository, IRepository announcementRepository, IRepository surveyRepository, @@ -361,8 +338,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency _aboutRepository = aboutRepository; _contactRepository = contactRepository; _forumCategoryRepository = forumCategoryRepository; - _departmentRepository = departmentRepository; - _jobPositionRepository = jobPositionRepository; _announcementRepository = announcementRepository; _surveyRepository = surveyRepository; _surveyQuestionRepository = surveyQuestionRepository; @@ -485,39 +460,6 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency } } - foreach (var item in items.Departments) - { - var exists = await _departmentRepository.AnyAsync(x => x.Name == item.Name); - if (exists) - continue; - - var branch = await _branchRepository.FirstOrDefaultAsync(x => x.Code == item.BranchCode); - var parent = await _departmentRepository.FirstOrDefaultAsync(x => x.Name == item.ParentName); - - await _departmentRepository.InsertAsync(new Department(item.Id) - { - Name = item.Name, - ParentId = parent?.Id - }, autoSave: true); - } - - foreach (var item in items.JobPositions) - { - var exists = await _jobPositionRepository.AnyAsync(x => x.Name == item.Name); - if (exists) - continue; - - var department = await _departmentRepository.FirstOrDefaultAsync(x => x.Name == item.DepartmentName); - var parent = await _jobPositionRepository.FirstOrDefaultAsync(x => x.Name == item.ParentName); - - await _jobPositionRepository.InsertAsync(new JobPosition(item.Id) - { - Name = item.Name, - DepartmentId = department.Id, - ParentId = parent?.Id - }, autoSave: true); - } - foreach (var item in items.Announcements) { var exists = await _announcementRepository.AnyAsync(x => x.Title == item.Title); diff --git a/configs/seeds/host/data/App.Definitions.Department.json b/configs/seeds/host/data/App.Definitions.Department.json new file mode 100644 index 00000000..610ecd3c --- /dev/null +++ b/configs/seeds/host/data/App.Definitions.Department.json @@ -0,0 +1,38 @@ +{ + "ListFormCode": "App.Definitions.Department", + "KeyFieldName": "Id", + "GeneratedAt": "2026-09-04T00:00:00Z", + "Order": 10, + "Rows": [ + { + "Id": "8f14e45f-ea2d-4d9f-9f1d-1a2b3c4d5e6f", + "Name": "Yönetim", + "ParentId": null + }, + { + "Id": "2c1743a3-91b7-4b57-a6c8-7d8e9f0a1b2c", + "Name": "Üretim", + "ParentId": "8f14e45f-ea2d-4d9f-9f1d-1a2b3c4d5e6f" + }, + { + "Id": "987bcab0-1b92-4a4e-8d7f-3c2b1a0f9e8d", + "Name": "Satış", + "ParentId": "8f14e45f-ea2d-4d9f-9f1d-1a2b3c4d5e6f" + }, + { + "Id": "05b048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d", + "Name": "Finans", + "ParentId": "8f14e45f-ea2d-4d9f-9f1d-1a2b3c4d5e6f" + }, + { + "Id": "051048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d", + "Name": "Muhasebe", + "ParentId": "05b048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d" + }, + { + "Id": "3cd38ab3-7e6f-4b8d-9c0a-5f4e3d2c1b0a", + "Name": "Bilgi İşlem", + "ParentId": "8f14e45f-ea2d-4d9f-9f1d-1a2b3c4d5e6f" + } + ] +} diff --git a/configs/seeds/host/data/App.Definitions.JobPosition.json b/configs/seeds/host/data/App.Definitions.JobPosition.json new file mode 100644 index 00000000..dc0f964d --- /dev/null +++ b/configs/seeds/host/data/App.Definitions.JobPosition.json @@ -0,0 +1,56 @@ +{ + "ListFormCode": "App.Definitions.JobPosition", + "KeyFieldName": "Id", + "GeneratedAt": "2026-09-04T00:00:00Z", + "Order": 20, + "Rows": [ + { + "Id": "d1f7c6a2-3b4e-4c8d-9f0a-1b2c3d4e5f60", + "Name": "Genel Müdür", + "DepartmentId": "8f14e45f-ea2d-4d9f-9f1d-1a2b3c4d5e6f", + "ParentId": null + }, + { + "Id": "b7c8d9e0-f1a2-4b3c-8d9e-0f1a2b3c4d2e", + "Name": "Bilgi İşlem Müdürü", + "DepartmentId": "3cd38ab3-7e6f-4b8d-9c0a-5f4e3d2c1b0a", + "ParentId": "d1f7c6a2-3b4e-4c8d-9f0a-1b2c3d4e5f60" + }, + { + "Id": "b7c8d9e0-f1b2-4b3c-1d9e-0f1a2b3c4d2e", + "Name": "İhracat Müdürü", + "DepartmentId": "987bcab0-1b92-4a4e-8d7f-3c2b1a0f9e8d", + "ParentId": "d1f7c6a2-3b4e-4c8d-9f0a-1b2c3d4e5f60" + }, + { + "Id": "b2c8d9e0-f1b2-4b3c-1d9e-0f1a2b3c4d2e", + "Name": "İç Piyasa Müdürü", + "DepartmentId": "987bcab0-1b92-4a4e-8d7f-3c2b1a0f9e8d", + "ParentId": "d1f7c6a2-3b4e-4c8d-9f0a-1b2c3d4e5f60" + }, + { + "Id": "b2c8d9e0-f1b2-2b3c-1d9e-0f1a2b3c4d2e", + "Name": "Üretim Müdürü", + "DepartmentId": "2c1743a3-91b7-4b57-a6c8-7d8e9f0a1b2c", + "ParentId": "d1f7c6a2-3b4e-4c8d-9f0a-1b2c3d4e5f60" + }, + { + "Id": "b7c8d9e0-f1a2-4b3c-1d9e-0f1a2b3c4d2e", + "Name": "Finans Müdürü", + "DepartmentId": "05b048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d", + "ParentId": "d1f7c6a2-3b4e-4c8d-9f0a-1b2c3d4e5f60" + }, + { + "Id": "b7c8d9e0-f1a2-4b3c-8d9e-0f1a2b3c4d5e", + "Name": "Muhasebe Müdürü", + "DepartmentId": "051048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d", + "ParentId": "b7c8d9e0-f1a2-4b3c-1d9e-0f1a2b3c4d2e" + }, + { + "Id": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f", + "Name": "Muhasebe Şefi", + "DepartmentId": "051048d7-2f44-4f9d-b5a1-6e7f8a9b0c1d", + "ParentId": "b7c8d9e0-f1a2-4b3c-8d9e-0f1a2b3c4d5e" + } + ] +}