feat:完成权限相关、全局配置、优化细节
This commit is contained in:
@@ -5,6 +5,7 @@ using Yi.Framework.Ddd.Dtos;
|
||||
using Yi.Framework.DictionaryManager.Entities;
|
||||
using Yi.Framework.DictionaryManager.Dtos.Dictionary;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Yi.Framework.DictionaryManager
|
||||
{
|
||||
@@ -21,7 +22,7 @@ namespace Yi.Framework.DictionaryManager
|
||||
|
||||
public override async Task<PagedResultDto<DictionaryGetListOutputDto>> GetListAsync(DictionaryGetListInputVo input)
|
||||
{
|
||||
int total = 0;
|
||||
RefAsync<int> total = 0;
|
||||
var entities = await _DbQueryable.WhereIF(input.DictType is not null, x => x.DictType == input.DictType)
|
||||
.WhereIF(input.DictLabel is not null, x => x.DictLabel!.Contains(input.DictLabel!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Yi.Framework.DictionaryManager
|
||||
public async override Task<PagedResultDto<DictionaryTypeGetListOutputDto>> GetListAsync(DictionaryTypeGetListInputVo input)
|
||||
{
|
||||
|
||||
int total = 0;
|
||||
RefAsync<int> total = 0;
|
||||
var entities = await _DbQueryable.WhereIF(input.DictName is not null, x => x.DictName.Contains(input.DictName!))
|
||||
.WhereIF(input.DictType is not null, x => x.DictType!.Contains(input.DictType!))
|
||||
.WhereIF(input.State is not null, x => x.State == input.State)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Data.DataSeeds;
|
||||
using Yi.Framework.Ddd.Repositories;
|
||||
using Yi.RBAC.Domain.Identity.Entities;
|
||||
using Yi.RBAC.Domain.Setting.Entities;
|
||||
using Yi.RBAC.Domain.Shared.Identity.EnumClasses;
|
||||
|
||||
namespace Yi.BBS.Domain.DataSeed
|
||||
{
|
||||
[AppService(typeof(IDataSeed))]
|
||||
public class BbsConfigDataSeed : AbstractDataSeed<ConfigEntity>
|
||||
{
|
||||
public BbsConfigDataSeed(IRepository<ConfigEntity> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<bool> IsInvoker()
|
||||
{
|
||||
return !await _repository.IsAnyAsync(x => x.ConfigKey == "ConfigEntity");
|
||||
}
|
||||
public override List<ConfigEntity> GetSeedData()
|
||||
{
|
||||
List<ConfigEntity> entities = new List<ConfigEntity>()
|
||||
{
|
||||
new ConfigEntity { Id = SnowflakeHelper.NextId, ConfigKey = "bbs.site.name", ConfigValue = "Yi意社区", ConfigName = "bbs站点名称" },
|
||||
new ConfigEntity { Id = SnowflakeHelper.NextId, ConfigKey = "bbs.site.author", ConfigValue = "橙子", ConfigName = "bbs站点作者" },
|
||||
new ConfigEntity { Id = SnowflakeHelper.NextId, ConfigKey = "bbs.site.icp", ConfigValue = "2023 意社区 | 赣ICP备xxxxxx号-4", ConfigName = "bbs备案号" },
|
||||
new ConfigEntity { Id = SnowflakeHelper.NextId, ConfigKey = "bbs.site.bottom", ConfigValue = "YiFramework意框架", ConfigName = "bbs底部信息" },
|
||||
};
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,11 @@
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Domain.Forum.Entities.DiscussEntity.PermissionUserIds">
|
||||
<summary>
|
||||
当PermissionType为部分用户时候,以下列表中的用户+创建者 代表拥有权限
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Domain.Forum.ForumManager">
|
||||
<summary>
|
||||
论坛模块的领域服务
|
||||
|
||||
Binary file not shown.
@@ -48,9 +48,18 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public string? PrivateCode { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
|
||||
public List<long> PermissionUserIds { get; set; }
|
||||
|
||||
public UserGetListOutputDto User { get; set; }
|
||||
|
||||
public void SetBan()
|
||||
{
|
||||
this.Title = DiscussConst.˽<EFBFBD><EFBFBD>;
|
||||
this.Introduction = "";
|
||||
this.Cover = null;
|
||||
//<2F><><EFBFBD><EFBFBD>ֹ
|
||||
this.IsBan = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,20 +78,19 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD>Լ<EFBFBD><D4BC>ɼ<EFBFBD><C9BC><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>¼<EFBFBD>û<EFBFBD>
|
||||
if (dto.User.Id != userId)
|
||||
{
|
||||
dto.Title = DiscussConst.˽<EFBFBD><EFBFBD>;
|
||||
dto.Introduction= "";
|
||||
dto.Cover = null;
|
||||
//<2F><><EFBFBD><EFBFBD>ֹ
|
||||
dto.IsBan = true;
|
||||
dto.SetBan();
|
||||
}
|
||||
break;
|
||||
case DiscussPermissionTypeEnum.User:
|
||||
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ֿɼ<D6BF><C9BC><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>¼<EFBFBD>û<EFBFBD> Ҳ <20><><EFBFBD>ڿɼ<DABF><C9BC>û<EFBFBD><C3BB>б<EFBFBD><D0B1><EFBFBD>
|
||||
if (dto.User.Id != userId && !dto.PermissionUserIds.Contains(userId))
|
||||
{
|
||||
dto.SetBan();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
public string? PrivateCode { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
|
||||
public List<long> PermissionUserIds { get; set; }
|
||||
public UserGetListOutputDto User { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
|
||||
public string Content { get; set; }
|
||||
public string? Color { get; set; }
|
||||
|
||||
public List<long> PermissionUserIds { get; set; }
|
||||
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
|
||||
|
||||
@@ -141,6 +141,13 @@ namespace Yi.BBS.Application.Forum
|
||||
throw new UserFriendlyException(DiscussConst.私密);
|
||||
}
|
||||
}
|
||||
if (discuss.PermissionType == DiscussPermissionTypeEnum.User)
|
||||
{
|
||||
if (discuss.CreatorId != _currentUser.Id && !discuss.PermissionUserIds.Contains(_currentUser.Id))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.私密);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ namespace Yi.BBS.Domain.Shared.Forum.ConstClasses
|
||||
{
|
||||
public const string 主题不存在 = "传入的主题id不存在";
|
||||
|
||||
public const string 私密 = "【私密】您无该主题权限";
|
||||
public const string 私密 = "【私密】您无该主题权限,可联系作者申请开放";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
封面
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Yi.BBS.Domain.Forum.Entities.DiscussEntity.PermissionUserIds">
|
||||
<summary>
|
||||
当PermissionType为部分用户时候,以下列表中的用户+创建者 代表拥有权限
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Domain.Forum.ForumManager">
|
||||
<summary>
|
||||
论坛模块的领域服务
|
||||
|
||||
@@ -54,5 +54,12 @@ namespace Yi.BBS.Domain.Forum.Entities
|
||||
public long? LastModifierId { get; set; }
|
||||
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当PermissionType为部分用户时候,以下列表中的用户+创建者 代表拥有权限
|
||||
/// </summary>
|
||||
[SugarColumn(IsJson = true)]//使用json处理
|
||||
public List<long> PermissionUserIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -18,5 +18,7 @@ namespace Yi.RBAC.Application.Contracts.Identity.Dtos
|
||||
|
||||
public long? DeptId { get; set; }
|
||||
|
||||
public string? Ids { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace Yi.RBAC.Application.Identity
|
||||
|
||||
RefAsync<int> total = 0;
|
||||
|
||||
|
||||
List<long>? ids = input.Ids?.Split(",").Select(x=>long.Parse(x)).ToList();
|
||||
var outPut = await _DbQueryable.WhereIF(!string.IsNullOrEmpty(input.UserName), x => x.UserName.Contains(input.UserName!))
|
||||
.WhereIF(input.Phone is not null, x => x.Phone.ToString()!.Contains(input.Phone.ToString()!))
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name!.Contains(input.Name!))
|
||||
@@ -56,6 +58,9 @@ namespace Yi.RBAC.Application.Identity
|
||||
|
||||
//这个为过滤当前部门,加入数据权限后,将由数据权限控制
|
||||
.WhereIF(input.DeptId is not null, x => x.DeptId == input.DeptId)
|
||||
|
||||
.WhereIF(ids is not null,x=> ids.Contains(x.Id))
|
||||
|
||||
|
||||
.LeftJoin<DeptEntity>((user, dept) => user.DeptId == dept.Id)
|
||||
.Select((user, dept) => new UserGetListOutputDto(), true)
|
||||
|
||||
Reference in New Issue
Block a user