|
@@ -89,11 +89,11 @@ namespace Hotline.KnowledgeBase
|
|
//查询是否有数据
|
|
//查询是否有数据
|
|
if (!string.IsNullOrEmpty(Id))
|
|
if (!string.IsNullOrEmpty(Id))
|
|
{
|
|
{
|
|
- var type = await _knowledgeTypeRepository.GetAsync(p => p.Id == Id, cancellationToken);
|
|
|
|
|
|
+ var type = await _knowledgeTypeRepository.GetAsync(p => p.Id == Id && p.IsDeleted == false, cancellationToken);
|
|
_mapper.Map(type, knowledgeTypeDto);
|
|
_mapper.Map(type, knowledgeTypeDto);
|
|
}
|
|
}
|
|
//查询已经启用的分类名称
|
|
//查询已经启用的分类名称
|
|
- var list = await _knowledgeTypeRepository.QueryAsync(p => p.IsEnable == true);
|
|
|
|
|
|
+ var list = await _knowledgeTypeRepository.QueryAsync(p => p.IsEnable == true && p.IsDeleted == false);
|
|
//分类组装树形
|
|
//分类组装树形
|
|
knowledgeTypeDto.TreeLists = GetChildren(list, Guid.Empty.ToString(), ParentId);
|
|
knowledgeTypeDto.TreeLists = GetChildren(list, Guid.Empty.ToString(), ParentId);
|
|
|
|
|
|
@@ -109,7 +109,7 @@ namespace Hotline.KnowledgeBase
|
|
public async Task ChangeStateType(string Id, CancellationToken cancellationToken)
|
|
public async Task ChangeStateType(string Id, CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
//查询数据是否存在
|
|
//查询数据是否存在
|
|
- var type = await _knowledgeTypeRepository.GetAsync(Id);
|
|
|
|
|
|
+ var type = await _knowledgeTypeRepository.GetAsync(p => p.Id == Id && p.IsDeleted == false, cancellationToken);
|
|
if (type is null)
|
|
if (type is null)
|
|
throw UserFriendlyException.SameMessage("分类不存在!");
|
|
throw UserFriendlyException.SameMessage("分类不存在!");
|
|
if (type.IsEnable)//启用
|
|
if (type.IsEnable)//启用
|
|
@@ -129,7 +129,7 @@ namespace Hotline.KnowledgeBase
|
|
else //禁用
|
|
else //禁用
|
|
{
|
|
{
|
|
//查询上级是否是启用状态,如果是禁用状态不能修改
|
|
//查询上级是否是启用状态,如果是禁用状态不能修改
|
|
- var CheckParent = await _knowledgeTypeRepository.GetAsync(type.ParentId, cancellationToken);
|
|
|
|
|
|
+ var CheckParent = await _knowledgeTypeRepository.GetAsync(p => p.Id == type.ParentId && p.IsDeleted == false, cancellationToken);
|
|
if (CheckParent is null)
|
|
if (CheckParent is null)
|
|
throw UserFriendlyException.SameMessage("分类启用失败!");
|
|
throw UserFriendlyException.SameMessage("分类启用失败!");
|
|
if (!CheckParent.IsEnable)
|
|
if (!CheckParent.IsEnable)
|
|
@@ -150,7 +150,7 @@ namespace Hotline.KnowledgeBase
|
|
public async Task ChangeStateTypeAndOffShelf(string Id, CancellationToken cancellationToken)
|
|
public async Task ChangeStateTypeAndOffShelf(string Id, CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
//查询数据是否存在
|
|
//查询数据是否存在
|
|
- var type = await _knowledgeTypeRepository.GetAsync(Id, cancellationToken);
|
|
|
|
|
|
+ var type = await _knowledgeTypeRepository.GetAsync(p => p.Id == Id, cancellationToken);
|
|
if (type is null)
|
|
if (type is null)
|
|
throw UserFriendlyException.SameMessage("分类不存在!");
|
|
throw UserFriendlyException.SameMessage("分类不存在!");
|
|
if (type.IsEnable)//启用状态
|
|
if (type.IsEnable)//启用状态
|
|
@@ -194,12 +194,12 @@ namespace Hotline.KnowledgeBase
|
|
public async Task RemoveType(string Id, CancellationToken cancellationToken)
|
|
public async Task RemoveType(string Id, CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
//查询数据是否存在
|
|
//查询数据是否存在
|
|
- var sandard = await _knowledgeTypeRepository.GetAsync(Id, cancellationToken);
|
|
|
|
|
|
+ var sandard = await _knowledgeTypeRepository.GetAsync(p => p.Id == Id && p.IsDeleted == false, cancellationToken);
|
|
if (sandard is null)
|
|
if (sandard is null)
|
|
throw UserFriendlyException.SameMessage("分类不存在!");
|
|
throw UserFriendlyException.SameMessage("分类不存在!");
|
|
|
|
|
|
//查询是否有子级分类
|
|
//查询是否有子级分类
|
|
- var checkChild = await _knowledgeTypeRepository.CountAsync(p => p.ParentId == Id, cancellationToken);
|
|
|
|
|
|
+ var checkChild = await _knowledgeTypeRepository.CountAsync(p => p.ParentId == Id && p.IsDeleted == false, cancellationToken);
|
|
if (checkChild > 0)
|
|
if (checkChild > 0)
|
|
throw UserFriendlyException.SameMessage("存在子级分类!");
|
|
throw UserFriendlyException.SameMessage("存在子级分类!");
|
|
|
|
|
|
@@ -209,7 +209,7 @@ namespace Hotline.KnowledgeBase
|
|
throw UserFriendlyException.SameMessage("分类存在知识!");
|
|
throw UserFriendlyException.SameMessage("分类存在知识!");
|
|
|
|
|
|
//删除操作
|
|
//删除操作
|
|
- await _knowledgeTypeRepository.RemoveAsync(sandard, false, cancellationToken);
|
|
|
|
|
|
+ await _knowledgeTypeRepository.RemoveAsync(sandard, true, cancellationToken);
|
|
}
|
|
}
|
|
|
|
|
|
#region 私有方法
|
|
#region 私有方法
|