feat: integrate PYMS payment gateway, add blog/sitepage/image services, local file manager
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m44s
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)
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
namespace CMSMicroservice.Application.Common.FileManager;
|
||||
|
||||
/// <summary>
|
||||
/// سرویس مدیریت فایل — ذخیره روی دیسک، مسیر نسبی در دیتابیس
|
||||
/// موقع واکشی: خواندن از دیسک و تبدیل به base64 data-URI
|
||||
/// </summary>
|
||||
public interface IFileManager
|
||||
{
|
||||
/// <summary>
|
||||
/// آپلود یک فایل خام به دیسک
|
||||
/// </summary>
|
||||
/// <returns>نتیجه آپلود شامل مسیر نسبی فایل</returns>
|
||||
/// <exception cref="FileUploadException">در صورت خطای آپلود</exception>
|
||||
Task<UploadedFile> UploadAsync(
|
||||
string directory,
|
||||
byte[] fileBytes,
|
||||
string mime,
|
||||
string? fileName = null,
|
||||
CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// آپلود تصویر با بهینهسازی خودکار + ساخت بندانگشتی
|
||||
/// </summary>
|
||||
/// <returns>نتیجه آپلود شامل تصویر اصلی و بندانگشتی (مسیرهای نسبی)</returns>
|
||||
/// <exception cref="FileUploadException">در صورت خطای آپلود</exception>
|
||||
Task<UploadedImage> UploadImageAsync(
|
||||
string directory,
|
||||
byte[] fileBytes,
|
||||
string mime,
|
||||
string? fileName = null,
|
||||
CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// حذف فایل از دیسک
|
||||
/// </summary>
|
||||
Task DeleteAsync(long fileId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// خواندن فایل از دیسک و تبدیل به base64 data-URI
|
||||
/// اگر مسیر از قبل data: باشد، همان را برمیگرداند
|
||||
/// اگر فایل وجود نداشته باشد، رشته خالی برمیگرداند
|
||||
/// </summary>
|
||||
string ResolveImageUrl(string? path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نتیجه آپلود فایل
|
||||
/// </summary>
|
||||
/// <param name="Id">شناسه فایل در FMS</param>
|
||||
/// <param name="Path">مسیر فایل ذخیرهشده (مثلاً /Images/Products/abc.jpg)</param>
|
||||
public sealed record UploadedFile(long Id, string Path);
|
||||
|
||||
/// <summary>
|
||||
/// نتیجه آپلود تصویر — شامل تصویر اصلی و بندانگشتی
|
||||
/// </summary>
|
||||
/// <param name="Main">تصویر اصلی بهینهشده</param>
|
||||
/// <param name="Thumbnail">تصویر بندانگشتی</param>
|
||||
public sealed record UploadedImage(UploadedFile Main, UploadedFile Thumbnail);
|
||||
|
||||
/// <summary>
|
||||
/// خطای آپلود فایل
|
||||
/// </summary>
|
||||
public class FileUploadException : Exception
|
||||
{
|
||||
public FileUploadException(string message) : base(message) { }
|
||||
public FileUploadException(string message, Exception inner) : base(message, inner) { }
|
||||
}
|
||||
Reference in New Issue
Block a user