From 5e772272dcb0e523b8c22109b5a39e9fff1949db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Wed, 11 Mar 2026 15:20:40 +0300 Subject: [PATCH] =?UTF-8?q?Blog=20d=C3=BCzenlemesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Public/BlogPostDto.cs | 3 +-- .../Public/BlogPostListDto.cs | 4 +--- .../Blog/BlogAppService.cs | 10 +++++----- .../Public/PublicAppService.cs | 10 ---------- .../Seeds/PermissionsData.json | 14 +++++++------- .../Tenant/Administration/Website/BlogPost.cs | 2 +- ...igner.cs => 20260311115619_Initial.Designer.cs} | 8 ++++---- ...211156_Initial.cs => 20260311115619_Initial.cs} | 2 +- .../Migrations/PlatformDbContextModelSnapshot.cs | 6 +++--- .../Seeds/TenantData.json | 12 ++++++------ .../Seeds/TenantDataSeeder.cs | 7 +++---- ui/src/proxy/blog/blog.ts | 10 +++------- .../admin/role-management/RolesPermission.tsx | 10 +++++++--- ui/src/views/public/Blog.tsx | 2 +- ui/src/views/public/BlogDetail.tsx | 10 +++------- 15 files changed, 46 insertions(+), 64 deletions(-) rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260310211156_Initial.Designer.cs => 20260311115619_Initial.Designer.cs} (99%) rename api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/{20260310211156_Initial.cs => 20260311115619_Initial.cs} (99%) diff --git a/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostDto.cs b/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostDto.cs index c2d7bfe..1775421 100644 --- a/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostDto.cs +++ b/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostDto.cs @@ -18,8 +18,7 @@ public class BlogPostDto : FullAuditedEntityDto public Guid CategoryId { get; set; } public BlogCategoryDto Category { get; set; } - public Guid UserId { get; set; } - public UserInfoViewModel User { get; set; } + public string Author { get; set; } public int ViewCount { get; set; } public int LikeCount { get; set; } diff --git a/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostListDto.cs b/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostListDto.cs index 219b759..32ce580 100644 --- a/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostListDto.cs +++ b/api/src/Sozsoft.Platform.Application.Contracts/Public/BlogPostListDto.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Sozsoft.Platform.Identity.Dto; using Volo.Abp.Application.Dtos; namespace Sozsoft.Platform.Public; @@ -19,8 +18,7 @@ public class BlogPostListDto : EntityDto public Guid CategoryId { get; set; } public BlogCategoryDto Category { get; set; } - public Guid UserId { get; set; } - public UserInfoViewModel User { get; set; } + public string Author { get; set; } public int ViewCount { get; set; } public int LikeCount { get; set; } diff --git a/api/src/Sozsoft.Platform.Application/Blog/BlogAppService.cs b/api/src/Sozsoft.Platform.Application/Blog/BlogAppService.cs index c3e63d4..1d955b5 100644 --- a/api/src/Sozsoft.Platform.Application/Blog/BlogAppService.cs +++ b/api/src/Sozsoft.Platform.Application/Blog/BlogAppService.cs @@ -44,7 +44,7 @@ public class BlogAppService : PlatformAppService, IBlogAppService ReadTime = input.ReadTime, CoverImage = input.CoverImage, CategoryId = input.CategoryId, - UserId = _currentUser.Id.Value, + Author = _currentUser.Name, IsPublished = true, }; @@ -73,7 +73,7 @@ public class BlogAppService : PlatformAppService, IBlogAppService { var post = await _postRepository.GetAsync(id); - if (post.UserId != _currentUser.Id && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Update")) + if (post.Author != _currentUser.Name && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Update")) { throw new Volo.Abp.Authorization.AbpAuthorizationException(); } @@ -125,7 +125,7 @@ public class BlogAppService : PlatformAppService, IBlogAppService var post = await _postRepository.GetAsync(id); // Check if user is author or has permission - if (post.UserId != _currentUser.Id && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Delete")) + if (post.Author != _currentUser.Name && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Delete")) { throw new Volo.Abp.Authorization.AbpAuthorizationException(); } @@ -143,7 +143,7 @@ public class BlogAppService : PlatformAppService, IBlogAppService var post = await _postRepository.GetAsync(id); // Check if user is author or has permission - if (post.UserId != _currentUser.Id && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Publish")) + if (post.Author != _currentUser.Name && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Publish")) { throw new Volo.Abp.Authorization.AbpAuthorizationException(); } @@ -159,7 +159,7 @@ public class BlogAppService : PlatformAppService, IBlogAppService var post = await _postRepository.GetAsync(id); // Check if user is author or has permission - if (post.UserId != _currentUser.Id && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Publish")) + if (post.Author != _currentUser.Name && !await AuthorizationService.IsGrantedAsync("App.BlogManagement.Publish")) { throw new Volo.Abp.Authorization.AbpAuthorizationException(); } diff --git a/api/src/Sozsoft.Platform.Application/Public/PublicAppService.cs b/api/src/Sozsoft.Platform.Application/Public/PublicAppService.cs index 550b39b..5a24d7b 100644 --- a/api/src/Sozsoft.Platform.Application/Public/PublicAppService.cs +++ b/api/src/Sozsoft.Platform.Application/Public/PublicAppService.cs @@ -13,7 +13,6 @@ using System.Linq; using Volo.Abp.Application.Dtos; using System.Text.Json; using Volo.Abp.Identity; -using Sozsoft.Platform.Identity.Dto; namespace Sozsoft.Platform.Public; @@ -132,10 +131,6 @@ public class PublicAppService : PlatformAppService var pageCategories = await _categoryRepository.GetListAsync(x => categoryIds.Contains(x.Id)); var categoryDict = pageCategories.ToDictionary(x => x.Id, x => x); - var userIds = pagedPosts.Select(x => x.UserId).Distinct().ToList(); - var pageEmployees = await _identityUserRepository.GetListByIdsAsync(userIds); - var employeeDict = pageEmployees.ToDictionary(x => x.Id, x => x); - // Post DTO mapping var postDtos = pagedPosts.Select(post => { @@ -145,11 +140,6 @@ public class PublicAppService : PlatformAppService dto.Category = ObjectMapper.Map(c); } - if (employeeDict.TryGetValue(post.UserId, out var e)) - { - dto.User = ObjectMapper.Map(e); - } - return dto; }).ToList(); diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json index 7e1789b..6600e72 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PermissionsData.json @@ -2910,7 +2910,7 @@ "DisplayName": "App.Definitions.WorkHour", "IsEnabled": true, "MultiTenancySide": 3, - "MenuGroup": "Kurs" + "MenuGroup": "Erp|Kurs" }, { "GroupName": "App.Administration", @@ -2919,7 +2919,7 @@ "DisplayName": "Create", "IsEnabled": true, "MultiTenancySide": 3, - "MenuGroup": "Kurs" + "MenuGroup": "Erp|Kurs" }, { "GroupName": "App.Administration", @@ -2928,7 +2928,7 @@ "DisplayName": "Update", "IsEnabled": true, "MultiTenancySide": 3, - "MenuGroup": "Kurs" + "MenuGroup": "Erp|Kurs" }, { "GroupName": "App.Administration", @@ -2937,7 +2937,7 @@ "DisplayName": "Delete", "IsEnabled": true, "MultiTenancySide": 3, - "MenuGroup": "Kurs" + "MenuGroup": "Erp|Kurs" }, { "GroupName": "App.Administration", @@ -2946,7 +2946,7 @@ "DisplayName": "Export", "IsEnabled": true, "MultiTenancySide": 3, - "MenuGroup": "Kurs" + "MenuGroup": "Erp|Kurs" }, { "GroupName": "App.Administration", @@ -2955,7 +2955,7 @@ "DisplayName": "Import", "IsEnabled": true, "MultiTenancySide": 3, - "MenuGroup": "Kurs" + "MenuGroup": "Erp|Kurs" }, { "GroupName": "App.Administration", @@ -2964,7 +2964,7 @@ "DisplayName": "Note", "IsEnabled": true, "MultiTenancySide": 3, - "MenuGroup": "Kurs" + "MenuGroup": "Erp|Kurs" }, { "GroupName": "App.Administration", diff --git a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Website/BlogPost.cs b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Website/BlogPost.cs index c403370..d7afb9c 100644 --- a/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Website/BlogPost.cs +++ b/api/src/Sozsoft.Platform.Domain/Entities/Tenant/Administration/Website/BlogPost.cs @@ -16,7 +16,7 @@ public class BlogPost : FullAuditedEntity public Guid CategoryId { get; set; } public BlogCategory Category { get; set; } - public Guid UserId { get; set; } + public string Author { get; set; } public int? ViewCount { get; set; } = 0; public int? LikeCount { get; set; } = 0; diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260310211156_Initial.Designer.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260311115619_Initial.Designer.cs similarity index 99% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260310211156_Initial.Designer.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260311115619_Initial.Designer.cs index 7a7867f..44e5c4a 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260310211156_Initial.Designer.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260311115619_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Sozsoft.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20260310211156_Initial")] + [Migration("20260311115619_Initial")] partial class Initial { /// @@ -796,6 +796,9 @@ namespace Sozsoft.Platform.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); + b.Property("Author") + .HasColumnType("nvarchar(max)"); + b.Property("CategoryId") .HasColumnType("uniqueidentifier"); @@ -872,9 +875,6 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(256) .HasColumnType("nvarchar(256)"); - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - b.Property("ViewCount") .HasColumnType("int"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260310211156_Initial.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260311115619_Initial.cs similarity index 99% rename from api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260310211156_Initial.cs rename to api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260311115619_Initial.cs index 1031b4a..f402f00 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260310211156_Initial.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/20260311115619_Initial.cs @@ -1850,7 +1850,7 @@ namespace Sozsoft.Platform.Migrations CoverImage = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), ReadTime = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), CategoryId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), + Author = table.Column(type: "nvarchar(max)", nullable: true), ViewCount = table.Column(type: "int", nullable: true), LikeCount = table.Column(type: "int", nullable: true), CommentCount = table.Column(type: "int", nullable: true), diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index 4a99a21..8898b33 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -793,6 +793,9 @@ namespace Sozsoft.Platform.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); + b.Property("Author") + .HasColumnType("nvarchar(max)"); + b.Property("CategoryId") .HasColumnType("uniqueidentifier"); @@ -869,9 +872,6 @@ namespace Sozsoft.Platform.Migrations .HasMaxLength(256) .HasColumnType("nvarchar(256)"); - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - b.Property("ViewCount") .HasColumnType("int"); diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json index 296c2bd..50405ef 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantData.json @@ -202,7 +202,7 @@ "Summary": "blog.posts.ai.excerpt", "CoverImage": "https://images.pexels.com/photos/8386434/pexels-photo-8386434.jpeg?auto=compress&cs=tinysrgb&w=1920", "CategoryName": "blog.categories.technology", - "UserName": "system@sozsoft.com" + "Author": "system@sozsoft.com" }, { "Title": "blog.posts.web.title", @@ -213,7 +213,7 @@ "Summary": "blog.posts.web.excerpt", "CoverImage": "https://images.pexels.com/photos/11035471/pexels-photo-11035471.jpeg?auto=compress&cs=tinysrgb&w=1920", "CategoryName": "blog.categories.webdev", - "UserName": "system@sozsoft.com" + "Author": "system@sozsoft.com" }, { "Title": "blog.posts.security.title", @@ -224,7 +224,7 @@ "Summary": "blog.posts.security.excerpt", "CoverImage": "https://images.pexels.com/photos/5380642/pexels-photo-5380642.jpeg?auto=compress&cs=tinysrgb&w=1920", "CategoryName": "blog.categories.security", - "UserName": "system@sozsoft.com" + "Author": "system@sozsoft.com" }, { "Title": "blog.posts.mobile.title", @@ -235,7 +235,7 @@ "ReadTime": "4 dk", "CoverImage": "https://images.pexels.com/photos/13017583/pexels-photo-13017583.jpeg?auto=compress&cs=tinysrgb&w=1920", "CategoryName": "blog.categories.mobile", - "UserName": "system@sozsoft.com" + "Author": "system@sozsoft.com" }, { "Title": "blog.posts.database.title", @@ -246,7 +246,7 @@ "ReadTime": "8 dk", "CoverImage": "https://images.pexels.com/photos/325229/pexels-photo-325229.jpeg?auto=compress&cs=tinysrgb&w=1920", "CategoryName": "blog.categories.database", - "UserName": "system@sozsoft.com" + "Author": "system@sozsoft.com" }, { "Title": "blog.posts.digital.title", @@ -257,7 +257,7 @@ "ReadTime": "6 dk", "CoverImage": "https://images.pexels.com/photos/7681091/pexels-photo-7681091.jpeg?auto=compress&cs=tinysrgb&w=1920", "CategoryName": "blog.categories.digital", - "UserName": "system@sozsoft.com" + "Author": "system@sozsoft.com" } ], "GlobalSearch": [ diff --git a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs index 2bcda87..44f5701 100644 --- a/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs +++ b/api/src/Sozsoft.Platform.EntityFrameworkCore/Seeds/TenantDataSeeder.cs @@ -118,7 +118,7 @@ public class BlogPostSeedDto public string Summary { get; set; } public string CoverImage { get; set; } public string CategoryName { get; set; } - public string UserName { get; set; } + public string Author { get; set; } public bool IsPublished { get; set; } public DateTime PublishedAt { get; set; } } @@ -669,9 +669,8 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency if (!exists) { var category = await _blogCategoryRepository.FirstOrDefaultAsync(x => x.Name == item.CategoryName); - var user = await _repositoryUser.FindByNormalizedUserNameAsync(item.UserName); - if (category != null && user != null) + if (category != null) { await _blogPostsRepository.InsertAsync(new BlogPost { @@ -683,7 +682,7 @@ public class TenantDataSeeder : IDataSeedContributor, ITransientDependency CoverImage = item.CoverImage, ReadTime = item.ReadTime, CategoryId = category.Id, - UserId = user.Id, + Author = item.Author, IsPublished = true, PublishedAt = DateTime.UtcNow }); diff --git a/ui/src/proxy/blog/blog.ts b/ui/src/proxy/blog/blog.ts index eaf3fcf..a7bcd95 100644 --- a/ui/src/proxy/blog/blog.ts +++ b/ui/src/proxy/blog/blog.ts @@ -8,12 +8,7 @@ export interface BlogPost { contentEn?: string summary: string coverImage?: string - userid: string - user: { - id: string - name: string - username: string - } + author: string category: { id: string name: string @@ -54,6 +49,7 @@ export interface CreateUpdateBlogPostDto { contentEn: string summary: string categoryId: string + author: string tags: string[] coverImage?: string isPublished: boolean @@ -76,6 +72,6 @@ export interface BlogListParams { categoryId?: string tag?: string search?: string - employeeId?: string + author?: string sortBy?: 'latest' | 'popular' | 'trending' } diff --git a/ui/src/views/admin/role-management/RolesPermission.tsx b/ui/src/views/admin/role-management/RolesPermission.tsx index e4eb25f..2206c9a 100644 --- a/ui/src/views/admin/role-management/RolesPermission.tsx +++ b/ui/src/views/admin/role-management/RolesPermission.tsx @@ -56,9 +56,13 @@ function RolesPermission({ const filteredGroups = data.groups .map((group: any) => { - const filteredPermissions = group.permissions.filter( - (perm: any) => Array.isArray(perm.menuGroup) && perm.menuGroup.includes(tenantGroup), - ) + const filteredPermissions = group.permissions.filter((perm: any) => { + if (!perm.menuGroup) return false + const groups = typeof perm.menuGroup === 'string' + ? perm.menuGroup.split('|').map((g: string) => g.trim()) + : perm.menuGroup + return groups.includes(tenantGroup) + }) return { ...group, permissions: filteredPermissions } }) diff --git a/ui/src/views/public/Blog.tsx b/ui/src/views/public/Blog.tsx index 365b3e1..eef191d 100644 --- a/ui/src/views/public/Blog.tsx +++ b/ui/src/views/public/Blog.tsx @@ -195,7 +195,7 @@ const Blog = () => {
- {post.user.username} + {post.author}
diff --git a/ui/src/views/public/BlogDetail.tsx b/ui/src/views/public/BlogDetail.tsx index 3a54fbc..00d7e23 100644 --- a/ui/src/views/public/BlogDetail.tsx +++ b/ui/src/views/public/BlogDetail.tsx @@ -12,11 +12,7 @@ import { APP_NAME } from '@/constants/app.constant' interface PostData { image?: string - user?: { - id: string - name: string - username: string - } + author?: string } const BlogDetail: React.FC = () => { @@ -39,7 +35,7 @@ const BlogDetail: React.FC = () => { setBlogPost(response) setPostData({ image: response.coverImage, - user: response.user, + author: response.author, }) } else { setError('Blog post ID is missing.') @@ -107,7 +103,7 @@ const BlogDetail: React.FC = () => {
- {postData.user?.username} + {postData.author}
{blogPost.publishedAt && showDbDateAsIs(blogPost.publishedAt)}