Merge branch 'refs/heads/abp' into digital-collectibles
This commit is contained in:
@@ -4,8 +4,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
public class ArticleGetListOutputDto : EntityDto<Guid>
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD>
|
||||
//public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
{
|
||||
@@ -10,5 +11,23 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public bool HasPermission { get;internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置权限
|
||||
/// </summary>
|
||||
public void SetPassPermission()
|
||||
{
|
||||
HasPermission = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置无权限
|
||||
/// </summary>
|
||||
public void SetNoPermission()
|
||||
{
|
||||
HasPermission = false;
|
||||
Content=DiscussConst.Privacy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,11 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// <summary>
|
||||
/// 标签
|
||||
/// </summary>
|
||||
public List<Guid>? DiscussLables { get; set; }
|
||||
public List<Guid>? DiscussLableIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色
|
||||
/// </summary>
|
||||
public List<string>? PermissionRoleCodes { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// </summary>
|
||||
public bool IsAgree { get; set; } = false;
|
||||
public string Title { get; set; }
|
||||
public string Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
|
||||
public int AgreeNum { get; set; }
|
||||
@@ -42,58 +41,16 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// 封面
|
||||
/// </summary>
|
||||
public string? Cover { get; set; }
|
||||
|
||||
//私有需要判断code权限
|
||||
public string? PrivateCode { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public List<Guid>? PermissionUserIds { get; set; }
|
||||
/// <summary>
|
||||
/// 所需角色
|
||||
/// </summary>
|
||||
public List<string>? PermissionRoleCodes { get; set; } = new List<string>();
|
||||
|
||||
public BbsUserGetListOutputDto User { get; set; }
|
||||
public List<Guid>? DiscussLables { get; set; } = new List<Guid>();
|
||||
public List<Guid>? DiscussLableIds { get; set; } = new List<Guid>();
|
||||
public List<DiscussLableGetOutputDto> Lables { get; set; } = new List<DiscussLableGetOutputDto>();
|
||||
public void SetBan()
|
||||
{
|
||||
Title = DiscussConst.Privacy;
|
||||
Introduction = "";
|
||||
Cover = null;
|
||||
//被禁止
|
||||
IsBan = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DiscussGetListOutputDtoExtension
|
||||
{
|
||||
|
||||
public static void ApplyPermissionTypeFilter(this List<DiscussGetListOutputDto> dtos, Guid userId)
|
||||
{
|
||||
dtos?.ForEach(dto =>
|
||||
{
|
||||
switch (dto.PermissionType)
|
||||
{
|
||||
case DiscussPermissionTypeEnum.Public:
|
||||
break;
|
||||
case DiscussPermissionTypeEnum.Oneself:
|
||||
//当前主题是仅自己可见,同时不是当前登录用户
|
||||
if (dto.User.Id != userId)
|
||||
{
|
||||
dto.SetBan();
|
||||
}
|
||||
break;
|
||||
case DiscussPermissionTypeEnum.User:
|
||||
//当前主题为部分可见,同时不是当前登录用户 也 不在可见用户列表中
|
||||
if (dto.User.Id != userId && !dto.PermissionUserIds.Contains(userId))
|
||||
{
|
||||
dto.SetBan();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.DiscussLable;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
|
||||
|
||||
@@ -14,7 +15,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// </summary>
|
||||
public bool IsDisableCreateComment { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string? Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
@@ -37,12 +37,33 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
public DateTime CreationTime { get; set; }
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
public bool IsAgree { get; set; } = false;
|
||||
public List<Guid>? PermissionUserIds { get; set; }
|
||||
public List<string> PermissionRoleCodes { get; set; } = new List<string>();
|
||||
|
||||
|
||||
|
||||
public BbsUserGetListOutputDto User { get; set; }
|
||||
|
||||
public PlateGetOutputDto Plate { get; set; }
|
||||
|
||||
public List<Guid>? DiscussLables { get; set; } = new List<Guid>();
|
||||
public List<Guid>? DiscussLableIds { get; set; } = new List<Guid>();
|
||||
public List<DiscussLableGetOutputDto> Lables { get; set; } =new List<DiscussLableGetOutputDto>();
|
||||
|
||||
public bool HasPermission { get;internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置权限
|
||||
/// </summary>
|
||||
public void SetPassPermission()
|
||||
{
|
||||
HasPermission = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置无权限
|
||||
/// </summary>
|
||||
public void SetNoPermission()
|
||||
{
|
||||
HasPermission = false;
|
||||
Content=DiscussConst.Privacy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,11 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// <summary>
|
||||
/// 标签
|
||||
/// </summary>
|
||||
public List<Guid>? DiscussLables { get; set; }
|
||||
public List<Guid>? DiscussLableIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 需求角色
|
||||
/// </summary>
|
||||
public List<string>? PermissionRoleCodes { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,22 +30,21 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
/// <summary>
|
||||
/// Article服务实现
|
||||
/// </summary>
|
||||
|
||||
public class ArticleService : YiCrudAppService<ArticleAggregateRoot, ArticleGetOutputDto, ArticleGetListOutputDto, Guid, ArticleGetListInputVo, ArticleCreateInputVo, ArticleUpdateInputVo>,
|
||||
IArticleService
|
||||
public class ArticleService : YiCrudAppService<ArticleAggregateRoot, ArticleGetOutputDto, ArticleGetListOutputDto,
|
||||
Guid, ArticleGetListInputVo, ArticleCreateInputVo, ArticleUpdateInputVo>,
|
||||
IArticleService
|
||||
{
|
||||
public ArticleService(IArticleRepository articleRepository,
|
||||
ISqlSugarRepository<DiscussAggregateRoot> discussRepository,
|
||||
IDiscussService discussService,
|
||||
ForumManager forumManager) : base(articleRepository)
|
||||
{
|
||||
|
||||
_articleRepository = articleRepository;
|
||||
_discussRepository = discussRepository;
|
||||
_discussService = discussService;
|
||||
_forumManager = forumManager;
|
||||
|
||||
}
|
||||
|
||||
private ForumManager _forumManager;
|
||||
private IArticleRepository _articleRepository;
|
||||
private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository;
|
||||
@@ -55,13 +54,34 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
var entities = await _articleRepository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
|
||||
//.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Name.Contains(input.Code!))
|
||||
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
var entities = await _articleRepository._DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
|
||||
.WhereIF(input.StartTime is not null && input.EndTime is not null,
|
||||
x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
return new PagedResultDto<ArticleGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询文章
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ArticleGetOutputDto> GetAsync(Guid id)
|
||||
{
|
||||
var entity = await _articleRepository.GetAsync(id);
|
||||
var output = entity.Adapt<ArticleGetOutputDto>();
|
||||
if (!await _forumManager.VerifyDiscussPermissionAsync(entity.DiscussId, CurrentUser.Id, CurrentUser.Roles))
|
||||
{
|
||||
output.SetNoPermission();
|
||||
}
|
||||
else
|
||||
{
|
||||
output.SetPassPermission();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文章全部树级信息
|
||||
@@ -72,16 +92,13 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
[Route("article/all/discuss-id/{discussId}")]
|
||||
public async Task<List<ArticleAllOutputDto>> GetAllAsync([FromRoute] Guid discussId)
|
||||
{
|
||||
await _forumManager.VerifyDiscussPermissionAsync(discussId,CurrentUser.Id);
|
||||
|
||||
|
||||
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
|
||||
var items = entities.Adapt<List<ArticleAllOutputDto>>();
|
||||
return items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询文章
|
||||
/// 查询文章概述
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <returns></returns>
|
||||
@@ -108,7 +125,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
[Authorize]
|
||||
public async override Task<ArticleGetOutputDto> CreateAsync(ArticleCreateInputVo input)
|
||||
{
|
||||
await VerifyDiscussCreateIdAsync(input.DiscussId);
|
||||
await VerifyPermissionAsync(input.DiscussId);
|
||||
return await base.CreateAsync(input);
|
||||
}
|
||||
|
||||
@@ -121,7 +138,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
public override async Task<ArticleGetOutputDto> UpdateAsync(Guid id, ArticleUpdateInputVo input)
|
||||
{
|
||||
var entity = await _articleRepository.GetByIdAsync(id);
|
||||
await VerifyDiscussCreateIdAsync(entity.DiscussId);
|
||||
await VerifyPermissionAsync(entity.DiscussId);
|
||||
return await base.UpdateAsync(id, input);
|
||||
}
|
||||
|
||||
@@ -134,7 +151,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
public override async Task DeleteAsync(Guid id)
|
||||
{
|
||||
var entity = await _articleRepository.GetByIdAsync(id);
|
||||
await VerifyDiscussCreateIdAsync(entity.DiscussId);
|
||||
await VerifyPermissionAsync(entity.DiscussId);
|
||||
await base.DeleteAsync(id);
|
||||
}
|
||||
|
||||
@@ -143,8 +160,10 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
/// 导入文章
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task PostImportAsync([FromQuery] ArticleImprotDto input, [FromForm][Required] IFormFileCollection file)
|
||||
public async Task PostImportAsync([FromQuery] ArticleImprotDto input,
|
||||
[FromForm] [Required] IFormFileCollection file)
|
||||
{
|
||||
await VerifyPermissionAsync(input.DiscussId);
|
||||
var fileObjs = new List<FileObject>();
|
||||
if (file.Count > 0)
|
||||
{
|
||||
@@ -171,45 +190,18 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
{
|
||||
throw new UserFriendlyException("未选择文件");
|
||||
}
|
||||
|
||||
//使用简单工厂根据传入的类型进行判断
|
||||
await _forumManager.PostImportAsync(input.DiscussId, input.ArticleParentId, fileObjs, input.ImportType);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 校验创建权限,userId为主题创建者
|
||||
/// </summary>
|
||||
/// <param name="disucssId"></param>
|
||||
/// <returns></returns>
|
||||
private async Task VerifyDiscussCreateIdAsync(Guid disucssId)
|
||||
private async Task VerifyPermissionAsync(Guid discussId)
|
||||
{
|
||||
var discuss = await _discussRepository.GetFirstAsync(x => x.Id == disucssId);
|
||||
if (discuss is null)
|
||||
if (!await _forumManager.VerifyDiscussPermissionAsync(discussId, CurrentUser.Id, isVerifyLook: false))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.No_Exist);
|
||||
}
|
||||
|
||||
//这块有点绕,这个版本的写法比较清晰
|
||||
bool result = false;
|
||||
|
||||
if (CurrentUser.GetPermissions().Contains(UserConst.AdminPermissionCode))
|
||||
{
|
||||
//如果是超管,直接跳过
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果不是超管,必须满足作者是自己,同时还有发布的权限
|
||||
if (discuss.CreatorId == CurrentUser.Id)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
throw new UserFriendlyException("权限不足,请联系主题作者或管理员申请开通");
|
||||
throw new UserFriendlyException("您无权限进行操作", "403");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,6 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
|
||||
|
||||
private ISqlSugarRepository<PlateAggregateRoot> _plateEntityRepository { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
@@ -117,15 +114,24 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
|
||||
//组装标签
|
||||
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
foreach (var lableId in output.DiscussLables)
|
||||
foreach (var lableId in output.DiscussLableIds)
|
||||
{
|
||||
if (lableDic.TryGetValue(lableId,out var item))
|
||||
{
|
||||
output.Lables.Add(item.Adapt<DiscussLableGetOutputDto>());
|
||||
}
|
||||
}
|
||||
|
||||
await _forumManager.VerifyDiscussPermissionAsync(output.Id,CurrentUser.Id);
|
||||
|
||||
//如果没有权限
|
||||
if (!await _forumManager.VerifyDiscussPermissionAsync(output.Id,CurrentUser.Id, CurrentUser.Roles))
|
||||
{
|
||||
output.SetNoPermission();
|
||||
}
|
||||
else
|
||||
{
|
||||
output.SetPassPermission();
|
||||
}
|
||||
|
||||
await _localEventBus.PublishAsync(new SeeDiscussEventArgs
|
||||
{ DiscussId = output.Id, OldSeeNum = output.SeeNum });
|
||||
return output;
|
||||
@@ -179,10 +185,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
(await _agreeRepository._DbQueryable.Where(x => discussId.Contains(x.DiscussId)).ToListAsync())
|
||||
.GroupBy(x => x.DiscussId)
|
||||
.ToDictionary(x => x.Key, y => y.Select(y => y.CreatorId).ToList());
|
||||
|
||||
//查询完主题之后,要过滤一下私有的主题信息
|
||||
items.ApplyPermissionTypeFilter(CurrentUser.Id ?? Guid.Empty);
|
||||
|
||||
|
||||
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
|
||||
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
|
||||
@@ -199,7 +202,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var lableId in x.DiscussLables)
|
||||
foreach (var lableId in x.DiscussLableIds)
|
||||
{
|
||||
if (lableDic.TryGetValue(lableId,out var item))
|
||||
{
|
||||
@@ -236,7 +239,6 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
Address = user.Address,
|
||||
Age = user.Age,
|
||||
CreationTime = user.CreationTime,
|
||||
|
||||
Level = info.Level,
|
||||
Introduction = user.Introduction,
|
||||
Icon = user.Icon,
|
||||
@@ -255,7 +257,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
output?.ForEach(x =>
|
||||
{
|
||||
x.User.LevelName = levelCacheDic[x.User.Level].Name;
|
||||
foreach (var lableId in x.DiscussLables)
|
||||
foreach (var lableId in x.DiscussLableIds)
|
||||
{
|
||||
if (lableDic.TryGetValue(lableId,out var item))
|
||||
{
|
||||
|
||||
@@ -14,14 +14,9 @@ namespace Yi.Framework.Bbs.Domain.Shared.Enums
|
||||
Public = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 仅自己可见
|
||||
/// 角色要求可见
|
||||
/// </summary>
|
||||
Oneself,
|
||||
|
||||
/// <summary>
|
||||
/// 部分用户可见
|
||||
/// </summary>
|
||||
User
|
||||
Role=1
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当PermissionType为部分用户时候,以下列表中的用户+创建者 代表拥有权限
|
||||
/// 当PermissionType为角色时候,以下列表中的角色+创建者 代表拥有权限
|
||||
/// </summary>
|
||||
[SugarColumn(IsJson = true)]//使用json处理
|
||||
public List<Guid>? PermissionUserIds { get; set; }
|
||||
[SugarColumn(IsJson = true)] //使用json处理
|
||||
public List<string>? PermissionRoleCodes { get; set; } = new List<string>();
|
||||
|
||||
[SugarColumn(IsJson = true)]//使用json处理
|
||||
public List<Guid>? DiscussLables{ get; set; }
|
||||
public List<Guid>? DiscussLableIds{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否禁止评论创建功能
|
||||
|
||||
@@ -7,6 +7,7 @@ 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.Rbac.Domain.Shared.Consts;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Bbs.Domain.Managers
|
||||
@@ -52,30 +53,52 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
/// <param name="discussId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public async Task VerifyDiscussPermissionAsync(Guid discussId,Guid? userId)
|
||||
public async Task<bool> VerifyDiscussPermissionAsync(Guid discussId,Guid? userId,string[] roles=null,bool isVerifyLook=true)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (discuss.CreatorId != userId)
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.Privacy);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.User)
|
||||
//管理员,直接放行
|
||||
if (roles.Contains(UserConst.AdminRolesCode))
|
||||
{
|
||||
if (discuss.CreatorId !=userId &&
|
||||
!discuss.PermissionUserIds.Contains(userId?? Guid.Empty))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.Privacy);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//是否为校验 查看权限, 其他操作权限(增删改)
|
||||
if (isVerifyLook)
|
||||
{
|
||||
//要求角色
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.Role)
|
||||
{
|
||||
if (roles is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
List<string> roleList = roles.ToList();
|
||||
//所选角色,没有任何交集
|
||||
if (!discuss.PermissionRoleCodes.Intersect(roleList).Any())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//通过了上面要求,剩下的都是有权限的,可以直接看
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//通过了上面的要求,剩下的就是没有权限了,直接拦截
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user