This commit is contained in:
2025-05-13 11:17:58 +08:00
parent aa58767c66
commit 4d83091c5c
3 changed files with 3 additions and 3 deletions

View File

@@ -21,7 +21,7 @@
public async Task<GetArticleQueryResponse> Handle(GetArticleQuery request, CancellationToken cancellationToken)
{
var article = await _db.Articles.FindAsync(request.Id);
if (article == null)
if (article == null|| article.Status== ArticleStatusEnum.Deleted)
{
throw new ArticleNotExistsException(request.Id);
}

View File

@@ -15,7 +15,7 @@
private readonly BlogDbContext _db = db;
public async Task<List<GetLatestArticlesQueryResponse>> Handle(GetLatestArticlesQuery request, CancellationToken cancellationToken)
{
var query = _db.Articles.AsNoTracking().Where(x=>x.Type==ArticleTypeEnum.Article).OrderByDescending(x => x.Id).Select(article =>
var query = _db.Articles.AsNoTracking().Where(x=>x.Type==ArticleTypeEnum.Article x.Status != ArticleStatusEnum.Deleted).OrderByDescending(x => x.Id).Select(article =>
new GetLatestArticlesQueryResponse(
article.Id,
article.Title,

View File

@@ -22,7 +22,7 @@
public async Task<GetPageQueryResponse> Handle(GetPageQuery request, CancellationToken cancellationToken)
{
var page = await _db.Articles.FindAsync(request.Id);
if (page == null)
if (page == null || page.Status == ArticleStatusEnum.Deleted)
{
throw new PageNotExistsException(request.Id);
}