2502cbbda2
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m44s
Payment Gateway: - Add PYMSPaymentService: IPaymentGatewayService via gRPC to PYMS microservice - Add ZarinPalPaymentService: direct ZarinPal integration (backup) - Register 'pyms' payment provider in DI ConfigureServices - Add PYMS proto files (pyms_transaction.proto, pyms_public_messages.proto) - Fix VerifyDiscountWalletCharge: pass 'OK' as status instead of Authority - Update appsettings: PaymentProvider=pyms, sandbox mode, merchant ID Blog System: - Add BlogCategory, BlogPost, BlogPostImage entities and CQRS - Add proto files and gRPC services for blog management - Add Mapster profiles for blog responses Content Management: - Add SitePage entity and CQRS for static pages - Add proto and gRPC service for site pages Image/File Management: - Add LocalFileManager with disk storage + base64 serving + FMS fallback - Add ImagePathResolverInterceptor for gRPC responses - Add ImageResolverService for explicit image resolution - Add UploadsController for public file serving with FMS fallback - Add PaymentCallbackController for discount order payment callbacks Database: - Add blog and content entity migrations - Remove ImagePath MaxLength constraints - Remove old FileManagementService (replaced by LocalFileManager)
67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
using CMSMicroservice.Application.Common.Interfaces;
|
|
using CMSMicroservice.Domain.Enums;
|
|
using MediatR;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace CMSMicroservice.Application.BlogPostCQ.Queries.GetBlogPost;
|
|
|
|
public class GetBlogPostQueryHandler : IRequestHandler<GetBlogPostQuery, BlogPostDto>
|
|
{
|
|
private readonly IApplicationDbContext _context;
|
|
|
|
public GetBlogPostQueryHandler(IApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<BlogPostDto> Handle(GetBlogPostQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var post = await _context.BlogPosts
|
|
.Include(x => x.BlogPostCategories).ThenInclude(x => x.BlogCategory)
|
|
.Include(x => x.BlogPostTags).ThenInclude(x => x.Tag)
|
|
.FirstOrDefaultAsync(x => x.Id == request.Id && !x.IsDeleted, cancellationToken)
|
|
?? throw new KeyNotFoundException($"مقاله با شناسه {request.Id} یافت نشد");
|
|
|
|
return new BlogPostDto
|
|
{
|
|
Id = post.Id,
|
|
Title = post.Title,
|
|
Slug = post.Slug,
|
|
Summary = post.Summary,
|
|
HtmlContent = post.HtmlContent,
|
|
FeaturedImagePath = post.FeaturedImagePath,
|
|
FeaturedImageThumbnailPath = post.FeaturedImageThumbnailPath,
|
|
Status = post.Status,
|
|
StatusName = GetStatusName(post.Status),
|
|
PublishedAt = post.PublishedAt,
|
|
ViewCount = post.ViewCount,
|
|
AuthorUserId = post.AuthorUserId,
|
|
IsFeatured = post.IsFeatured,
|
|
SortOrder = post.SortOrder,
|
|
Created = post.Created,
|
|
LastModified = post.LastModified,
|
|
Categories = post.BlogPostCategories.Select(c => new BlogPostCategoryDto
|
|
{
|
|
Id = c.BlogCategory.Id,
|
|
Title = c.BlogCategory.Title,
|
|
Slug = c.BlogCategory.Slug
|
|
}).ToList(),
|
|
Tags = post.BlogPostTags.Select(t => new BlogPostTagDto
|
|
{
|
|
Id = t.Tag.Id,
|
|
Title = t.Tag.Title,
|
|
Name = t.Tag.Name
|
|
}).ToList()
|
|
};
|
|
}
|
|
|
|
public static string GetStatusName(BlogPostStatus status) => status switch
|
|
{
|
|
BlogPostStatus.Draft => "پیشنویس",
|
|
BlogPostStatus.Published => "منتشرشده",
|
|
BlogPostStatus.Scheduled => "زمانبندیشده",
|
|
BlogPostStatus.Archived => "آرشیو",
|
|
_ => "نامشخص"
|
|
};
|
|
}
|