From c0ba5c1a1871f0269aec9ccd8836e8c247935ac4 Mon Sep 17 00:00:00 2001 From: Vzart Date: Thu, 20 Jul 2023 22:21:34 +0700 Subject: [PATCH 1/6] refactor: move get all request logs to logging folder --- src/Api/Controllers/BorrowsController.cs | 1 + .../Queries/GetAllRequestLogsPaginated.cs | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/Application/{Borrows => Loggings}/Queries/GetAllRequestLogsPaginated.cs (97%) diff --git a/src/Api/Controllers/BorrowsController.cs b/src/Api/Controllers/BorrowsController.cs index 7f49b61e..ce16fece 100644 --- a/src/Api/Controllers/BorrowsController.cs +++ b/src/Api/Controllers/BorrowsController.cs @@ -7,6 +7,7 @@ using Application.Common.Models.Dtos; using Application.Common.Models.Dtos.Physical; using Application.Identity; +using Application.Loggings.Queries; using Infrastructure.Identity.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/src/Application/Borrows/Queries/GetAllRequestLogsPaginated.cs b/src/Application/Loggings/Queries/GetAllRequestLogsPaginated.cs similarity index 97% rename from src/Application/Borrows/Queries/GetAllRequestLogsPaginated.cs rename to src/Application/Loggings/Queries/GetAllRequestLogsPaginated.cs index f10ba63c..6f145ee1 100644 --- a/src/Application/Borrows/Queries/GetAllRequestLogsPaginated.cs +++ b/src/Application/Loggings/Queries/GetAllRequestLogsPaginated.cs @@ -4,11 +4,10 @@ using Application.Common.Models.Dtos; using Application.Users.Queries; using AutoMapper; -using Domain.Enums; using MediatR; using Microsoft.EntityFrameworkCore; -namespace Application.Borrows.Queries; +namespace Application.Loggings.Queries; public class GetAllRequestLogsPaginated { From faacb6e2284d2bd412f8eda74200145f9dd8ecbb Mon Sep 17 00:00:00 2001 From: Vzart Date: Fri, 21 Jul 2023 10:54:34 +0700 Subject: [PATCH 2/6] fix: create and get entry now accept unicode --- src/Application/Entries/Commands/CreateEntry.cs | 4 ++-- src/Application/Entries/Queries/GetAllEntriesPaginated.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Application/Entries/Commands/CreateEntry.cs b/src/Application/Entries/Commands/CreateEntry.cs index e5dcc8f8..32d4dc40 100644 --- a/src/Application/Entries/Commands/CreateEntry.cs +++ b/src/Application/Entries/Commands/CreateEntry.cs @@ -24,10 +24,10 @@ public Validator() RuleFor(x => x.Name) .NotEmpty().WithMessage("Entry's name is required.") .MaximumLength(256).WithMessage("Name cannot exceed 256 characters."); - + RuleFor(x => x.Path) .NotEmpty().WithMessage("Entry's path is required.") - .Matches("^(/(?!/)[A-Za-z_.\\s\\-0-9]*)+(? x.EntryPath) .NotEmpty().WithMessage("File's path is required.") - .Matches("^(/(?!/)[A-Za-z_.\\s\\-0-9]*)+(? Date: Fri, 21 Jul 2023 14:35:48 +0700 Subject: [PATCH 3/6] add regex validator for entry name. --- src/Application/Entries/Commands/CreateEntry.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Application/Entries/Commands/CreateEntry.cs b/src/Application/Entries/Commands/CreateEntry.cs index 32d4dc40..1a9ddb4c 100644 --- a/src/Application/Entries/Commands/CreateEntry.cs +++ b/src/Application/Entries/Commands/CreateEntry.cs @@ -23,6 +23,7 @@ public Validator() RuleFor(x => x.Name) .NotEmpty().WithMessage("Entry's name is required.") + .Matches("^[\\p{L}A-Za-z_.\\s\\-0-9]*$").WithMessage("Invalid name format.") .MaximumLength(256).WithMessage("Name cannot exceed 256 characters."); RuleFor(x => x.Path) From 36302e31e33681db605c75c20e3a244079c0a9ce Mon Sep 17 00:00:00 2001 From: Vzart Date: Wed, 26 Jul 2023 13:40:35 +0700 Subject: [PATCH 4/6] fix: file extension when download --- src/Application/Entries/Commands/DownloadDigitalFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application/Entries/Commands/DownloadDigitalFile.cs b/src/Application/Entries/Commands/DownloadDigitalFile.cs index ef020e9a..85048f97 100644 --- a/src/Application/Entries/Commands/DownloadDigitalFile.cs +++ b/src/Application/Entries/Commands/DownloadDigitalFile.cs @@ -80,7 +80,7 @@ public async Task Handle(Command request, CancellationToken cancellation { Content = content, FileType = fileType, - FileName = entry.Name, + FileName = $"{entry.Name}.{entry.File.FileExtension}", }; } } From 5446a569af894658f73e03f437a2887120e688d3 Mon Sep 17 00:00:00 2001 From: Vzart Date: Wed, 26 Jul 2023 13:42:40 +0700 Subject: [PATCH 5/6] fix: stoopid 1 --- src/Application/Entries/Commands/CreateEntry.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Application/Entries/Commands/CreateEntry.cs b/src/Application/Entries/Commands/CreateEntry.cs index 1a9ddb4c..32d4dc40 100644 --- a/src/Application/Entries/Commands/CreateEntry.cs +++ b/src/Application/Entries/Commands/CreateEntry.cs @@ -23,7 +23,6 @@ public Validator() RuleFor(x => x.Name) .NotEmpty().WithMessage("Entry's name is required.") - .Matches("^[\\p{L}A-Za-z_.\\s\\-0-9]*$").WithMessage("Invalid name format.") .MaximumLength(256).WithMessage("Name cannot exceed 256 characters."); RuleFor(x => x.Path) From 927215921864c2edd6a8898fd97994cecaaef42a Mon Sep 17 00:00:00 2001 From: Vzart Date: Wed, 26 Jul 2023 13:45:26 +0700 Subject: [PATCH 6/6] fix: sorry bao san --- src/Application/Entries/Commands/CreateEntry.cs | 1 + src/Application/Entries/Commands/CreateSharedEntry.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Application/Entries/Commands/CreateEntry.cs b/src/Application/Entries/Commands/CreateEntry.cs index 32d4dc40..1a9ddb4c 100644 --- a/src/Application/Entries/Commands/CreateEntry.cs +++ b/src/Application/Entries/Commands/CreateEntry.cs @@ -23,6 +23,7 @@ public Validator() RuleFor(x => x.Name) .NotEmpty().WithMessage("Entry's name is required.") + .Matches("^[\\p{L}A-Za-z_.\\s\\-0-9]*$").WithMessage("Invalid name format.") .MaximumLength(256).WithMessage("Name cannot exceed 256 characters."); RuleFor(x => x.Path) diff --git a/src/Application/Entries/Commands/CreateSharedEntry.cs b/src/Application/Entries/Commands/CreateSharedEntry.cs index ade8d987..5fe9d8f0 100644 --- a/src/Application/Entries/Commands/CreateSharedEntry.cs +++ b/src/Application/Entries/Commands/CreateSharedEntry.cs @@ -24,6 +24,8 @@ public Validator() RuleLevelCascadeMode = CascadeMode.Stop; RuleFor(x => x.Name) + .NotEmpty().WithMessage("Entry's name is required.") + .Matches("^[\\p{L}A-Za-z_.\\s\\-0-9]*$").WithMessage("Invalid name format.") .MaximumLength(256).WithMessage("Name cannot exceed 256 characters."); } }