diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentStateEnum.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentStateEnum.cs new file mode 100644 index 00000000..8cd23d90 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentStateEnum.cs @@ -0,0 +1,19 @@ +namespace Yi.Framework.Bbs.Domain.Shared.Enums; + +public enum AssignmentStateEnum +{ + /// + /// 正在进行 + /// + Progress, + + /// + /// 已完成 + /// + Completed, + + /// + /// 已过期 + /// + Expired +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentTypeEnum.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentTypeEnum.cs new file mode 100644 index 00000000..d0665771 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain.Shared/Enums/AssignmentTypeEnum.cs @@ -0,0 +1,19 @@ +namespace Yi.Framework.Bbs.Domain.Shared.Enums; + +public enum AssignmentTypeEnum +{ + /// + /// 新手任务 + /// + Novice, + + /// + /// 每日任务 + /// + Daily, + + /// + /// 每周任务 + /// + Weekly +} \ 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 new file mode 100644 index 00000000..a7ab058c --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentAggregateRoot.cs @@ -0,0 +1,53 @@ +using SqlSugar; +using Volo.Abp.Auditing; +using Volo.Abp.Domain.Entities; +using Yi.Framework.Bbs.Domain.Shared.Enums; +using Yi.Framework.Core.Data; + +namespace Yi.Framework.Bbs.Domain.Entities.Assignment; + +/// +/// 任务实例表 +/// +[SugarTable("Assignment")] +public class AssignmentAggregateRoot : AggregateRoot, IHasCreationTime, IOrderNum, IHasModificationTime +{ + [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)] + public override Guid Id { get; protected set; } + + /// + /// 任务定义ID + /// + public Guid AssignmentDefineId { get; set; } + + /// + /// 任务接收者用户id + /// + public Guid UserId { get; set; } + + /// + /// 总共步骤数 + /// + public int TotalStepNumber { get; set; } + + /// + /// 当前步骤数 + /// + public int CurrentStepNumber { get; set; } + + + /// + /// 任务状态 + /// + public AssignmentStateEnum AssignmentState { get; set; } + + + /// + /// 任务过期时间 + /// + public DateTime? ExpireTime { get; set; } + + public DateTime CreationTime { get; } + public int OrderNum { get; set; } + public DateTime? LastModificationTime { get; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentDefineAggregateRoot.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentDefineAggregateRoot.cs new file mode 100644 index 00000000..5573e76a --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Entities/Assignment/AssignmentDefineAggregateRoot.cs @@ -0,0 +1,47 @@ +using SqlSugar; +using Volo.Abp.Auditing; +using Volo.Abp.Domain.Entities; +using Yi.Framework.Bbs.Domain.Shared.Enums; +using Yi.Framework.Core.Data; + +namespace Yi.Framework.Bbs.Domain.Entities.Assignment; + +/// +/// 任务定义表 +/// +[SugarTable("AssignmentDefine")] + +public class AssignmentDefineAggregateRoot: AggregateRoot, IHasCreationTime,IOrderNum +{ + [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)] + public override Guid Id { get; protected set; } + + /// + /// 任务名称 + /// + public string Name { get; set; } + + /// + /// 备注 + /// + public string Remarks { get; set; } + + /// + /// 任务类型 + /// + public AssignmentTypeEnum AssignmentType{ get; set; } + + + /// + /// 前置任务id + /// + public Guid? PreAssignmentId { get; set; } + + /// + /// 任务奖励的钱钱数量 + /// + public decimal RewardsMoneyNumber { get; set; } + + public DateTime CreationTime { get; } + public int OrderNum { get; set; } +} \ 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 new file mode 100644 index 00000000..e37d92a8 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentManager.cs @@ -0,0 +1,43 @@ +using Volo.Abp.Domain.Services; +using Yi.Framework.Bbs.Domain.Entities.Assignment; + +namespace Yi.Framework.Bbs.Domain.Managers; + +/// +/// 任务领域,任务相关核心逻辑 +/// +public class AssignmentManager : DomainService +{ + /// + /// 接受任务 + /// + /// 领取用户 + /// 任务定义id + /// + public Task AcceptAsync(Guid userId, Guid asignmentDefineId) + { + throw new NotImplementedException(); + } + + /// + /// 领取任务奖励 + /// + /// 任务id + /// + /// + public Task ReceiveRewardsAsync(Guid asignmentId) + { + throw new NotImplementedException(); + } + + + /// + /// 根据用户id获取能够领取的任务列表 + /// + /// 用户id + /// + public Task> GetCanReceiveListAsync(Guid userId) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/AssignmentContext.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/AssignmentContext.cs new file mode 100644 index 00000000..4f1f6048 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/AssignmentContext.cs @@ -0,0 +1,21 @@ +using Yi.Framework.Bbs.Domain.Entities.Assignment; + +namespace Yi.Framework.Bbs.Domain.Managers.AssignmentProviders; + +public class AssignmentContext +{ + /// + /// 全部的任务定义 + /// + public List AllAssignmentDefine { get; } + + /// + /// 当前用户的全部任务数据 + /// + public List CurrentUserAssignments { get; } + + /// + /// 当前用户id + /// + public Guid CurrentUserId { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/IAssignmentProvider.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/IAssignmentProvider.cs new file mode 100644 index 00000000..9f718414 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/IAssignmentProvider.cs @@ -0,0 +1,24 @@ +using Volo.Abp.DependencyInjection; +using Yi.Framework.Bbs.Domain.Entities.Assignment; + +namespace Yi.Framework.Bbs.Domain.Managers.AssignmentProviders; + +/// +/// 任务提供者接口 +/// +public interface IAssignmentProvider : ITransientDependency +{ + /// + /// 获取可领取的任务定义,该方法需全部AssignmentProvider去重 + /// + /// + /// + Task> GetCanReceiveListAsync(AssignmentContext context); + + /// + /// 校验是否能够被领取,该方法还需工厂进行代理执行一次 + /// + /// + /// + Task VerifyCanAcceptAsync(AssignmentContext context); +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/DailyProvider.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/DailyProvider.cs new file mode 100644 index 00000000..56ce0057 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/DailyProvider.cs @@ -0,0 +1,9 @@ +namespace Yi.Framework.Bbs.Domain.Managers.AssignmentProviders; + +/// +/// 每日任务提供者 +/// +public class DailyProvider : TimerProvider +{ + protected override TimeSpan TimeCycle => TimeSpan.FromDays(1); +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/NoviceProvider.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/NoviceProvider.cs new file mode 100644 index 00000000..24f2062c --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/NoviceProvider.cs @@ -0,0 +1,19 @@ +using Yi.Framework.Bbs.Domain.Entities.Assignment; + +namespace Yi.Framework.Bbs.Domain.Managers.AssignmentProviders; + +/// +/// 新手任务提供者 +/// +public class NoviceProvider : IAssignmentProvider +{ + public Task> GetCanReceiveListAsync(AssignmentContext context) + { + throw new NotImplementedException(); + } + + public Task VerifyCanAcceptAsync(AssignmentContext context) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/WeeklyProvider.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/WeeklyProvider.cs new file mode 100644 index 00000000..4a39e7a7 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/Impl/WeeklyProvider.cs @@ -0,0 +1,9 @@ +namespace Yi.Framework.Bbs.Domain.Managers.AssignmentProviders; + +/// +/// 每周任务提供者 +/// +public class WeeklyProvider : TimerProvider +{ + protected override TimeSpan TimeCycle => TimeSpan.FromDays(7); +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/TimerAbstractProvider.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/TimerAbstractProvider.cs new file mode 100644 index 00000000..a22a8637 --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/AssignmentProviders/TimerAbstractProvider.cs @@ -0,0 +1,24 @@ +using Yi.Framework.Bbs.Domain.Entities.Assignment; + +namespace Yi.Framework.Bbs.Domain.Managers.AssignmentProviders; + +/// +/// 定时任务提供者 +/// +public abstract class TimerProvider : IAssignmentProvider +{ + /// + /// 时间周期 + /// + protected abstract TimeSpan TimeCycle { get; } + + public Task> GetCanReceiveListAsync(AssignmentContext context) + { + throw new NotImplementedException(); + } + + public Task VerifyCanAcceptAsync(AssignmentContext context) + { + throw new NotImplementedException(); + } +} \ No newline at end of file