1- using IGeekFan . FreeKit . Extras . Dto ;
1+ using AutoMapper ;
2+ using IGeekFan . FreeKit . Extras . Dto ;
23using IGeekFan . FreeKit . Extras . FreeSql ;
34using LinCms . Blog . Classifys ;
45using LinCms . Blog . UserSubscribes ;
1011using LinCms . Extensions ;
1112using LinCms . IRepositories ;
1213using LinCms . Security ;
14+ using Microsoft . AspNetCore . Mvc ;
1315using System ;
1416using System . Collections . Generic ;
1517using System . Linq ;
@@ -126,7 +128,7 @@ public async Task DeleteAsync(Guid id)
126128 }
127129 }
128130
129- await articleRepository . DeleteAsync ( new Article { Id = id } ) ;
131+ await articleRepository . DeleteAsync ( new Article { Id = id } ) ;
130132 await tagArticleRepository . DeleteAsync ( r => r . ArticleId == id ) ;
131133 await commentRepository . DeleteAsync ( r => r . SubjectId == id ) ;
132134 await userLikeRepository . DeleteAsync ( r => r . SubjectId == id ) ;
@@ -175,7 +177,7 @@ public async Task<Guid> CreateAsync(CreateUpdateArticleDto createArticle)
175177 Article article = Mapper . Map < Article > ( createArticle ) ;
176178 article . Archive = DateTime . Now . ToString ( "yyy年MM月" ) ;
177179 article . WordNumber = createArticle . Content . Length ;
178- article . ReadingTime = ( long ) TextAnalysisUtil . GetReadingTime ( createArticle . Content ) . Minutes ;
180+ article . ReadingTime = ( long ) TextAnalysisUtil . GetReadingTime ( createArticle . Content ) . Minutes ;
179181
180182 article . Tags = new List < Tag > ( ) ;
181183 foreach ( var articleTagId in createArticle . TagIds )
@@ -224,7 +226,7 @@ public async Task UpdateAsync(Guid id, CreateUpdateArticleDto updateArticleDto)
224226
225227 Mapper . Map ( updateArticleDto , article ) ;
226228 article . WordNumber = article . Content . Length ;
227- article . ReadingTime = ( long ) TextAnalysisUtil . GetReadingTime ( article . Content ) . Minutes ;
229+ article . ReadingTime = ( long ) TextAnalysisUtil . GetReadingTime ( article . Content ) . Minutes ;
228230 await articleRepository . UpdateAsync ( article ) ;
229231
230232 ArticleDraft articleDraft = Mapper . Map < ArticleDraft > ( article ) ;
@@ -243,6 +245,22 @@ public async Task UpdateAsync(Guid id, CreateUpdateArticleDto updateArticleDto)
243245
244246 #endregion
245247
248+
249+ public async Task < PagedResultDto < ArticleListDto > > GetAllArticleAsync ( ArticleSearchDto searchDto )
250+ {
251+ var articles = ( await articleRepository
252+ . Select
253+ . WhereCascade ( r => r . IsDeleted == false )
254+ . WhereIf ( searchDto . ArticleId . HasValue , r => r . Id == searchDto . ArticleId )
255+ . WhereIf ( searchDto . Title . IsNotNullOrEmpty ( ) , r => r . Title . Contains ( searchDto . Title ) )
256+ . OrderByDescending ( r => r . CreateTime )
257+ . ToPagerListAsync ( searchDto , out long totalCount ) )
258+ . Select ( a => Mapper . Map < ArticleListDto > ( a ) )
259+ . ToList ( ) ;
260+
261+ return new PagedResultDto < ArticleListDto > ( articles , totalCount ) ;
262+ }
263+
246264 /// <summary>
247265 /// 随笔选择多个标签
248266 /// </summary>
0 commit comments