diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs index 52db5120..c0fc717d 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Forum/CommentService.cs @@ -132,8 +132,8 @@ namespace Yi.Framework.Bbs.Application.Services.Forum /// /// /// - [Permission("bbs:comment:add")] - [Authorize] + // [Permission("bbs:comment:add")] + // [Authorize] public override async Task CreateAsync(CommentCreateInputVo input) { var discuess = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId); diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/CommentCreatedEventHandler.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/CommentCreatedEventHandler.cs index 80ae83df..a5496314 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/CommentCreatedEventHandler.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/CommentCreatedEventHandler.cs @@ -1,73 +1,73 @@ -using TencentCloud.Tbm.V20180129.Models; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Entities.Events; -using Volo.Abp.EventBus; -using Volo.Abp.EventBus.Local; -using Yi.Framework.Bbs.Domain.Entities; -using Yi.Framework.Bbs.Domain.Entities.Forum; -using Yi.Framework.Bbs.Domain.Shared.Consts; -using Yi.Framework.Bbs.Domain.Shared.Enums; -using Yi.Framework.Bbs.Domain.Shared.Etos; -using Yi.Framework.Rbac.Domain.Entities; -using Yi.Framework.SqlSugarCore.Abstractions; - -namespace Yi.Framework.Bbs.Domain.EventHandlers -{ - /// - /// 评论创建的领域事件 - /// - public class CommentCreatedEventHandler : ILocalEventHandler>, - ITransientDependency - { - private ILocalEventBus _localEventBus; - private ISqlSugarRepository _discussRepository; - private ISqlSugarRepository _userRepository; - public CommentCreatedEventHandler(ILocalEventBus localEventBus, ISqlSugarRepository discussRepository, ISqlSugarRepository userRepository) - { - _userRepository = userRepository; - _localEventBus = localEventBus; - _discussRepository = discussRepository; - } - public async Task HandleEventAsync(EntityCreatedEventData eventData) - { - var commentEntity = eventData.Entity; - - //给创建者发布数量+1 - await _userRepository._Db.Updateable() - .SetColumns(it => it.CommentNumber == it.CommentNumber + 1) - .Where(it => it.UserId == commentEntity.CreatorId) - .ExecuteCommandAsync(); - var disucssDto = await _discussRepository._DbQueryable - .Where(x => x.Id == commentEntity.DiscussId) - .LeftJoin((dicuss, user) => dicuss.CreatorId == user.Id) - .Select((dicuss, user) => - new - { - DiscussUserId = user.Id, - DiscussTitle = dicuss.Title, - - }) - .FirstAsync(); - - var commentUser = await _userRepository.GetFirstAsync(x => x.Id == commentEntity.CreatorId); - - //截取30个长度 - var content = commentEntity.Content.Length >= 30 ? commentEntity.Content.Substring(0, 30)+"..." : commentEntity.Content; - //通知主题作者,有人评论 - await _localEventBus.PublishAsync(new BbsNoticeEventArgs(disucssDto.DiscussUserId, string.Format(DiscussConst.CommentNotice, disucssDto.DiscussTitle, commentUser.UserName, content,commentEntity.DiscussId)), false); - - //如果为空,表示根路径,没有回复者 - if (commentEntity.ParentId != Guid.Empty) - { - //通知回复者,有人评论 - await _localEventBus.PublishAsync(new BbsNoticeEventArgs(commentEntity.ParentId, string.Format(DiscussConst.CommentNoticeToReply, disucssDto.DiscussTitle, commentUser.UserName, content,commentEntity.DiscussId)), false); - - } - - //最后发布任务触发事件 - await _localEventBus.PublishAsync( - new AssignmentEventArgs(AssignmentRequirementTypeEnum.Comment, commentUser.Id),false); - - } - } -} +// using TencentCloud.Tbm.V20180129.Models; +// using Volo.Abp.DependencyInjection; +// using Volo.Abp.Domain.Entities.Events; +// using Volo.Abp.EventBus; +// using Volo.Abp.EventBus.Local; +// using Yi.Framework.Bbs.Domain.Entities; +// using Yi.Framework.Bbs.Domain.Entities.Forum; +// using Yi.Framework.Bbs.Domain.Shared.Consts; +// using Yi.Framework.Bbs.Domain.Shared.Enums; +// using Yi.Framework.Bbs.Domain.Shared.Etos; +// using Yi.Framework.Rbac.Domain.Entities; +// using Yi.Framework.SqlSugarCore.Abstractions; +// +// namespace Yi.Framework.Bbs.Domain.EventHandlers +// { +// /// +// /// 评论创建的领域事件 +// /// +// public class CommentCreatedEventHandler : ILocalEventHandler>, +// ITransientDependency +// { +// private ILocalEventBus _localEventBus; +// private ISqlSugarRepository _discussRepository; +// private ISqlSugarRepository _userRepository; +// public CommentCreatedEventHandler(ILocalEventBus localEventBus, ISqlSugarRepository discussRepository, ISqlSugarRepository userRepository) +// { +// _userRepository = userRepository; +// _localEventBus = localEventBus; +// _discussRepository = discussRepository; +// } +// public async Task HandleEventAsync(EntityCreatedEventData eventData) +// { +// var commentEntity = eventData.Entity; +// +// //给创建者发布数量+1 +// await _userRepository._Db.Updateable() +// .SetColumns(it => it.CommentNumber == it.CommentNumber + 1) +// .Where(it => it.UserId == commentEntity.CreatorId) +// .ExecuteCommandAsync(); +// var disucssDto = await _discussRepository._DbQueryable +// .Where(x => x.Id == commentEntity.DiscussId) +// .LeftJoin((dicuss, user) => dicuss.CreatorId == user.Id) +// .Select((dicuss, user) => +// new +// { +// DiscussUserId = user.Id, +// DiscussTitle = dicuss.Title, +// +// }) +// .FirstAsync(); +// +// var commentUser = await _userRepository.GetFirstAsync(x => x.Id == commentEntity.CreatorId); +// +// //截取30个长度 +// var content = commentEntity.Content.Length >= 30 ? commentEntity.Content.Substring(0, 30)+"..." : commentEntity.Content; +// //通知主题作者,有人评论 +// await _localEventBus.PublishAsync(new BbsNoticeEventArgs(disucssDto.DiscussUserId, string.Format(DiscussConst.CommentNotice, disucssDto.DiscussTitle, commentUser.UserName, content,commentEntity.DiscussId)), false); +// +// //如果为空,表示根路径,没有回复者 +// if (commentEntity.ParentId != Guid.Empty) +// { +// //通知回复者,有人评论 +// await _localEventBus.PublishAsync(new BbsNoticeEventArgs(commentEntity.ParentId, string.Format(DiscussConst.CommentNoticeToReply, disucssDto.DiscussTitle, commentUser.UserName, content,commentEntity.DiscussId)), false); +// +// } +// +// //最后发布任务触发事件 +// await _localEventBus.PublishAsync( +// new AssignmentEventArgs(AssignmentRequirementTypeEnum.Comment, commentUser.Id),false); +// +// } +// } +// } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs index 52cdef2a..858a2ca6 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs @@ -41,7 +41,8 @@ namespace Yi.Framework.Bbs.Domain.Managers entity.Content = content; entity.ParentId = parentId; entity.RootId = rootId; - return await _commentRepository.InsertReturnEntityAsync(entity); + await _commentRepository.InsertAsync(entity); + return entity; } /// diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs index 2d08d6d4..c5bc8565 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs @@ -4,28 +4,30 @@ using Yi.Abp.Web; //创建日志,可使用{SourceContext}记录 Log.Logger = new LoggerConfiguration() -.MinimumLevel.Debug() -.MinimumLevel.Override("Microsoft", LogEventLevel.Information) -.MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error) -.MinimumLevel.Override("Quartz", LogEventLevel.Warning) -.Enrich.FromLogContext() -.WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug)) -.WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error)) -.WriteTo.Async(c => c.Console()) -.CreateLogger(); + .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) + .MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error) + .MinimumLevel.Override("Quartz", LogEventLevel.Warning) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, + restrictedToMinimumLevel: LogEventLevel.Debug)) + .WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, + restrictedToMinimumLevel: LogEventLevel.Error)) + .WriteTo.Async(c => c.Console()) + .CreateLogger(); try { Log.Information(""" + + __ ___ ______ _ + \ \ / (_) | ____| | | + \ \_/ / _ | |__ _ __ __ _ _ __ ___ _____ _____ _ __| | __ + \ / | | | __| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ / + | | | | | | | | | (_| | | | | | | __/\ V V / (_) | | | < + |_| |_| |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_\ - __ ___ ______ _ - \ \ / (_) | ____| | | - \ \_/ / _ | |__ _ __ __ _ _ __ ___ _____ _____ _ __| | __ - \ / | | | __| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ / - | | | | | | | | | (_| | | | | | | __/\ V V / (_) | | | < - |_| |_| |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_\ - - """); + """); Log.Information("Yi框架-Abp.vNext,启动!"); var builder = WebApplication.CreateBuilder(args); @@ -36,6 +38,18 @@ try builder.Host.UseSerilog(); await builder.Services.AddApplicationAsync(); var app = builder.Build(); + app.Use(async (http, next) => + { + var id = Guid.NewGuid(); + Console.WriteLine("之前-----" + id); + http.Response.OnStarting(() => + { + Console.WriteLine("之中-----" + id); + return Task.CompletedTask; + }); + await next(); + Console.WriteLine("之后-----" + id); + }); await app.InitializeApplicationAsync(); await app.RunAsync(); } diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index 2b1a2ebf..75e540bf 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -67,7 +67,7 @@ namespace Yi.Abp.Web Configure(optios => { //默认关闭,开启会有大量的审计日志 - optios.IsEnabled = true; + optios.IsEnabled = false; //审计日志过滤器 optios.AlwaysLogSelectors.Add(x => Task.FromResult(!x.Url.StartsWith("/api/app/file/"))); });