From 96b9cad2f822b4060887be6e1c5f257ceac1db95 Mon Sep 17 00:00:00 2001 From: chenchun Date: Tue, 13 Aug 2024 16:45:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BD=93=E7=B3=BB=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssignmentDefineGetListOutputDto.cs | 7 +- .../Assignment/AssignmentGetListOutputDto.cs | 17 +++- .../Services/AssignmentService.cs | 30 ++++--- .../Enums/AssignmentRequirementTypeEnum.cs | 16 ++-- .../Etos/AssignmentEventArgs.cs | 30 +++++++ .../Assignment/AssignmentAggregateRoot.cs | 5 +- ...tHandler.cs => AgreeChangeEventHandler.cs} | 62 +++++++++------ .../EventHandlers/AssignmentEventHandler.cs | 78 +++++++++++++++++++ .../CommentCreatedEventHandler.cs | 5 ++ .../DiscussCreatedEventHandler.cs | 24 ++++-- .../Managers/AssignmentManager.cs | 7 +- Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs | 7 ++ 12 files changed, 233 insertions(+), 55 deletions(-) create mode 100644 Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Etos/AssignmentEventArgs.cs rename Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/{AgreeChangedEventHandler.cs => AgreeChangeEventHandler.cs} (55%) create mode 100644 Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AssignmentEventHandler.cs diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentDefineGetListOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentDefineGetListOutputDto.cs index e3a9effc..f651300c 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentDefineGetListOutputDto.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentDefineGetListOutputDto.cs @@ -19,7 +19,12 @@ public class AssignmentDefineGetListOutputDto : EntityDto /// 任务类型 /// public AssignmentTypeEnum AssignmentType { get; set; } - + + /// + /// 任务需求类型 + /// + public AssignmentRequirementTypeEnum AssignmentRequirementType{ get; set; } + /// /// 总共步骤数 /// diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentGetListOutputDto.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentGetListOutputDto.cs index 6a0026ea..08677acb 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentGetListOutputDto.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application.Contracts/Dtos/Assignment/AssignmentGetListOutputDto.cs @@ -5,7 +5,15 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Assignment; public class AssignmentGetListOutputDto:EntityDto { - + /// + /// 任务名称 + /// + public string Name { get; set; } + + /// + /// 备注 + /// + public string Remarks { get; set; } /// /// 当前步骤数 /// @@ -16,6 +24,11 @@ public class AssignmentGetListOutputDto:EntityDto /// public int TotalStepNumber { get; set; } + + /// + /// 任务需求类型 + /// + public AssignmentRequirementTypeEnum AssignmentRequirementType{ get; set; } /// /// 任务状态 /// @@ -33,6 +46,6 @@ public class AssignmentGetListOutputDto:EntityDto public DateTime? CompleteTime { get; set; } - public DateTime CreationTime { get; } + public DateTime CreationTime { get; set; } public int OrderNum { get; set; } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/AssignmentService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/AssignmentService.cs index 85f5db7c..4b427fc9 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/AssignmentService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/AssignmentService.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Services; using Volo.Abp.Users; using Yi.Framework.Bbs.Application.Contracts.Dtos.Assignment; +using Yi.Framework.Bbs.Domain.Entities.Assignment; using Yi.Framework.Bbs.Domain.Managers; using Yi.Framework.Bbs.Domain.Shared.Enums; @@ -27,7 +28,7 @@ public class AssignmentService : ApplicationService /// /// [HttpPost("assignment/accept/{id}")] - public async Task AcceptAsync([FromRoute]Guid id) + public async Task AcceptAsync([FromRoute] Guid id) { await _assignmentManager.AcceptAsync(CurrentUser.GetId(), id); } @@ -37,7 +38,7 @@ public class AssignmentService : ApplicationService /// /// [HttpPost("assignment/complete/{id}")] - public async Task ReceiveRewardsAsync([FromRoute]Guid id) + public async Task ReceiveRewardsAsync([FromRoute] Guid id) { await _assignmentManager.ReceiveRewardsAsync(id); } @@ -58,18 +59,23 @@ public class AssignmentService : ApplicationService /// 查询接受的任务 /// [HttpGet("assignment")] - public async Task> GetListAsync([FromQuery]AssignmentGetListInput input) + public async Task> GetListAsync([FromQuery] AssignmentGetListInput input) { - var entities= await _assignmentManager._assignmentRepository._DbQueryable - .Where(x => x.UserId == CurrentUser.GetId()) - .WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.Progress, - x => x.AssignmentState == AssignmentStateEnum.Progress) - .WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.End, - x => x.AssignmentState == AssignmentStateEnum.Completed || - x.AssignmentState == AssignmentStateEnum.Expired) - .ToListAsync(); + var output = await _assignmentManager._assignmentRepository._DbQueryable + .Where(x => x.UserId == CurrentUser.GetId()) + .WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.Progress, + x => x.AssignmentState == AssignmentStateEnum.Progress) + .WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.End, + x => x.AssignmentState == AssignmentStateEnum.Completed || + x.AssignmentState == AssignmentStateEnum.Expired) + .OrderBy(x=>x.CreationTime) + .LeftJoin((x, define) => x.AssignmentDefineId==define.Id) + .Select((x, define) => new AssignmentGetListOutputDto + { + Id = x.Id + },true) + .ToListAsync(); - var output= entities.Adapt>(); return output; } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentRequirementTypeEnum.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentRequirementTypeEnum.cs index 04aef002..4c7c9c88 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentRequirementTypeEnum.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentRequirementTypeEnum.cs @@ -12,15 +12,17 @@ public enum AssignmentRequirementTypeEnum /// Comment=4, - /// - /// 更新个人中心 - /// - UpdateProfile=8, - - /// /// 点赞 /// - Agree=16 + Agree=8, + + /// + /// 更新个人中心 + /// + UpdateProfile=16 + + + } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Etos/AssignmentEventArgs.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Etos/AssignmentEventArgs.cs new file mode 100644 index 00000000..240e7e50 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Etos/AssignmentEventArgs.cs @@ -0,0 +1,30 @@ +using Yi.Framework.Bbs.Domain.Shared.Enums; + +namespace Yi.Framework.Bbs.Domain.Shared.Etos; + +public class AssignmentEventArgs +{ + public AssignmentEventArgs(AssignmentRequirementTypeEnum requirementType, Guid currentUserId,object? args=null) + { + RequirementType = requirementType; + Args = args; + CurrentUserId = currentUserId; + } + + /// + /// 任务需求类型 + /// + public AssignmentRequirementTypeEnum RequirementType { get; set; } + + + /// + /// 任务参数,可空,只需要一个触发点即可 + /// + public object? Args { get; set; } + + + /// + /// 当前用户id + /// + public Guid CurrentUserId { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentAggregateRoot.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentAggregateRoot.cs index cb8b6361..efdf1dab 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentAggregateRoot.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentAggregateRoot.cs @@ -48,7 +48,10 @@ public class AssignmentAggregateRoot : AggregateRoot, IHasCreationTime, IO /// 任务过期时间 /// public DateTime? ExpireTime { get; set; } - + /// + /// 任务需求类型 + /// + public AssignmentRequirementTypeEnum AssignmentRequirementType{ get; set; } public DateTime? CompleteTime { get; set; } diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AgreeChangedEventHandler.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AgreeChangeEventHandler.cs similarity index 55% rename from Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AgreeChangedEventHandler.cs rename to Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AgreeChangeEventHandler.cs index 573ce9c5..fbad46be 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AgreeChangedEventHandler.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AgreeChangeEventHandler.cs @@ -5,6 +5,7 @@ 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; @@ -14,20 +15,24 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers /// /// 被点赞 /// - public class AgreeCreatedEventHandler : ILocalEventHandler>, - ITransientDependency + public class AgreeChangeEventHandler : ILocalEventHandler>, + ITransientDependency { private ISqlSugarRepository _userRepository; private ISqlSugarRepository _userInfoRepository; private ISqlSugarRepository _agreeRepository; private ILocalEventBus _localEventBus; - public AgreeCreatedEventHandler(ISqlSugarRepository userInfoRepository, ISqlSugarRepository agreeRepository, ILocalEventBus localEventBus, ISqlSugarRepository userRepository) + + public AgreeChangeEventHandler(ISqlSugarRepository userInfoRepository, + ISqlSugarRepository agreeRepository, ILocalEventBus localEventBus, + ISqlSugarRepository userRepository) { _userInfoRepository = userInfoRepository; _agreeRepository = agreeRepository; _localEventBus = localEventBus; _userRepository = userRepository; } + public async Task HandleEventAsync(EntityCreatedEventData eventData) { var agreeEntity = eventData.Entity; @@ -35,55 +40,66 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers //查询主题的信息 var discussAndAgreeDto = await _agreeRepository._DbQueryable .LeftJoin((agree, discuss) => agree.DiscussId == discuss.Id) - .Select((agree, discuss) => - new - { - DiscussId=discuss.Id, - DiscussTitle = discuss.Title, - DiscussCreatorId = discuss.CreatorId, - }) - .FirstAsync(); + .Select((agree, discuss) => + new + { + DiscussId = discuss.Id, + DiscussTitle = discuss.Title, + DiscussCreatorId = discuss.CreatorId, + }) + .FirstAsync(); //查询点赞者用户 var agreeUser = await _userRepository.GetFirstAsync(x => x.Id == agreeEntity.CreatorId); //给创建者点赞数量+1 await _userInfoRepository._Db.Updateable() - .SetColumns(it => it.AgreeNumber == it.AgreeNumber + 1) - .Where(it => it.UserId == discussAndAgreeDto.DiscussCreatorId) - .ExecuteCommandAsync(); + .SetColumns(it => it.AgreeNumber == it.AgreeNumber + 1) + .Where(it => it.UserId == discussAndAgreeDto.DiscussCreatorId) + .ExecuteCommandAsync(); //通知主题作者,有人点赞 - await _localEventBus.PublishAsync(new BbsNoticeEventArgs(discussAndAgreeDto.DiscussCreatorId!.Value, string.Format(DiscussConst.AgreeNotice, discussAndAgreeDto.DiscussTitle, agreeUser.UserName,discussAndAgreeDto.DiscussId)), false); + await _localEventBus.PublishAsync( + new BbsNoticeEventArgs(discussAndAgreeDto.DiscussCreatorId!.Value, + string.Format(DiscussConst.AgreeNotice, discussAndAgreeDto.DiscussTitle, agreeUser.UserName, + discussAndAgreeDto.DiscussId)), false); + //最后发布任务触发事件 + await _localEventBus.PublishAsync( + new AssignmentEventArgs(AssignmentRequirementTypeEnum.Agree, agreeUser.Id),false); } } + /// /// 取消点赞 /// public class AgreeDeletedEventHandler : ILocalEventHandler>, - ITransientDependency + ITransientDependency { private ISqlSugarRepository _userRepository; private ISqlSugarRepository _agreeRepository; private ILocalEventBus _localEventBus; - public AgreeDeletedEventHandler(ISqlSugarRepository userRepository, ISqlSugarRepository agreeRepository, ILocalEventBus localEventBus) + + public AgreeDeletedEventHandler(ISqlSugarRepository userRepository, + ISqlSugarRepository agreeRepository, ILocalEventBus localEventBus) { _userRepository = userRepository; _agreeRepository = agreeRepository; _localEventBus = localEventBus; } + public async Task HandleEventAsync(EntityDeletedEventData eventData) { var agreeEntity = eventData.Entity; - var userId = await _agreeRepository._DbQueryable.LeftJoin((agree, discuss) => agree.DiscussId == discuss.Id) - .Select((agree, discuss) => discuss.CreatorId).FirstAsync(); + var userId = await _agreeRepository._DbQueryable + .LeftJoin((agree, discuss) => agree.DiscussId == discuss.Id) + .Select((agree, discuss) => discuss.CreatorId).FirstAsync(); //给创建者点赞数量-1 await _userRepository._Db.Updateable() - .SetColumns(it => it.AgreeNumber == it.AgreeNumber - 1) - .Where(it => it.UserId == userId) - .ExecuteCommandAsync(); + .SetColumns(it => it.AgreeNumber == it.AgreeNumber - 1) + .Where(it => it.UserId == userId) + .ExecuteCommandAsync(); } } -} +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AssignmentEventHandler.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AssignmentEventHandler.cs new file mode 100644 index 00000000..9aaa45b4 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/AssignmentEventHandler.cs @@ -0,0 +1,78 @@ +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus; +using Yi.Framework.Bbs.Domain.Entities.Assignment; +using Yi.Framework.Bbs.Domain.Shared.Enums; +using Yi.Framework.Bbs.Domain.Shared.Etos; +using Yi.Framework.SqlSugarCore.Abstractions; + +namespace Yi.Framework.Bbs.Domain.EventHandlers; + +/// +/// 任务系统的领域事件,处理不同任务触发变化 +/// +public class AssignmentEventHandler : ILocalEventHandler, ITransientDependency +{ + private readonly ISqlSugarRepository _repository; + + public AssignmentEventHandler(ISqlSugarRepository repository) + { + _repository = repository; + } + + public async Task HandleEventAsync(AssignmentEventArgs eventData) + { + var currentAssignmentList = await _repository.GetListAsync(x => + x.AssignmentState == AssignmentStateEnum.Progress && x.UserId == eventData.CurrentUserId); + + //如果有接收的任务 + if (currentAssignmentList.Count > 0) + { + switch (eventData.RequirementType) + { + //发表主题 + case AssignmentRequirementTypeEnum.Discuss: + SetCurrentStepNumber(AssignmentRequirementTypeEnum.Discuss, currentAssignmentList); + break; + + //发表评论 + case AssignmentRequirementTypeEnum.Comment: + SetCurrentStepNumber(AssignmentRequirementTypeEnum.Comment, currentAssignmentList); + break; + + //点赞 + case AssignmentRequirementTypeEnum.Agree: + SetCurrentStepNumber(AssignmentRequirementTypeEnum.Agree, currentAssignmentList); + break; + + //更新个人信息 + case AssignmentRequirementTypeEnum.UpdateProfile: + //这里还需判断是否更新了 + break; + default: + throw new ArgumentOutOfRangeException(); + } + + + //更新 + await _repository.UpdateRangeAsync(currentAssignmentList); + } + } + + /// + /// 设置当前进度 + /// + /// + /// + private void SetCurrentStepNumber(AssignmentRequirementTypeEnum requirementType, + List currentAssignmentList) + { + currentAssignmentList.ForEach(x => + { + if (x.AssignmentRequirementType == AssignmentRequirementTypeEnum.Agree && + x.CurrentStepNumber < x.TotalStepNumber) + { + x.CurrentStepNumber += 1; + } + }); + } +} \ No newline at end of file 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 0c5f63c3..80ae83df 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 @@ -6,6 +6,7 @@ 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; @@ -62,6 +63,10 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers 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/EventHandlers/DiscussCreatedEventHandler.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/DiscussCreatedEventHandler.cs index fcebe0f5..9714eaed 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/DiscussCreatedEventHandler.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/EventHandlers/DiscussCreatedEventHandler.cs @@ -1,8 +1,11 @@ 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.Enums; +using Yi.Framework.Bbs.Domain.Shared.Etos; using Yi.Framework.SqlSugarCore.Abstractions; namespace Yi.Framework.Bbs.Domain.EventHandlers @@ -11,22 +14,31 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers /// 主题创建的领域事件 /// public class DiscussCreatedEventHandler : ILocalEventHandler>, - ITransientDependency + ITransientDependency { private ISqlSugarRepository _userRepository; - public DiscussCreatedEventHandler(ISqlSugarRepository userRepository) + private ILocalEventBus _localEventBus; + + public DiscussCreatedEventHandler(ISqlSugarRepository userRepository, + ILocalEventBus localEventBus) { _userRepository = userRepository; + _localEventBus = localEventBus; } + public async Task HandleEventAsync(EntityCreatedEventData eventData) { var disucussEntity = eventData.Entity; //给创建者发布数量+1 await _userRepository._Db.Updateable() - .SetColumns(it => it.DiscussNumber == it.DiscussNumber + 1) - .Where(it => it.UserId == disucussEntity.CreatorId) - .ExecuteCommandAsync(); + .SetColumns(it => it.DiscussNumber == it.DiscussNumber + 1) + .Where(it => it.UserId == disucussEntity.CreatorId) + .ExecuteCommandAsync(); + + //最后发布任务触发事件 + await _localEventBus.PublishAsync( + new AssignmentEventArgs(AssignmentRequirementTypeEnum.Discuss, disucussEntity.CreatorId!.Value), false); } } -} +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentManager.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentManager.cs index 58267821..5b8a8a47 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentManager.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentManager.cs @@ -52,6 +52,7 @@ public class AssignmentManager : DomainService entity.CurrentStepNumber = 0; entity.TotalStepNumber = assignmentDefine.TotalStepNumber; entity.RewardsMoneyNumber = assignmentDefine.RewardsMoneyNumber; + entity.AssignmentRequirementType = assignmentDefine.AssignmentRequirementType; entity.ExpireTime = assignmentDefine.AssignmentType.GetExpireTime(); await _assignmentRepository.InsertAsync(entity); } @@ -71,7 +72,7 @@ public class AssignmentManager : DomainService //加钱加钱 await _localEventBus.PublishAsync( new MoneyChangeEventArgs { UserId = assignment.UserId, Number = assignment.RewardsMoneyNumber }, false); - + //设置已完成,并领取奖励,钱钱 assignment.SetComplete(); await _assignmentRepository.UpdateAsync(assignment); @@ -79,7 +80,7 @@ public class AssignmentManager : DomainService else { //不能领取 - throw new UserFriendlyException("该任务无法领取奖励,请检查任务详情"); + throw new UserFriendlyException("该任务没有满足领取条件,请检查任务详情"); } } @@ -98,7 +99,7 @@ public class AssignmentManager : DomainService output.AddRange(await assignmentProvider.GetCanReceiveListAsync(context)); } - output.DistinctBy(x => x.Id); + output = output.DistinctBy(x => x.Id).OrderBy(x => x.OrderNum).ToList(); return output; } diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index 5ec09a9a..f9557819 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -7,6 +7,7 @@ using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi.Models; using Newtonsoft.Json.Converters; using Volo.Abp.AspNetCore.Authentication.JwtBearer; +using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.AntiForgery; @@ -68,6 +69,12 @@ namespace Yi.Abp.Web optios.AlwaysLogSelectors.Add(x => Task.FromResult(true)); }); + //配置错误处理显示详情 + Configure(options => + { + options.SendExceptionsDetailsToClients = true; + }); + //动态Api Configure(options => {