From 951536357ac70300062daa629f4da14ddc1c58c1 Mon Sep 17 00:00:00 2001 From: zpc Date: Mon, 23 Feb 2026 13:09:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(content):=20=E4=BF=AE=E5=A4=8DContentServic?= =?UTF-8?q?e.cs=E7=BC=96=E7=A0=81=E6=8D=9F=E5=9D=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重写整个文件修复UTF-8编码损坏的中文字符 - 所有中文字符串已恢复正确内容 - 修复因PowerShell Set-Content导致的乱码问题 --- .../Services/ContentService.cs | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/server/MiAssessment/src/MiAssessment.Admin.Business/Services/ContentService.cs b/server/MiAssessment/src/MiAssessment.Admin.Business/Services/ContentService.cs index 12f4e89..c0c3320 100644 --- a/server/MiAssessment/src/MiAssessment.Admin.Business/Services/ContentService.cs +++ b/server/MiAssessment/src/MiAssessment.Admin.Business/Services/ContentService.cs @@ -22,14 +22,14 @@ public class ContentService : IContentService /// private static readonly Dictionary LinkTypeNames = new() { - { 0, "? }, + { 0, "无" }, { 1, "内部页面" }, { 2, "外部链接" }, - { 3, "小程? } + { 3, "小程序" } }; /// - /// 状态名称映? + /// 状态名称映射 /// private static readonly Dictionary StatusNames = new() { @@ -38,19 +38,19 @@ public class ContentService : IContentService }; /// - /// 宣传图位置名称映? + /// 宣传图位置名称映射 /// private static readonly Dictionary PositionNames = new() { { 1, "首页底部" }, - { 2, "团队? } + { 2, "团队页" } }; /// - /// 构造函? + /// 构造函数 /// /// 数据库上下文 - /// 日志记录?/param> + /// 日志记录器 public ContentService( AdminBusinessDbContext dbContext, ILogger logger) @@ -59,7 +59,7 @@ public class ContentService : IContentService _logger = logger; } - #region Banner 轮播图操? + #region Banner 轮播图操作 /// public async Task> GetBannerListAsync(BannerQueryRequest request) @@ -69,7 +69,7 @@ public class ContentService : IContentService .AsNoTracking() .Where(b => !b.IsDeleted); - // 状态筛? + // 状态筛选 if (request.Status.HasValue) { query = query.Where(b => b.Status == request.Status.Value); @@ -142,7 +142,7 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.BannerImageRequired, "图片URL不能为空"); } - // 验证 LinkType 和对应字? + // 验证 LinkType 和对应字段 ValidateLinkType(request.LinkType, request.LinkUrl, request.AppId); // 创建实体 @@ -171,7 +171,7 @@ public class ContentService : IContentService /// public async Task UpdateBannerAsync(UpdateBannerRequest request) { - // 查找轮播? + // 查找轮播图 var banner = await _dbContext.Banners .Where(b => b.Id == request.Id && !b.IsDeleted) .FirstOrDefaultAsync(); @@ -187,7 +187,7 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.BannerImageRequired, "图片URL不能为空"); } - // 验证 LinkType 和对应字? + // 验证 LinkType 和对应字段 ValidateLinkType(request.LinkType, request.LinkUrl, request.AppId); // 更新字段 @@ -210,7 +210,7 @@ public class ContentService : IContentService /// public async Task DeleteBannerAsync(long id) { - // 查找轮播? + // 查找轮播图 var banner = await _dbContext.Banners .Where(b => b.Id == id && !b.IsDeleted) .FirstOrDefaultAsync(); @@ -220,7 +220,7 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.BannerNotFound, "轮播图不存在"); } - // 软删? + // 软删除 banner.IsDeleted = true; banner.UpdateTime = DateTime.Now; @@ -234,7 +234,7 @@ public class ContentService : IContentService /// public async Task UpdateBannerStatusAsync(long id, int status) { - // 查找轮播? + // 查找轮播图 var banner = await _dbContext.Banners .Where(b => b.Id == id && !b.IsDeleted) .FirstOrDefaultAsync(); @@ -244,13 +244,13 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.BannerNotFound, "轮播图不存在"); } - // 更新状? + // 更新状态 banner.Status = status; banner.UpdateTime = DateTime.Now; await _dbContext.SaveChangesAsync(); - _logger.LogInformation("更新轮播图状态成功,ID: {BannerId}, 状? {Status}", id, status); + _logger.LogInformation("更新轮播图状态成功,ID: {BannerId}, 状态: {Status}", id, status); return true; } @@ -266,7 +266,7 @@ public class ContentService : IContentService // 获取所有需要更新的轮播图ID var ids = items.Select(i => i.Id).ToList(); - // 批量查询轮播? + // 批量查询轮播图 var banners = await _dbContext.Banners .Where(b => ids.Contains(b.Id) && !b.IsDeleted) .ToListAsync(); @@ -291,7 +291,7 @@ public class ContentService : IContentService #endregion - #region Promotion 宣传图操? + #region Promotion 宣传图操作 /// public async Task> GetPromotionListAsync(PromotionQueryRequest request) @@ -301,13 +301,13 @@ public class ContentService : IContentService .AsNoTracking() .Where(p => !p.IsDeleted); - // 位置筛? + // 位置筛选 if (request.Position.HasValue) { query = query.Where(p => p.Position == request.Position.Value); } - // 状态筛? + // 状态筛选 if (request.Status.HasValue) { query = query.Where(p => p.Status == request.Status.Value); @@ -376,7 +376,7 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.PromotionImageRequired, "图片URL不能为空"); } - // 验证 Position ? + // 验证 Position 值 ValidatePosition(request.Position); // 创建实体 @@ -404,7 +404,7 @@ public class ContentService : IContentService /// public async Task UpdatePromotionAsync(UpdatePromotionRequest request) { - // 查找宣传? + // 查找宣传图 var promotion = await _dbContext.Promotions .Where(p => p.Id == request.Id && !p.IsDeleted) .FirstOrDefaultAsync(); @@ -420,7 +420,7 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.PromotionImageRequired, "图片URL不能为空"); } - // 验证 Position ? + // 验证 Position 值 ValidatePosition(request.Position); // 更新字段 @@ -441,7 +441,7 @@ public class ContentService : IContentService /// public async Task DeletePromotionAsync(long id) { - // 查找宣传? + // 查找宣传图 var promotion = await _dbContext.Promotions .Where(p => p.Id == id && !p.IsDeleted) .FirstOrDefaultAsync(); @@ -451,7 +451,7 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.PromotionNotFound, "宣传图不存在"); } - // 软删? + // 软删除 promotion.IsDeleted = true; promotion.UpdateTime = DateTime.Now; @@ -465,7 +465,7 @@ public class ContentService : IContentService /// public async Task UpdatePromotionStatusAsync(long id, int status) { - // 查找宣传? + // 查找宣传图 var promotion = await _dbContext.Promotions .Where(p => p.Id == id && !p.IsDeleted) .FirstOrDefaultAsync(); @@ -475,13 +475,13 @@ public class ContentService : IContentService throw new BusinessException(ErrorCodes.PromotionNotFound, "宣传图不存在"); } - // 更新状? + // 更新状态 promotion.Status = status; promotion.UpdateTime = DateTime.Now; await _dbContext.SaveChangesAsync(); - _logger.LogInformation("更新宣传图状态成功,ID: {PromotionId}, 状? {Status}", id, status); + _logger.LogInformation("更新宣传图状态成功,ID: {PromotionId}, 状态: {Status}", id, status); return true; } @@ -491,7 +491,7 @@ public class ContentService : IContentService #region 私有方法 /// - /// 验证 LinkType 和对应字? + /// 验证 LinkType 和对应字段 /// /// 跳转类型 /// 跳转地址 @@ -501,7 +501,7 @@ public class ContentService : IContentService switch (linkType) { case 0: - // 无跳转,不需要验? + // 无跳转,不需要验证 break; case 1: case 2: @@ -512,7 +512,7 @@ public class ContentService : IContentService } break; case 3: - // 小程序,LinkUrl ?AppId 都必? + // 小程序,LinkUrl 和 AppId 都必填 if (string.IsNullOrWhiteSpace(linkUrl)) { throw new BusinessException(ErrorCodes.BannerLinkUrlRequired, "跳转地址不能为空"); @@ -536,10 +536,10 @@ public class ContentService : IContentService } /// - /// 获取状态名? + /// 获取状态名称 /// - /// 状态?/param> - /// 状态名?/returns> + /// 状态值 + /// 状态名称 private static string GetStatusName(int status) { return StatusNames.TryGetValue(status, out var name) ? name : "未知"; @@ -548,7 +548,7 @@ public class ContentService : IContentService /// /// 获取位置名称 /// - /// 位置?/param> + /// 位置值 /// 位置名称 private static string GetPositionName(int position) { @@ -556,23 +556,23 @@ public class ContentService : IContentService } /// - /// 导航状态名称映? + /// 导航状态名称映射 /// private static readonly Dictionary NavigationStatusNames = new() { { 0, "即将上线" }, - { 1, "已上? } + { 1, "已上线" } }; /// - /// 验证 Position ? + /// 验证 Position 值 /// - /// 位置?/param> + /// 位置值 private void ValidatePosition(int position) { if (position != 1 && position != 2) { - throw new BusinessException(ErrorCodes.ParamError, "位置值必须为1(首页底部)?(团队页?); + throw new BusinessException(ErrorCodes.ParamError, "位置值必须为1(首页底部)或2(团队页)"); } } @@ -641,7 +641,7 @@ public class ContentService : IContentService if (nav == null) { - throw new BusinessException(ErrorCodes.NavigationNotFound, "首页导航不存?); + throw new BusinessException(ErrorCodes.NavigationNotFound, "首页导航不存在"); } return nav; @@ -683,7 +683,7 @@ public class ContentService : IContentService if (entity == null) { - throw new BusinessException(ErrorCodes.NavigationNotFound, "首页导航不存?); + throw new BusinessException(ErrorCodes.NavigationNotFound, "首页导航不存在"); } if (string.IsNullOrWhiteSpace(request.Name)) @@ -727,14 +727,14 @@ public class ContentService : IContentService if (entity == null) { - throw new BusinessException(ErrorCodes.NavigationNotFound, "首页导航不存?); + throw new BusinessException(ErrorCodes.NavigationNotFound, "首页导航不存在"); } entity.Status = status; entity.UpdateTime = DateTime.Now; await _dbContext.SaveChangesAsync(); - _logger.LogInformation("更新首页导航状态成功,ID: {Id}, 状? {Status}", id, status); + _logger.LogInformation("更新首页导航状态成功,ID: {Id}, 状态: {Status}", id, status); return true; }