|
@@ -15,6 +15,7 @@ using Hotline.Share.Tools;
|
|
|
using Hotline.Application.Tools;
|
|
|
using SqlSugar;
|
|
|
using Hotline.CaseLibrary;
|
|
|
+using Hotline.Planlibrary;
|
|
|
|
|
|
namespace Hotline.Application.Caselibrary
|
|
|
{
|
|
@@ -26,10 +27,10 @@ namespace Hotline.Application.Caselibrary
|
|
|
|
|
|
#region 注册
|
|
|
|
|
|
- private readonly IRepository<CaseList> _CaseListRepository; //案例库列表
|
|
|
- private readonly IRepository<CaseRelationType> _CaseRelationTypeRepository; //案例库关联类型
|
|
|
- private readonly IRepository<CaseType> _CaseTypeRepository; //案例库分类管理
|
|
|
- private readonly IRepository<CaseTypeOrg> _CaseTypeOrgRepository; //案例库分类关联机构
|
|
|
+ private readonly IRepository<CaseList> _caseListRepository; //案例库列表
|
|
|
+ private readonly IRepository<CaseRelationType> _caseRelationTypeRepository; //案例库关联类型
|
|
|
+ private readonly IRepository<CaseType> _caseTypeRepository; //案例库分类管理
|
|
|
+ private readonly IRepository<CaseTypeOrg> _caseTypeOrgRepository; //案例库分类关联机构
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IRepository<Hotspot> _hotspotTypeRepository;
|
|
@@ -47,10 +48,10 @@ namespace Hotline.Application.Caselibrary
|
|
|
IFileRepository fileRepository,
|
|
|
IBulletinApplication bulletinApplication)
|
|
|
{
|
|
|
- _CaseListRepository = CaseListRepository;
|
|
|
- _CaseRelationTypeRepository = CaseRelationTypeRepository;
|
|
|
- _CaseTypeRepository = CaseTypeRepository;
|
|
|
- _CaseTypeOrgRepository = CaseTypeOrgRepository;
|
|
|
+ _caseListRepository = CaseListRepository;
|
|
|
+ _caseRelationTypeRepository = CaseRelationTypeRepository;
|
|
|
+ _caseTypeRepository = CaseTypeRepository;
|
|
|
+ _caseTypeOrgRepository = CaseTypeOrgRepository;
|
|
|
_sessionContext = sessionContext;
|
|
|
_mapper = mapper;
|
|
|
_hotspotTypeRepository = hotspotTypeRepository;
|
|
@@ -72,7 +73,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
/// <returns></returns>
|
|
|
public async Task<string> AddTypeAsync(AddCaseTypeDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var sandard = await _CaseTypeRepository.GetAsync(p => p.ParentId == dto.ParentId && p.Name == dto.Name && p.IsDeleted == false, cancellationToken);
|
|
|
+ var sandard = await _caseTypeRepository.GetAsync(p => p.ParentId == dto.ParentId && p.Name == dto.Name && p.IsDeleted == false, cancellationToken);
|
|
|
if (sandard is not null)
|
|
|
throw UserFriendlyException.SameMessage("当前层级已存在相同名称的分类!");
|
|
|
|
|
@@ -83,7 +84,13 @@ namespace Hotline.Application.Caselibrary
|
|
|
string FullName = await GetFullName(type.ParentId);
|
|
|
//处理全称,如果为第一级直接用全称,否则获取全称后拼接名称
|
|
|
type.SpliceName = string.IsNullOrEmpty(FullName) ? dto.Name : FullName + "-" + dto.Name;
|
|
|
- var id = await _CaseTypeRepository.AddAsync(type, cancellationToken);
|
|
|
+ var id = await _caseTypeRepository.AddAsync(type, cancellationToken);
|
|
|
+ if (dto.TypeOrgDtos != null && dto.TypeOrgDtos.Any())
|
|
|
+ {
|
|
|
+ List<CaseTypeOrg> orgs = _mapper.Map<List<CaseTypeOrg>>(dto.TypeOrgDtos);
|
|
|
+ orgs.ForEach(x => x.TypeId = type.Id);
|
|
|
+ await _caseTypeOrgRepository.AddRangeAsync(orgs, cancellationToken);
|
|
|
+ }
|
|
|
return id;
|
|
|
}
|
|
|
|
|
@@ -100,7 +107,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
public async Task UpdateTypeAsync(UpdateCaseTypeDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//查询原有数据
|
|
|
- var type = await _CaseTypeRepository.GetAsync(dto.Id, cancellationToken);
|
|
|
+ var type = await _caseTypeRepository.GetAsync(dto.Id, cancellationToken);
|
|
|
if (type is null)
|
|
|
throw UserFriendlyException.SameMessage("编辑失败!");
|
|
|
bool result = type.Name != dto.Name || type.ParentId != dto.ParentId;
|
|
@@ -116,19 +123,19 @@ namespace Hotline.Application.Caselibrary
|
|
|
}
|
|
|
|
|
|
//修改数据
|
|
|
- await _CaseTypeRepository.UpdateAsync(type, cancellationToken);
|
|
|
+ await _caseTypeRepository.UpdateAsync(type, cancellationToken);
|
|
|
|
|
|
//如果修改了名称,对应修改子分类全称
|
|
|
if (result)
|
|
|
await UpdateChildNode(type.Id);
|
|
|
|
|
|
// 修改关联机构
|
|
|
- await _CaseTypeOrgRepository.RemoveAsync(x => x.TypeId == type.Id, false, cancellationToken);
|
|
|
+ await _caseTypeOrgRepository.RemoveAsync(x => x.TypeId == type.Id, false, cancellationToken);
|
|
|
if (dto.TypeOrgDtos != null && dto.TypeOrgDtos.Any())
|
|
|
{
|
|
|
List<CaseTypeOrg> orgs = _mapper.Map<List<CaseTypeOrg>>(dto.TypeOrgDtos);
|
|
|
orgs.ForEach(x => x.TypeId = type.Id);
|
|
|
- await _CaseTypeOrgRepository.AddRangeAsync(orgs, cancellationToken);
|
|
|
+ await _caseTypeOrgRepository.AddRangeAsync(orgs, cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -145,22 +152,22 @@ namespace Hotline.Application.Caselibrary
|
|
|
public async Task RemoveTypeAsync(string Id, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//查询数据是否存在
|
|
|
- var sandard = await _CaseTypeRepository.GetAsync(p => p.Id == Id && p.IsDeleted == false, cancellationToken);
|
|
|
+ var sandard = await _caseTypeRepository.GetAsync(p => p.Id == Id && p.IsDeleted == false, cancellationToken);
|
|
|
if (sandard is null)
|
|
|
throw UserFriendlyException.SameMessage("分类不存在!");
|
|
|
|
|
|
//查询是否有子级分类
|
|
|
- var checkChild = await _CaseTypeRepository.CountAsync(p => p.ParentId == Id && p.IsDeleted == false, cancellationToken);
|
|
|
+ var checkChild = await _caseTypeRepository.CountAsync(p => p.ParentId == Id && p.IsDeleted == false, cancellationToken);
|
|
|
if (checkChild > 0)
|
|
|
throw UserFriendlyException.SameMessage("存在子级分类!");
|
|
|
|
|
|
//查询是否有案例分类
|
|
|
- var checkKnowledge = await _CaseListRepository.CountAsync(p => p.CaseTypes.Any(t => t.CaseId == Id), cancellationToken);
|
|
|
+ var checkKnowledge = await _caseListRepository.CountAsync(p => p.CaseTypes.Any(t => t.CaseId == Id), cancellationToken);
|
|
|
if (checkKnowledge > 0)
|
|
|
throw UserFriendlyException.SameMessage("分类存在案例!");
|
|
|
|
|
|
//删除操作
|
|
|
- await _CaseTypeRepository.RemoveAsync(sandard, true, cancellationToken);
|
|
|
+ await _caseTypeRepository.RemoveAsync(sandard, true, cancellationToken);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -182,12 +189,12 @@ namespace Hotline.Application.Caselibrary
|
|
|
|
|
|
if (!string.IsNullOrEmpty(pagedDto.CaseTypeID))
|
|
|
{
|
|
|
- var type = await _CaseTypeRepository.GetAsync(x => x.Id == pagedDto.CaseTypeID);
|
|
|
+ var type = await _caseTypeRepository.GetAsync(x => x.Id == pagedDto.CaseTypeID);
|
|
|
typeSpliceName = type?.SpliceName;
|
|
|
}
|
|
|
|
|
|
//单表分页
|
|
|
- var (total, temp) = await _CaseListRepository.Queryable()
|
|
|
+ var (total, temp) = await _caseListRepository.Queryable()
|
|
|
.Includes(x => x.CaseTypes)
|
|
|
.Where(x => x.IsDeleted == false)
|
|
|
.Where(x => (x.Status == ECaseStatus.Drafts && x.CreatorId == _sessionContext.UserId) || (x.Status != ECaseStatus.Drafts))
|
|
@@ -243,19 +250,19 @@ namespace Hotline.Application.Caselibrary
|
|
|
{
|
|
|
var pList = _mapper.Map<CaseList>(dto);
|
|
|
|
|
|
- var any = await _CaseListRepository.Queryable().Where(x => x.Status == ECaseStatus.OnShelf && x.Title == dto.Title).AnyAsync();
|
|
|
+ var any = await _caseListRepository.Queryable().Where(x => x.Status == ECaseStatus.OnShelf && x.Title == dto.Title).AnyAsync();
|
|
|
if (any)
|
|
|
throw UserFriendlyException.SameMessage("当前案例标题存在重复标题!");
|
|
|
|
|
|
if (dto.Files != null && dto.Files.Count > 0)
|
|
|
pList.FileJson = await _fileRepository.AddFileAsync(dto.Files, pList.Id, "", cancellationToken);
|
|
|
- await _CaseListRepository.AddAsync(pList, cancellationToken);
|
|
|
+ await _caseListRepository.AddAsync(pList, cancellationToken);
|
|
|
|
|
|
if (dto.CaseType.Any())
|
|
|
{
|
|
|
List<CaseRelationType> types = _mapper.Map<List<CaseRelationType>>(dto.CaseType);
|
|
|
types.ForEach(x => x.CaseId = pList.Id);
|
|
|
- await _CaseRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
+ await _caseRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
}
|
|
|
|
|
|
return pList.Id;
|
|
@@ -273,7 +280,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
/// <returns></returns>
|
|
|
public async Task UpdateCaseAsync(UpdateCaseListDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var Case = await _CaseListRepository.GetAsync(dto.Id);
|
|
|
+ var Case = await _caseListRepository.GetAsync(dto.Id);
|
|
|
|
|
|
if (Case == null)
|
|
|
throw UserFriendlyException.SameMessage("案例库查询失败");
|
|
@@ -281,7 +288,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
if ((Case.Status == ECaseStatus.OnShelf || Case.Status == ECaseStatus.Auditing) && (Case.ExpiredTime.HasValue && Case.ExpiredTime.Value > DateTime.Now))
|
|
|
throw UserFriendlyException.SameMessage("案例库数据不可修改");
|
|
|
|
|
|
- var any = await _CaseListRepository.Queryable().Where(x => x.Status == ECaseStatus.OnShelf && x.Title == dto.Title && x.Id != dto.Id).AnyAsync();
|
|
|
+ var any = await _caseListRepository.Queryable().Where(x => x.Status == ECaseStatus.OnShelf && x.Title == dto.Title && x.Id != dto.Id).AnyAsync();
|
|
|
if (any)
|
|
|
throw UserFriendlyException.SameMessage("当前案例标题存在重复标题!");
|
|
|
|
|
@@ -292,15 +299,15 @@ namespace Hotline.Application.Caselibrary
|
|
|
else
|
|
|
Case.FileJson = new List<Share.Dtos.File.FileJson>();
|
|
|
|
|
|
- await _CaseListRepository.UpdateNullAsync(Case, cancellationToken);
|
|
|
+ await _caseListRepository.UpdateNullAsync(Case, cancellationToken);
|
|
|
if (dto.CaseType.Any())
|
|
|
{
|
|
|
- var anyRelationTypes = await _CaseRelationTypeRepository.Queryable().Where(x => x.CaseId == Case.Id).ToListAsync();
|
|
|
+ var anyRelationTypes = await _caseRelationTypeRepository.Queryable().Where(x => x.CaseId == Case.Id).ToListAsync();
|
|
|
if (anyRelationTypes.Any())
|
|
|
- await _CaseRelationTypeRepository.RemoveRangeAsync(anyRelationTypes);
|
|
|
+ await _caseRelationTypeRepository.RemoveRangeAsync(anyRelationTypes);
|
|
|
List<CaseRelationType> types = _mapper.Map<List<CaseRelationType>>(dto.CaseType);
|
|
|
types.ForEach(x => x.CaseId = dto.Id);
|
|
|
- await _CaseRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
+ await _caseRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -316,7 +323,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
/// <returns></returns>
|
|
|
public async Task AuditCaseAsync(UpdateCaseListDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var Case = await _CaseListRepository.GetAsync(dto.Id);
|
|
|
+ var Case = await _caseListRepository.GetAsync(dto.Id);
|
|
|
|
|
|
if (Case == null)
|
|
|
throw UserFriendlyException.SameMessage("案例库查询失败");
|
|
@@ -328,7 +335,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
Case.ExaminOrganizeId = dto.ExaminOrganizeId;
|
|
|
Case.UpdateTime = dto.UpdateTime;
|
|
|
|
|
|
- await _CaseListRepository.UpdateNullAsync(Case, cancellationToken);
|
|
|
+ await _caseListRepository.UpdateNullAsync(Case, cancellationToken);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -343,7 +350,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
/// <returns></returns>
|
|
|
public async Task<CaseInfoDto> GetCaseAsync(string Id, bool? IsAddPv, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var Case = await _CaseListRepository.GetAsync(Id);
|
|
|
+ var Case = await _caseListRepository.GetAsync(Id);
|
|
|
if (Case == null)
|
|
|
throw UserFriendlyException.SameMessage("案例库查询失败");
|
|
|
;
|
|
@@ -355,11 +362,13 @@ namespace Hotline.Application.Caselibrary
|
|
|
if (Case != null)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(Case.Describe))
|
|
|
- CaseInfoDto.Content = _bulletinApplication.GetSiteUrls(Case.Describe);
|
|
|
+ CaseInfoDto.Abstract = _bulletinApplication.GetSiteUrls(Case.Abstract);
|
|
|
+ if (!string.IsNullOrEmpty(Case.Describe))
|
|
|
+ CaseInfoDto.Describe = _bulletinApplication.GetSiteUrls(Case.Describe);
|
|
|
if (!string.IsNullOrEmpty(Case.Result))
|
|
|
- CaseInfoDto.Content = _bulletinApplication.GetSiteUrls(Case.Result);
|
|
|
+ CaseInfoDto.Result = _bulletinApplication.GetSiteUrls(Case.Result);
|
|
|
if (!string.IsNullOrEmpty(Case.Reason))
|
|
|
- CaseInfoDto.Content = _bulletinApplication.GetSiteUrls(Case.Reason);
|
|
|
+ CaseInfoDto.Reason = _bulletinApplication.GetSiteUrls(Case.Reason);
|
|
|
}
|
|
|
|
|
|
if (CaseInfoDto.FileJson != null && CaseInfoDto.FileJson.Any())
|
|
@@ -374,7 +383,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
//修改浏览量
|
|
|
Case.PageView++;
|
|
|
//修改点击量
|
|
|
- await _CaseListRepository.UpdateAsync(Case, cancellationToken);
|
|
|
+ await _caseListRepository.UpdateAsync(Case, cancellationToken);
|
|
|
}
|
|
|
return CaseInfoDto;
|
|
|
}
|
|
@@ -392,7 +401,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
public async Task<Dictionary<string, Stream>> CaseInfoListExportAsync(CaseInfoExportDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var streamList = new Dictionary<string, Stream>();
|
|
|
- var knowList = await _CaseListRepository.Queryable()
|
|
|
+ var knowList = await _caseListRepository.Queryable()
|
|
|
.Where(m => dto.Ids.Contains(m.Id))
|
|
|
.Select(m => new { m.Title, m.Result })
|
|
|
.ToListAsync(cancellationToken);
|
|
@@ -488,7 +497,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
{
|
|
|
List<string> list = new();
|
|
|
//查询父级数据
|
|
|
- var type = await _CaseTypeRepository.GetAsync(p => p.Id == Id);
|
|
|
+ var type = await _caseTypeRepository.GetAsync(p => p.Id == Id);
|
|
|
if (type != null)
|
|
|
{
|
|
|
//添加名称
|
|
@@ -519,7 +528,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
string FullName = await GetFullName(item.ParentId);
|
|
|
item.SpliceName = string.IsNullOrEmpty(FullName) ? item.Name : FullName + "-" + item.Name;
|
|
|
//修改全称
|
|
|
- await _CaseTypeRepository.UpdateAsync(item);
|
|
|
+ await _caseTypeRepository.UpdateAsync(item);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -533,7 +542,7 @@ namespace Hotline.Application.Caselibrary
|
|
|
{
|
|
|
List<CaseType> list = new();
|
|
|
//查询数据
|
|
|
- var typelist = await _CaseTypeRepository.QueryAsync(p => p.ParentId == Id);
|
|
|
+ var typelist = await _caseTypeRepository.QueryAsync(p => p.ParentId == Id);
|
|
|
if (typelist != null)
|
|
|
{
|
|
|
//处理数据
|