From 05ecb2d17e7a6a2eb7f3cfc85e82e7b8f2b29084 Mon Sep 17 00:00:00 2001 From: VillSource Date: Sat, 2 Mar 2024 16:34:38 +0700 Subject: [PATCH] mapping spacial article name - terms and policy --- .../Query/GetArticels/GetArticelsQueryHandeler.cs | 6 +++++- .../Article/Query/GetArticle/GetArticleQueryHandler.cs | 9 +++++++-- .../Query/GetTopArticles/GetTopArticlesQueryHandler.cs | 8 +++++++- .../Query/SerchArticle/SerchArticelsQueryHandeler.cs | 6 +++++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Src/Core/Application/Features/Article/Query/GetArticels/GetArticelsQueryHandeler.cs b/Src/Core/Application/Features/Article/Query/GetArticels/GetArticelsQueryHandeler.cs index a273b78..f9b6404 100644 --- a/Src/Core/Application/Features/Article/Query/GetArticels/GetArticelsQueryHandeler.cs +++ b/Src/Core/Application/Features/Article/Query/GetArticels/GetArticelsQueryHandeler.cs @@ -91,7 +91,11 @@ protected override async Task> Execute(GetArticel var col = res.Collections.Select(article => new GetArticelsQueryDto() { Id = Base64UrlEncoder.Encode(article.ID.ToByteArray()), - AuthorId = article.AuthorId, + AuthorId = article.AuthorId == "AAAAAAAAAECAAAAAAAAAAA" + ? "TermsAndPolicy" + : article.AuthorId == "EREREREREUGREREREREREQ" + ? "SupportedProgrammingLanguages" + : article.AuthorId, Title = article.Title, CoverImage = article.Cover, diff --git a/Src/Core/Application/Features/Article/Query/GetArticle/GetArticleQueryHandler.cs b/Src/Core/Application/Features/Article/Query/GetArticle/GetArticleQueryHandler.cs index fe3d61b..c5a12c4 100644 --- a/Src/Core/Application/Features/Article/Query/GetArticle/GetArticleQueryHandler.cs +++ b/Src/Core/Application/Features/Article/Query/GetArticle/GetArticleQueryHandler.cs @@ -1,4 +1,4 @@ -using Application.Common.Interfaces; +using Application.Common.Interfaces; using Application.Common.models; using Application.Common.Repositories; using MediatR; @@ -25,7 +25,12 @@ public GetArticleQueryHandler(IPostRepository repo) public async Task Handle( GetArticleQuery request, CancellationToken cancellationToken) { - var result = _repo.FindById(request.ArticleId, request.sub); + var result = _repo.FindById( + request.ArticleId == "TermsAndPolicy" + ? "AAAAAAAAAECAAAAAAAAAAA" + : request.ArticleId == "SupportedProgrammingLanguages" + ? "EREREREREUGREREREREREQ" + : request.ArticleId, request.sub); if (result.Exception is not null) return ResponseWrapper .Error(result.Exception, "Not Found."); diff --git a/Src/Core/Application/Features/Article/Query/GetTopArticles/GetTopArticlesQueryHandler.cs b/Src/Core/Application/Features/Article/Query/GetTopArticles/GetTopArticlesQueryHandler.cs index ba8fcec..159908d 100644 --- a/Src/Core/Application/Features/Article/Query/GetTopArticles/GetTopArticlesQueryHandler.cs +++ b/Src/Core/Application/Features/Article/Query/GetTopArticles/GetTopArticlesQueryHandler.cs @@ -21,7 +21,13 @@ protected async override Task> Execute(GetTopArti { var a = _articlesNameRepository.Top(request.n) .Select(i => new KeyValuePair - (Base64UrlEncoder.Encode(i.Key.ToByteArray()), i.Value)); + (Base64UrlEncoder.Encode(i.Key.ToByteArray()), i.Value)) + .Select(i => new KeyValuePair( + i.Key == "AAAAAAAAAECAAAAAAAAAAA" + ? "TermsAndPolicy" + : i.Key == "EREREREREUGREREREREREQ" + ? "SupportedProgrammingLanguages" + : i.Key, i.Value)); return Ok(a.ToList()); } } diff --git a/Src/Core/Application/Features/Article/Query/SerchArticle/SerchArticelsQueryHandeler.cs b/Src/Core/Application/Features/Article/Query/SerchArticle/SerchArticelsQueryHandeler.cs index d0deca9..29a7f4b 100644 --- a/Src/Core/Application/Features/Article/Query/SerchArticle/SerchArticelsQueryHandeler.cs +++ b/Src/Core/Application/Features/Article/Query/SerchArticle/SerchArticelsQueryHandeler.cs @@ -48,7 +48,11 @@ protected override async Task> Execute(SerchArtic // maping model var col = res.Collections.Select(article => new SerchArticelsQueryDto() { - Id = Base64UrlEncoder.Encode(article.ID.ToByteArray()), + Id = Base64UrlEncoder.Encode(article.ID.ToByteArray()) == "AAAAAAAAAECAAAAAAAAAAA" + ? "TermsAndPolicy" + : Base64UrlEncoder.Encode(article.ID.ToByteArray()) == "EREREREREUGREREREREREQ" + ? "SupportedProgrammingLanguages" + : Base64UrlEncoder.Encode(article.ID.ToByteArray()), AuthorId = article.AuthorId, Title = article.Title,