feat: 社区新增有偿悬赏功能
This commit is contained in:
@@ -39,6 +39,11 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
||||
public string? Introduction { get; set; }
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主题类型
|
||||
/// </summary>
|
||||
public DiscussTypeEnum DiscussType { get; set; }
|
||||
/// <summary>
|
||||
/// 封面
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
|
||||
namespace Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
|
||||
[SugarTable("DiscussReward")]
|
||||
[SugarIndex($"index_{nameof(DiscussId)}", nameof(DiscussId), OrderByType.Asc)]
|
||||
public class DiscussRewardAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
{
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已解决
|
||||
/// </summary>
|
||||
public bool IsResolved{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏最小价值
|
||||
/// </summary>
|
||||
public decimal? MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏最大价值
|
||||
/// </summary>
|
||||
public decimal? MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作者联系方式
|
||||
/// </summary>
|
||||
public string Contact { get; set; }
|
||||
|
||||
public void SetResolved()
|
||||
{
|
||||
IsResolved = true;
|
||||
}
|
||||
}
|
||||
@@ -21,21 +21,30 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
public readonly ISqlSugarRepository<PlateAggregateRoot, Guid> _plateEntityRepository;
|
||||
public readonly ISqlSugarRepository<CommentAggregateRoot, Guid> _commentRepository;
|
||||
public readonly ISqlSugarRepository<ArticleAggregateRoot, Guid> _articleRepository;
|
||||
public ForumManager(ISqlSugarRepository<DiscussAggregateRoot, Guid> discussRepository, ISqlSugarRepository<PlateAggregateRoot, Guid> plateEntityRepository, ISqlSugarRepository<CommentAggregateRoot, Guid> commentRepository, ISqlSugarRepository<ArticleAggregateRoot, Guid> articleRepository)
|
||||
public readonly ISqlSugarRepository<DiscussRewardAggregateRoot,Guid> _discussRewardRepository;
|
||||
public ForumManager(ISqlSugarRepository<DiscussAggregateRoot, Guid> discussRepository, ISqlSugarRepository<PlateAggregateRoot, Guid> plateEntityRepository, ISqlSugarRepository<CommentAggregateRoot, Guid> commentRepository, ISqlSugarRepository<ArticleAggregateRoot, Guid> articleRepository, ISqlSugarRepository<DiscussRewardAggregateRoot, Guid> discussRewardRepository)
|
||||
{
|
||||
_discussRepository = discussRepository;
|
||||
_plateEntityRepository = plateEntityRepository;
|
||||
_commentRepository = commentRepository;
|
||||
_articleRepository = articleRepository;
|
||||
_discussRewardRepository = discussRewardRepository;
|
||||
}
|
||||
|
||||
//主题是不能直接创建的,需要由领域服务统一创建
|
||||
public async Task<DiscussAggregateRoot> CreateDiscussAsync(DiscussAggregateRoot entity)
|
||||
public async Task<DiscussAggregateRoot> CreateDiscussAsync(DiscussAggregateRoot entity,DiscussRewardAggregateRoot rewardEntity=null)
|
||||
{
|
||||
entity.CreationTime = DateTime.Now;
|
||||
entity.AgreeNum = 0;
|
||||
entity.SeeNum = 0;
|
||||
return await _discussRepository.InsertReturnEntityAsync(entity);
|
||||
var discuss = await _discussRepository.InsertReturnEntityAsync(entity);
|
||||
if (discuss.DiscussType==DiscussTypeEnum.Reward)
|
||||
{
|
||||
rewardEntity.DiscussId=discuss.Id;
|
||||
Check.NotNull(rewardEntity,"悬赏类型,悬赏信息不能为空");
|
||||
await _discussRewardRepository.InsertAsync(rewardEntity);
|
||||
}
|
||||
return discuss;
|
||||
}
|
||||
|
||||
public async Task<CommentAggregateRoot> CreateCommentAsync(Guid discussId, Guid parentId, Guid rootId, string content)
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
/// <returns></returns>
|
||||
public async Task<Dictionary<int, LevelCacheItem>> GetCacheMapAsync()
|
||||
{
|
||||
var items = _levelCache.GetOrAdd(LevelConst.LevelCacheKey, () =>
|
||||
var items =await _levelCache.GetOrAddAsync(LevelConst.LevelCacheKey,async () =>
|
||||
{
|
||||
var cacheItem = (_repository.GetListAsync().Result)
|
||||
.OrderByDescending(x => x.CurrentLevel).ToList()
|
||||
var cacheItem = ((await _repository.GetListAsync())
|
||||
.OrderByDescending(x => x.CurrentLevel))
|
||||
.Adapt<List<LevelCacheItem>>();
|
||||
return cacheItem;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user