Blog düzenlemesi
This commit is contained in:
parent
dfc63617f8
commit
5e772272dc
15 changed files with 46 additions and 64 deletions
|
|
@ -18,8 +18,7 @@ public class BlogPostDto : FullAuditedEntityDto<Guid>
|
|||
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; }
|
||||
|
|
|
|||
|
|
@ -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<Guid>
|
|||
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; }
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<BlogCategory, BlogCategoryDto>(c);
|
||||
}
|
||||
|
||||
if (employeeDict.TryGetValue(post.UserId, out var e))
|
||||
{
|
||||
dto.User = ObjectMapper.Map<Volo.Abp.Identity.IdentityUser, UserInfoViewModel>(e);
|
||||
}
|
||||
|
||||
return dto;
|
||||
}).ToList();
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class BlogPost : FullAuditedEntity<Guid>
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
|
|||
namespace Sozsoft.Platform.Migrations
|
||||
{
|
||||
[DbContext(typeof(PlatformDbContext))]
|
||||
[Migration("20260310211156_Initial")]
|
||||
[Migration("20260311115619_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
@ -796,6 +796,9 @@ namespace Sozsoft.Platform.Migrations
|
|||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Author")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid>("CategoryId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
|
|
@ -872,9 +875,6 @@ namespace Sozsoft.Platform.Migrations
|
|||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int?>("ViewCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
|
@ -1850,7 +1850,7 @@ namespace Sozsoft.Platform.Migrations
|
|||
CoverImage = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
|
||||
ReadTime = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
|
||||
CategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Author = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
ViewCount = table.Column<int>(type: "int", nullable: true),
|
||||
LikeCount = table.Column<int>(type: "int", nullable: true),
|
||||
CommentCount = table.Column<int>(type: "int", nullable: true),
|
||||
|
|
@ -793,6 +793,9 @@ namespace Sozsoft.Platform.Migrations
|
|||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Author")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid>("CategoryId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
|
|
@ -869,9 +872,6 @@ namespace Sozsoft.Platform.Migrations
|
|||
.HasMaxLength(256)
|
||||
.HasColumnType("nvarchar(256)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int?>("ViewCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
})
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ const Blog = () => {
|
|||
<div className="flex items-center text-sm text-gray-500 space-x-4">
|
||||
<div className="flex items-center">
|
||||
<FaUser size={16} className="mr-1" />
|
||||
{post.user.username}
|
||||
{post.author}
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<FaCalendarAlt size={16} className="mr-1" />
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
|||
</h1>
|
||||
<div className="flex items-center text-sm text-gray-500 space-x-4 mb-8">
|
||||
<div className="flex items-center">
|
||||
<span>{postData.user?.username}</span>
|
||||
<span>{postData.author}</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
{blogPost.publishedAt && showDbDateAsIs(blogPost.publishedAt)}
|
||||
|
|
|
|||
Loading…
Reference in a new issue