Merge branch 'refs/heads/abp' into digital-collectibles
This commit is contained in:
@@ -31,5 +31,10 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// 是否禁止评论创建功能
|
||||
/// </summary>
|
||||
public bool IsDisableCreateComment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签
|
||||
/// </summary>
|
||||
public HashSet<Guid>? DiscussLables { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||
/// <summary>
|
||||
/// Label输入创建对象
|
||||
/// </summary>
|
||||
public class MyTypeCreateInputVo
|
||||
public class DiscussLableCreateInputVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Color { get; set; }
|
||||
@@ -0,0 +1,9 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||
{
|
||||
public class DiscussLableGetListInputVo : PagedAndSortedResultRequestDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,10 @@ using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||
{
|
||||
public class MyTypeGetListOutputDto : EntityDto<Guid>
|
||||
public class DiscussLableGetListOutputDto : EntityDto<Guid>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Color { get; set; }
|
||||
public string? BackgroundColor { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||
{
|
||||
public class MyTypeOutputDto : EntityDto<Guid>
|
||||
public class DiscussLableOutputDto : EntityDto<Guid>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Color { get; set; }
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||
{
|
||||
public class MyTypeUpdateInputVo
|
||||
public class DiscussLableUpdateInputVo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Color { get; set; }
|
||||
public string? BackgroundColor { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.MyType
|
||||
{
|
||||
public class MyTypeGetListInputVo : PagedAndSortedResultRequestDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Color { get; set; }
|
||||
public string? BackgroundColor { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.IServices
|
||||
/// <summary>
|
||||
/// Label服务抽象
|
||||
/// </summary>
|
||||
public interface IMyTypeService : IYiCrudAppService<MyTypeOutputDto, MyTypeGetListOutputDto, Guid, MyTypeGetListInputVo, MyTypeCreateInputVo, MyTypeUpdateInputVo>
|
||||
public interface IDiscussLableService : IYiCrudAppService<DiscussLableOutputDto, DiscussLableGetListOutputDto, Guid, DiscussLableGetListInputVo, DiscussLableCreateInputVo, DiscussLableUpdateInputVo>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -8,6 +8,5 @@ namespace Yi.Framework.Bbs.Application.Contracts.IServices
|
||||
/// </summary>
|
||||
public interface IDiscussService : IYiCrudAppService<DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>
|
||||
{
|
||||
Task VerifyDiscussPermissionAsync(Guid discussId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
[Route("article/all/discuss-id/{discussId}")]
|
||||
public async Task<List<ArticleAllOutputDto>> GetAllAsync([FromRoute] Guid discussId)
|
||||
{
|
||||
await _discussService.VerifyDiscussPermissionAsync(discussId);
|
||||
await _forumManager.VerifyDiscussPermissionAsync(discussId,CurrentUser.Id);
|
||||
|
||||
|
||||
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
|
||||
|
||||
@@ -44,14 +44,13 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
private IDiscussService _discussService { get; set; }
|
||||
/// <summary>
|
||||
/// 获取改主题下的评论,结构为二维列表,该查询无分页
|
||||
/// Todo: 可放入领域层
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PagedResultDto<CommentGetListOutputDto>> GetDiscussIdAsync([FromRoute] Guid discussId, [FromQuery] CommentGetListInputVo input)
|
||||
{
|
||||
await _discussService.VerifyDiscussPermissionAsync(discussId);
|
||||
await _forumManager.VerifyDiscussPermissionAsync(discussId,CurrentUser.Id);
|
||||
|
||||
var entities = await _repository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Content), x => x.Content.Contains(input.Content))
|
||||
.Where(x => x.DiscussId == discussId)
|
||||
@@ -64,15 +63,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
List<Guid> userIds = entities.Where(x => x.CreatorId != null).Select(x => x.CreatorId ?? Guid.Empty).ToList();
|
||||
var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------数据查询完成------
|
||||
|
||||
|
||||
|
||||
|
||||
//------数据查询完成------,以下只是dto的简单组装
|
||||
|
||||
//从根目录开始组装
|
||||
//结果初始值,第一层等于全部根节点
|
||||
@@ -117,11 +108,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
rootOutoutDto?.ForEach(x =>
|
||||
{
|
||||
x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return new PagedResultDto<CommentGetListOutputDto>(entities.Count(), rootOutoutDto);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Data;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.MyType;
|
||||
using Yi.Framework.Bbs.Application.Contracts.IServices;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
using Yi.Framework.Ddd.Application;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
{
|
||||
/// <summary>
|
||||
/// DiscussLable服务实现
|
||||
/// </summary>
|
||||
public class DiscussLableService : YiCrudAppService<DiscussLableAggregateRoot, DiscussLableOutputDto,
|
||||
DiscussLableGetListOutputDto, Guid, DiscussLableGetListInputVo, DiscussLableCreateInputVo,
|
||||
DiscussLableUpdateInputVo>,
|
||||
IDiscussLableService
|
||||
{
|
||||
private ISqlSugarRepository<DiscussLableAggregateRoot, Guid> _repository;
|
||||
|
||||
public DiscussLableService(ISqlSugarRepository<DiscussLableAggregateRoot, Guid> repository) : base(repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
[HttpGet("discuss-lable/all")]
|
||||
public async Task<ListResultDto<DiscussLableGetListOutputDto>> GetAllListAsync(DiscussLableGetListInputVo input)
|
||||
{
|
||||
var order = input.Sorting ?? nameof(DiscussLableAggregateRoot.Name);
|
||||
var output = await _repository._DbQueryable
|
||||
.WhereIF(input.Name is not null, x => x.Name.Contains(input.Name))
|
||||
.OrderBy(order)
|
||||
.Select(x => new DiscussLableGetListOutputDto(), true)
|
||||
.ToListAsync();
|
||||
return new ListResultDto<DiscussLableGetListOutputDto>(output);
|
||||
}
|
||||
|
||||
public override async Task<PagedResultDto<DiscussLableGetListOutputDto>> GetListAsync(
|
||||
DiscussLableGetListInputVo input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var order = input.Sorting ?? nameof(DiscussLableAggregateRoot.Name);
|
||||
var output = await _repository._DbQueryable
|
||||
.WhereIF(input.Name is not null, x => x.Name.Contains(input.Name))
|
||||
.OrderBy(order)
|
||||
.Select(x => new DiscussLableGetListOutputDto(), true)
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
return new PagedResultDto<DiscussLableGetListOutputDto>(total, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
item.IsAgree = agreeCreatorList.Contains(CurrentUser.Id);
|
||||
}
|
||||
|
||||
await VerifyDiscussPermissionAsync(item.Id);
|
||||
await _forumManager.VerifyDiscussPermissionAsync(item.Id,CurrentUser.Id);
|
||||
await _localEventBus.PublishAsync(new SeeDiscussEventArgs
|
||||
{ DiscussId = item.Id, OldSeeNum = item.SeeNum });
|
||||
return item;
|
||||
@@ -260,37 +260,5 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
var entity = await _forumManager.CreateDiscussAsync(await MapToEntityAsync(input));
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验主题查询权限
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public async Task VerifyDiscussPermissionAsync(Guid discussId)
|
||||
{
|
||||
var discuss = await _forumManager._discussRepository.GetFirstAsync(x => x.Id == discussId);
|
||||
if (discuss is null)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.No_Exist);
|
||||
}
|
||||
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.Oneself)
|
||||
{
|
||||
if (discuss.CreatorId != CurrentUser.Id)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.Privacy);
|
||||
}
|
||||
}
|
||||
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.User)
|
||||
{
|
||||
if (discuss.CreatorId != CurrentUser.Id &&
|
||||
!discuss.PermissionUserIds.Contains(CurrentUser.Id ?? Guid.Empty))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.Privacy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Data;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.MyType;
|
||||
using Yi.Framework.Bbs.Application.Contracts.IServices;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
using Yi.Framework.Ddd.Application;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
{
|
||||
/// <summary>
|
||||
/// Label服务实现
|
||||
/// </summary>
|
||||
public class MyTypeService : YiCrudAppService<MyTypeEntity, MyTypeOutputDto, MyTypeGetListOutputDto, Guid, MyTypeGetListInputVo, MyTypeCreateInputVo, MyTypeUpdateInputVo>,
|
||||
IMyTypeService
|
||||
{
|
||||
private ISqlSugarRepository<MyTypeEntity, Guid> _repository;
|
||||
public MyTypeService(ISqlSugarRepository<MyTypeEntity, Guid> repository, IDataFilter dataFilter) : base(repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_dataFilter = dataFilter;
|
||||
}
|
||||
|
||||
private IDataFilter _dataFilter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户的主题类型
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<PagedResultDto<MyTypeGetListOutputDto>> GetListCurrentAsync(MyTypeGetListInputVo input)
|
||||
{
|
||||
//过滤器需要更换
|
||||
//_dataFilter.Enable<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
|
||||
|
||||
//_dataFilter.AddFilter<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
|
||||
return base.GetListAsync(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<MyTypeOutputDto> CreateAsync(MyTypeCreateInputVo input)
|
||||
{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
entity.UserId = CurrentUser.Id ?? Guid.Empty;
|
||||
entity.IsDeleted = false;
|
||||
var outputEntity = await _repository.InsertReturnEntityAsync(entity);
|
||||
return await MapToGetOutputDtoAsync(outputEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,9 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
||||
[SugarColumn(IsJson = true)]//使用json处理
|
||||
public List<Guid>? PermissionUserIds { get; set; }
|
||||
|
||||
[SugarColumn(IsJson = true)]//使用json处理
|
||||
public HashSet<Guid>? DiscussLables{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否禁止评论创建功能
|
||||
/// </summary>
|
||||
|
||||
@@ -4,17 +4,13 @@ using Volo.Abp.Domain.Entities;
|
||||
|
||||
namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
||||
{
|
||||
[SugarTable("MyType")]
|
||||
public class MyTypeEntity : Entity<Guid>, ISoftDelete
|
||||
[SugarTable("DiscussLable")]
|
||||
public class DiscussLableAggregateRoot : AggregateRoot<Guid>, ISoftDelete
|
||||
{
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public override Guid Id { get; protected set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string? Color { get; set; }
|
||||
public string? BackgroundColor { get; set; }
|
||||
|
||||
public Guid UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
|
||||
namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
||||
{
|
||||
[SugarTable("DiscussMyType")]
|
||||
public class DiscussMyTypeEntity : Entity<Guid>
|
||||
{
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public override Guid Id { get; protected set; }
|
||||
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
public Guid MyTypeId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.Domain.Services;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
using Yi.Framework.Bbs.Domain.Managers.ArticleImport;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Model;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
@@ -44,6 +46,38 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
return await _commentRepository.InsertReturnEntityAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验主题查询权限
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public async Task VerifyDiscussPermissionAsync(Guid discussId,Guid? userId)
|
||||
{
|
||||
var discuss = await _discussRepository.GetFirstAsync(x => x.Id == discussId);
|
||||
if (discuss is null)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.No_Exist);
|
||||
}
|
||||
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.Oneself)
|
||||
{
|
||||
if (discuss.CreatorId != userId)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.Privacy);
|
||||
}
|
||||
}
|
||||
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.User)
|
||||
{
|
||||
if (discuss.CreatorId !=userId &&
|
||||
!discuss.PermissionUserIds.Contains(userId?? Guid.Empty))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.Privacy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入文章
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user