|
@@ -16,6 +16,9 @@ using Hotline.Share.Tools;
|
|
|
using Hotline.Application.Tools;
|
|
|
using SqlSugar;
|
|
|
using Hotline.KnowledgeBase;
|
|
|
+using Hotline.Repository.SqlSugar.Knowledge;
|
|
|
+using Hotline.Share.Enums.KnowledgeBase;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
namespace Hotline.Application.Planlibrary
|
|
|
{
|
|
@@ -31,6 +34,7 @@ namespace Hotline.Application.Planlibrary
|
|
|
private readonly IRepository<PlanRelationType> _planRelationTypeRepository; //预案库关联类型
|
|
|
private readonly IRepository<PlanType> _planTypeRepository; //预案库分类管理
|
|
|
private readonly IRepository<PlanTypeOrg> _planTypeOrgRepository; //预案库分类关联机构
|
|
|
+ private readonly IRepository<PlanCollect> _planCollectRepository; //预案库分类关联机构
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IRepository<Hotspot> _hotspotTypeRepository;
|
|
@@ -46,7 +50,8 @@ namespace Hotline.Application.Planlibrary
|
|
|
IMapper mapper,
|
|
|
IRepository<Hotspot> hotspotTypeRepository,
|
|
|
IFileRepository fileRepository,
|
|
|
- IBulletinApplication bulletinApplication)
|
|
|
+ IBulletinApplication bulletinApplication,
|
|
|
+ IRepository<PlanCollect> planCollectRepository)
|
|
|
{
|
|
|
_planListRepository = planListRepository;
|
|
|
_planRelationTypeRepository = planRelationTypeRepository;
|
|
@@ -57,6 +62,7 @@ namespace Hotline.Application.Planlibrary
|
|
|
_hotspotTypeRepository = hotspotTypeRepository;
|
|
|
_fileRepository = fileRepository;
|
|
|
_bulletinApplication = bulletinApplication;
|
|
|
+ _planCollectRepository = planCollectRepository;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -209,6 +215,7 @@ namespace Hotline.Application.Planlibrary
|
|
|
var (total, temp) = await _planListRepository.Queryable()
|
|
|
.Includes(x => x.PlanTypes)
|
|
|
.Includes(x => x.HotspotType)
|
|
|
+ .Includes(x => x.ExaminMan)
|
|
|
.Where(x => x.IsDeleted == false)
|
|
|
.Where(x => (x.Status == EPlanStatus.Drafts && x.CreatorId == _sessionContext.UserId) || (x.Status != EPlanStatus.Drafts))
|
|
|
.WhereIF(OrgSeedData.CenterId != pagedDto.CreateOrgId && !string.IsNullOrEmpty(pagedDto.CreateOrgId), x => x.CreatorOrgId != null && x.CreatorOrgId.StartsWith(pagedDto.CreateOrgId!))
|
|
@@ -274,9 +281,9 @@ namespace Hotline.Application.Planlibrary
|
|
|
pList.FileJson = await _fileRepository.AddFileAsync(dto.Files, pList.Id, "", cancellationToken);
|
|
|
await _planListRepository.AddAsync(pList, cancellationToken);
|
|
|
|
|
|
- if (dto.PlanType.Any())
|
|
|
+ if (dto.PlanTypes.Any())
|
|
|
{
|
|
|
- List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanType);
|
|
|
+ List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanTypes);
|
|
|
types.ForEach(x => x.PlanId = pList.Id);
|
|
|
await _planRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
}
|
|
@@ -318,12 +325,12 @@ namespace Hotline.Application.Planlibrary
|
|
|
plan.FileJson = new List<Share.Dtos.File.FileJson>();
|
|
|
|
|
|
await _planListRepository.UpdateNullAsync(plan, cancellationToken);
|
|
|
- if (dto.PlanType.Any())
|
|
|
+ if (dto.PlanTypes.Any())
|
|
|
{
|
|
|
var anyRelationTypes = await _planRelationTypeRepository.Queryable().Where(x => x.PlanId == plan.Id).ToListAsync();
|
|
|
if (anyRelationTypes.Any())
|
|
|
await _planRelationTypeRepository.RemoveRangeAsync(anyRelationTypes);
|
|
|
- List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanType);
|
|
|
+ List<PlanRelationType> types = _mapper.Map<List<PlanRelationType>>(dto.PlanTypes);
|
|
|
types.ForEach(x => x.PlanId = dto.Id);
|
|
|
await _planRelationTypeRepository.AddRangeAsync(types, cancellationToken);
|
|
|
}
|
|
@@ -399,17 +406,31 @@ namespace Hotline.Application.Planlibrary
|
|
|
if (plan == null)
|
|
|
throw UserFriendlyException.SameMessage("预案库查询失败");
|
|
|
;
|
|
|
- //转化
|
|
|
+ // 转化
|
|
|
var planInfoDto = _mapper.Map<PlanInfoDto>(plan);
|
|
|
|
|
|
+ // 内容
|
|
|
if (plan != null && !string.IsNullOrEmpty(plan.Content))
|
|
|
planInfoDto.Content = _bulletinApplication.GetSiteUrls(plan.Content);
|
|
|
|
|
|
// 热点
|
|
|
- //var hot = await _hotspotTypeRepository.GetAsync(plan.HotspotId, cancellationToken);
|
|
|
- //if (hot != null)
|
|
|
- // planDto.HotspotId = hot.HotSpotFullName;
|
|
|
+ var hot = await _hotspotTypeRepository.GetAsync(plan.HotspotId, cancellationToken);
|
|
|
+ if (hot != null)
|
|
|
+ planInfoDto.HotspotName = hot.HotSpotFullName;
|
|
|
|
|
|
+ // 分类
|
|
|
+ var relationType = await _planRelationTypeRepository.QueryAsync(x => x.PlanId == Id && x.CreatorId == _sessionContext.UserId);
|
|
|
+ if (relationType != null)
|
|
|
+ {
|
|
|
+ planInfoDto.PlanTypes = _mapper.Map<List<PlanRelationTypeDto>>(relationType);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收藏
|
|
|
+ var collect = await _planCollectRepository.GetAsync(x => x.PlanId == Id && x.CreatorId == _sessionContext.UserId);
|
|
|
+ if (collect != null)
|
|
|
+ planInfoDto.Collect = _mapper.Map<PlanCollectDto>(collect);
|
|
|
+
|
|
|
+ // 附件
|
|
|
if (planInfoDto.FileJson != null && planInfoDto.FileJson.Any())
|
|
|
{
|
|
|
var ids = planInfoDto.FileJson.Select(x => x.Id).ToList();
|