feat: 完成任务体系搭建
This commit is contained in:
@@ -19,7 +19,12 @@ public class AssignmentDefineGetListOutputDto : EntityDto<Guid>
|
|||||||
/// 任务类型
|
/// 任务类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AssignmentTypeEnum AssignmentType { get; set; }
|
public AssignmentTypeEnum AssignmentType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务需求类型
|
||||||
|
/// </summary>
|
||||||
|
public AssignmentRequirementTypeEnum AssignmentRequirementType{ get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 总共步骤数
|
/// 总共步骤数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Assignment;
|
|||||||
|
|
||||||
public class AssignmentGetListOutputDto:EntityDto<Guid>
|
public class AssignmentGetListOutputDto:EntityDto<Guid>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 任务名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string Remarks { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前步骤数
|
/// 当前步骤数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -16,6 +24,11 @@ public class AssignmentGetListOutputDto:EntityDto<Guid>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int TotalStepNumber { get; set; }
|
public int TotalStepNumber { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务需求类型
|
||||||
|
/// </summary>
|
||||||
|
public AssignmentRequirementTypeEnum AssignmentRequirementType{ get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 任务状态
|
/// 任务状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -33,6 +46,6 @@ public class AssignmentGetListOutputDto:EntityDto<Guid>
|
|||||||
public DateTime? CompleteTime { get; set; }
|
public DateTime? CompleteTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public DateTime CreationTime { get; }
|
public DateTime CreationTime { get; set; }
|
||||||
public int OrderNum { get; set; }
|
public int OrderNum { get; set; }
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Volo.Abp.Application.Services;
|
using Volo.Abp.Application.Services;
|
||||||
using Volo.Abp.Users;
|
using Volo.Abp.Users;
|
||||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Assignment;
|
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.Managers;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ public class AssignmentService : ApplicationService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
[HttpPost("assignment/accept/{id}")]
|
[HttpPost("assignment/accept/{id}")]
|
||||||
public async Task AcceptAsync([FromRoute]Guid id)
|
public async Task AcceptAsync([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
await _assignmentManager.AcceptAsync(CurrentUser.GetId(), id);
|
await _assignmentManager.AcceptAsync(CurrentUser.GetId(), id);
|
||||||
}
|
}
|
||||||
@@ -37,7 +38,7 @@ public class AssignmentService : ApplicationService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
[HttpPost("assignment/complete/{id}")]
|
[HttpPost("assignment/complete/{id}")]
|
||||||
public async Task ReceiveRewardsAsync([FromRoute]Guid id)
|
public async Task ReceiveRewardsAsync([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
await _assignmentManager.ReceiveRewardsAsync(id);
|
await _assignmentManager.ReceiveRewardsAsync(id);
|
||||||
}
|
}
|
||||||
@@ -58,18 +59,23 @@ public class AssignmentService : ApplicationService
|
|||||||
/// 查询接受的任务
|
/// 查询接受的任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpGet("assignment")]
|
[HttpGet("assignment")]
|
||||||
public async Task<List<AssignmentGetListOutputDto>> GetListAsync([FromQuery]AssignmentGetListInput input)
|
public async Task<List<AssignmentGetListOutputDto>> GetListAsync([FromQuery] AssignmentGetListInput input)
|
||||||
{
|
{
|
||||||
var entities= await _assignmentManager._assignmentRepository._DbQueryable
|
var output = await _assignmentManager._assignmentRepository._DbQueryable
|
||||||
.Where(x => x.UserId == CurrentUser.GetId())
|
.Where(x => x.UserId == CurrentUser.GetId())
|
||||||
.WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.Progress,
|
.WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.Progress,
|
||||||
x => x.AssignmentState == AssignmentStateEnum.Progress)
|
x => x.AssignmentState == AssignmentStateEnum.Progress)
|
||||||
.WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.End,
|
.WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.End,
|
||||||
x => x.AssignmentState == AssignmentStateEnum.Completed ||
|
x => x.AssignmentState == AssignmentStateEnum.Completed ||
|
||||||
x.AssignmentState == AssignmentStateEnum.Expired)
|
x.AssignmentState == AssignmentStateEnum.Expired)
|
||||||
.ToListAsync();
|
.OrderBy(x=>x.CreationTime)
|
||||||
|
.LeftJoin<AssignmentDefineAggregateRoot>((x, define) => x.AssignmentDefineId==define.Id)
|
||||||
|
.Select((x, define) => new AssignmentGetListOutputDto
|
||||||
|
{
|
||||||
|
Id = x.Id
|
||||||
|
},true)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
var output= entities.Adapt<List<AssignmentGetListOutputDto>>();
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,15 +12,17 @@ public enum AssignmentRequirementTypeEnum
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Comment=4,
|
Comment=4,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新个人中心
|
|
||||||
/// </summary>
|
|
||||||
UpdateProfile=8,
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 点赞
|
/// 点赞
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Agree=16
|
Agree=8,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新个人中心
|
||||||
|
/// </summary>
|
||||||
|
UpdateProfile=16
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务需求类型
|
||||||
|
/// </summary>
|
||||||
|
public AssignmentRequirementTypeEnum RequirementType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务参数,可空,只需要一个触发点即可
|
||||||
|
/// </summary>
|
||||||
|
public object? Args { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid CurrentUserId { get; set; }
|
||||||
|
}
|
||||||
@@ -48,7 +48,10 @@ public class AssignmentAggregateRoot : AggregateRoot<Guid>, IHasCreationTime, IO
|
|||||||
/// 任务过期时间
|
/// 任务过期时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? ExpireTime { get; set; }
|
public DateTime? ExpireTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 任务需求类型
|
||||||
|
/// </summary>
|
||||||
|
public AssignmentRequirementTypeEnum AssignmentRequirementType{ get; set; }
|
||||||
public DateTime? CompleteTime { get; set; }
|
public DateTime? CompleteTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Volo.Abp.EventBus.Local;
|
|||||||
using Yi.Framework.Bbs.Domain.Entities;
|
using Yi.Framework.Bbs.Domain.Entities;
|
||||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||||
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||||
using Yi.Framework.Rbac.Domain.Entities;
|
using Yi.Framework.Rbac.Domain.Entities;
|
||||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
@@ -14,20 +15,24 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 被点赞
|
/// 被点赞
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AgreeCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<AgreeEntity>>,
|
public class AgreeChangeEventHandler : ILocalEventHandler<EntityCreatedEventData<AgreeEntity>>,
|
||||||
ITransientDependency
|
ITransientDependency
|
||||||
{
|
{
|
||||||
private ISqlSugarRepository<UserAggregateRoot> _userRepository;
|
private ISqlSugarRepository<UserAggregateRoot> _userRepository;
|
||||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userInfoRepository;
|
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userInfoRepository;
|
||||||
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
||||||
private ILocalEventBus _localEventBus;
|
private ILocalEventBus _localEventBus;
|
||||||
public AgreeCreatedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userInfoRepository, ISqlSugarRepository<AgreeEntity> agreeRepository, ILocalEventBus localEventBus, ISqlSugarRepository<UserAggregateRoot> userRepository)
|
|
||||||
|
public AgreeChangeEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userInfoRepository,
|
||||||
|
ISqlSugarRepository<AgreeEntity> agreeRepository, ILocalEventBus localEventBus,
|
||||||
|
ISqlSugarRepository<UserAggregateRoot> userRepository)
|
||||||
{
|
{
|
||||||
_userInfoRepository = userInfoRepository;
|
_userInfoRepository = userInfoRepository;
|
||||||
_agreeRepository = agreeRepository;
|
_agreeRepository = agreeRepository;
|
||||||
_localEventBus = localEventBus;
|
_localEventBus = localEventBus;
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleEventAsync(EntityCreatedEventData<AgreeEntity> eventData)
|
public async Task HandleEventAsync(EntityCreatedEventData<AgreeEntity> eventData)
|
||||||
{
|
{
|
||||||
var agreeEntity = eventData.Entity;
|
var agreeEntity = eventData.Entity;
|
||||||
@@ -35,55 +40,66 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
|||||||
//查询主题的信息
|
//查询主题的信息
|
||||||
var discussAndAgreeDto = await _agreeRepository._DbQueryable
|
var discussAndAgreeDto = await _agreeRepository._DbQueryable
|
||||||
.LeftJoin<DiscussAggregateRoot>((agree, discuss) => agree.DiscussId == discuss.Id)
|
.LeftJoin<DiscussAggregateRoot>((agree, discuss) => agree.DiscussId == discuss.Id)
|
||||||
.Select((agree, discuss) =>
|
.Select((agree, discuss) =>
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
DiscussId=discuss.Id,
|
DiscussId = discuss.Id,
|
||||||
DiscussTitle = discuss.Title,
|
DiscussTitle = discuss.Title,
|
||||||
DiscussCreatorId = discuss.CreatorId,
|
DiscussCreatorId = discuss.CreatorId,
|
||||||
})
|
})
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
//查询点赞者用户
|
//查询点赞者用户
|
||||||
var agreeUser = await _userRepository.GetFirstAsync(x => x.Id == agreeEntity.CreatorId);
|
var agreeUser = await _userRepository.GetFirstAsync(x => x.Id == agreeEntity.CreatorId);
|
||||||
|
|
||||||
//给创建者点赞数量+1
|
//给创建者点赞数量+1
|
||||||
await _userInfoRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
await _userInfoRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||||
.SetColumns(it => it.AgreeNumber == it.AgreeNumber + 1)
|
.SetColumns(it => it.AgreeNumber == it.AgreeNumber + 1)
|
||||||
.Where(it => it.UserId == discussAndAgreeDto.DiscussCreatorId)
|
.Where(it => it.UserId == discussAndAgreeDto.DiscussCreatorId)
|
||||||
.ExecuteCommandAsync();
|
.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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 取消点赞
|
/// 取消点赞
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AgreeDeletedEventHandler : ILocalEventHandler<EntityDeletedEventData<AgreeEntity>>,
|
public class AgreeDeletedEventHandler : ILocalEventHandler<EntityDeletedEventData<AgreeEntity>>,
|
||||||
ITransientDependency
|
ITransientDependency
|
||||||
{
|
{
|
||||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
||||||
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
||||||
private ILocalEventBus _localEventBus;
|
private ILocalEventBus _localEventBus;
|
||||||
public AgreeDeletedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository, ISqlSugarRepository<AgreeEntity> agreeRepository, ILocalEventBus localEventBus)
|
|
||||||
|
public AgreeDeletedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository,
|
||||||
|
ISqlSugarRepository<AgreeEntity> agreeRepository, ILocalEventBus localEventBus)
|
||||||
{
|
{
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
_agreeRepository = agreeRepository;
|
_agreeRepository = agreeRepository;
|
||||||
_localEventBus = localEventBus;
|
_localEventBus = localEventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleEventAsync(EntityDeletedEventData<AgreeEntity> eventData)
|
public async Task HandleEventAsync(EntityDeletedEventData<AgreeEntity> eventData)
|
||||||
{
|
{
|
||||||
var agreeEntity = eventData.Entity;
|
var agreeEntity = eventData.Entity;
|
||||||
var userId = await _agreeRepository._DbQueryable.LeftJoin<DiscussAggregateRoot>((agree, discuss) => agree.DiscussId == discuss.Id)
|
var userId = await _agreeRepository._DbQueryable
|
||||||
.Select((agree, discuss) => discuss.CreatorId).FirstAsync();
|
.LeftJoin<DiscussAggregateRoot>((agree, discuss) => agree.DiscussId == discuss.Id)
|
||||||
|
.Select((agree, discuss) => discuss.CreatorId).FirstAsync();
|
||||||
|
|
||||||
//给创建者点赞数量-1
|
//给创建者点赞数量-1
|
||||||
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||||
.SetColumns(it => it.AgreeNumber == it.AgreeNumber - 1)
|
.SetColumns(it => it.AgreeNumber == it.AgreeNumber - 1)
|
||||||
.Where(it => it.UserId == userId)
|
.Where(it => it.UserId == userId)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务系统的领域事件,处理不同任务触发变化
|
||||||
|
/// </summary>
|
||||||
|
public class AssignmentEventHandler : ILocalEventHandler<AssignmentEventArgs>, ITransientDependency
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarRepository<AssignmentAggregateRoot> _repository;
|
||||||
|
|
||||||
|
public AssignmentEventHandler(ISqlSugarRepository<AssignmentAggregateRoot> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置当前进度
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requirementType"></param>
|
||||||
|
/// <param name="currentAssignmentList"></param>
|
||||||
|
private void SetCurrentStepNumber(AssignmentRequirementTypeEnum requirementType,
|
||||||
|
List<AssignmentAggregateRoot> currentAssignmentList)
|
||||||
|
{
|
||||||
|
currentAssignmentList.ForEach(x =>
|
||||||
|
{
|
||||||
|
if (x.AssignmentRequirementType == AssignmentRequirementTypeEnum.Agree &&
|
||||||
|
x.CurrentStepNumber < x.TotalStepNumber)
|
||||||
|
{
|
||||||
|
x.CurrentStepNumber += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ using Volo.Abp.EventBus.Local;
|
|||||||
using Yi.Framework.Bbs.Domain.Entities;
|
using Yi.Framework.Bbs.Domain.Entities;
|
||||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||||
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||||
using Yi.Framework.Rbac.Domain.Entities;
|
using Yi.Framework.Rbac.Domain.Entities;
|
||||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
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 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
using Volo.Abp.Domain.Entities.Events;
|
using Volo.Abp.Domain.Entities.Events;
|
||||||
using Volo.Abp.EventBus;
|
using Volo.Abp.EventBus;
|
||||||
|
using Volo.Abp.EventBus.Local;
|
||||||
using Yi.Framework.Bbs.Domain.Entities;
|
using Yi.Framework.Bbs.Domain.Entities;
|
||||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
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;
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
|
|
||||||
namespace Yi.Framework.Bbs.Domain.EventHandlers
|
namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||||
@@ -11,22 +14,31 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
|||||||
/// 主题创建的领域事件
|
/// 主题创建的领域事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DiscussCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<DiscussAggregateRoot>>,
|
public class DiscussCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<DiscussAggregateRoot>>,
|
||||||
ITransientDependency
|
ITransientDependency
|
||||||
{
|
{
|
||||||
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
|
||||||
public DiscussCreatedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository)
|
private ILocalEventBus _localEventBus;
|
||||||
|
|
||||||
|
public DiscussCreatedEventHandler(ISqlSugarRepository<BbsUserExtraInfoEntity> userRepository,
|
||||||
|
ILocalEventBus localEventBus)
|
||||||
{
|
{
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
|
_localEventBus = localEventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleEventAsync(EntityCreatedEventData<DiscussAggregateRoot> eventData)
|
public async Task HandleEventAsync(EntityCreatedEventData<DiscussAggregateRoot> eventData)
|
||||||
{
|
{
|
||||||
var disucussEntity = eventData.Entity;
|
var disucussEntity = eventData.Entity;
|
||||||
|
|
||||||
//给创建者发布数量+1
|
//给创建者发布数量+1
|
||||||
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
await _userRepository._Db.Updateable<BbsUserExtraInfoEntity>()
|
||||||
.SetColumns(it => it.DiscussNumber == it.DiscussNumber + 1)
|
.SetColumns(it => it.DiscussNumber == it.DiscussNumber + 1)
|
||||||
.Where(it => it.UserId == disucussEntity.CreatorId)
|
.Where(it => it.UserId == disucussEntity.CreatorId)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
|
//最后发布任务触发事件
|
||||||
|
await _localEventBus.PublishAsync(
|
||||||
|
new AssignmentEventArgs(AssignmentRequirementTypeEnum.Discuss, disucussEntity.CreatorId!.Value), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,6 +52,7 @@ public class AssignmentManager : DomainService
|
|||||||
entity.CurrentStepNumber = 0;
|
entity.CurrentStepNumber = 0;
|
||||||
entity.TotalStepNumber = assignmentDefine.TotalStepNumber;
|
entity.TotalStepNumber = assignmentDefine.TotalStepNumber;
|
||||||
entity.RewardsMoneyNumber = assignmentDefine.RewardsMoneyNumber;
|
entity.RewardsMoneyNumber = assignmentDefine.RewardsMoneyNumber;
|
||||||
|
entity.AssignmentRequirementType = assignmentDefine.AssignmentRequirementType;
|
||||||
entity.ExpireTime = assignmentDefine.AssignmentType.GetExpireTime();
|
entity.ExpireTime = assignmentDefine.AssignmentType.GetExpireTime();
|
||||||
await _assignmentRepository.InsertAsync(entity);
|
await _assignmentRepository.InsertAsync(entity);
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ public class AssignmentManager : DomainService
|
|||||||
//加钱加钱
|
//加钱加钱
|
||||||
await _localEventBus.PublishAsync(
|
await _localEventBus.PublishAsync(
|
||||||
new MoneyChangeEventArgs { UserId = assignment.UserId, Number = assignment.RewardsMoneyNumber }, false);
|
new MoneyChangeEventArgs { UserId = assignment.UserId, Number = assignment.RewardsMoneyNumber }, false);
|
||||||
|
|
||||||
//设置已完成,并领取奖励,钱钱
|
//设置已完成,并领取奖励,钱钱
|
||||||
assignment.SetComplete();
|
assignment.SetComplete();
|
||||||
await _assignmentRepository.UpdateAsync(assignment);
|
await _assignmentRepository.UpdateAsync(assignment);
|
||||||
@@ -79,7 +80,7 @@ public class AssignmentManager : DomainService
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//不能领取
|
//不能领取
|
||||||
throw new UserFriendlyException("该任务无法领取奖励,请检查任务详情");
|
throw new UserFriendlyException("该任务没有满足领取条件,请检查任务详情");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +99,7 @@ public class AssignmentManager : DomainService
|
|||||||
output.AddRange(await assignmentProvider.GetCanReceiveListAsync(context));
|
output.AddRange(await assignmentProvider.GetCanReceiveListAsync(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
output.DistinctBy(x => x.Id);
|
output = output.DistinctBy(x => x.Id).OrderBy(x => x.OrderNum).ToList();
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Microsoft.IdentityModel.Tokens;
|
|||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
|
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Volo.Abp.AspNetCore.ExceptionHandling;
|
||||||
using Volo.Abp.AspNetCore.MultiTenancy;
|
using Volo.Abp.AspNetCore.MultiTenancy;
|
||||||
using Volo.Abp.AspNetCore.Mvc;
|
using Volo.Abp.AspNetCore.Mvc;
|
||||||
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
|
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
|
||||||
@@ -68,6 +69,12 @@ namespace Yi.Abp.Web
|
|||||||
optios.AlwaysLogSelectors.Add(x => Task.FromResult(true));
|
optios.AlwaysLogSelectors.Add(x => Task.FromResult(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//配置错误处理显示详情
|
||||||
|
Configure<AbpExceptionHandlingOptions>(options =>
|
||||||
|
{
|
||||||
|
options.SendExceptionsDetailsToClients = true;
|
||||||
|
});
|
||||||
|
|
||||||
//动态Api
|
//动态Api
|
||||||
Configure<AbpAspNetCoreMvcOptions>(options =>
|
Configure<AbpAspNetCoreMvcOptions>(options =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user