From 98dddd684b34aa4ef6adde114e8ae3535d19bfa9 Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 8 Feb 2026 01:43:11 +0800 Subject: [PATCH] 321 --- .../Services/DanyeService.cs | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/DanyeService.cs b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/DanyeService.cs index 63e94830..32511cde 100644 --- a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/DanyeService.cs +++ b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/DanyeService.cs @@ -15,12 +15,6 @@ public class DanyeService : IDanyeService private readonly HoneyBoxDbContext _dbContext; private readonly ILogger _logger; - /// - /// 标题不可编辑的ID范围(2-20) - /// - private const int TitleEditableMinId = 2; - private const int TitleEditableMaxId = 20; - public DanyeService( HoneyBoxDbContext dbContext, ILogger logger) @@ -62,7 +56,7 @@ public class DanyeService : IDanyeService Title = danye.Title, Content = danye.Content, IsImageOptimizer = danye.IsImageOptimizer == 1, - IsTitleEditable = !IsTitleProtected(danye.Id) + IsTitleEditable = true // 所有单页标题都可编辑 }; } @@ -82,18 +76,10 @@ public class DanyeService : IDanyeService throw new BusinessException(BusinessErrorCodes.ValidationFailed, "内容不能为空"); } - // 更新标题(仅当ID不在2-20范围内且提供了标题时) + // 更新标题 if (!string.IsNullOrWhiteSpace(request.Title)) { - if (IsTitleProtected(id)) - { - _logger.LogWarning("尝试修改受保护的单页标题: Id={Id}", id); - // 不抛出异常,只是忽略标题更新 - } - else - { - danye.Title = request.Title; - } + danye.Title = request.Title; } // 更新内容 @@ -156,12 +142,6 @@ public class DanyeService : IDanyeService throw new BusinessException(BusinessErrorCodes.NotFound, "单页不存在"); } - // 系统预设单页(ID 2-20)不允许删除 - if (IsTitleProtected(id)) - { - throw new BusinessException(BusinessErrorCodes.ValidationFailed, "系统预设单页不允许删除"); - } - _dbContext.Danyes.Remove(danye); var result = await _dbContext.SaveChangesAsync() > 0; @@ -172,14 +152,6 @@ public class DanyeService : IDanyeService #region Private Helper Methods - /// - /// 判断标题是否受保护(ID 2-20 的单页标题不可编辑) - /// - private static bool IsTitleProtected(int id) - { - return id >= TitleEditableMinId && id <= TitleEditableMaxId; - } - /// /// Unix时间戳转DateTime ///