|
@@ -1,5 +1,7 @@
|
|
using Hotline.KnowledgeBase;
|
|
using Hotline.KnowledgeBase;
|
|
using Hotline.Permissions;
|
|
using Hotline.Permissions;
|
|
|
|
+using Hotline.Settings;
|
|
|
|
+using Hotline.Settings.Hotspots;
|
|
using Hotline.Share.Dtos.Knowledge;
|
|
using Hotline.Share.Dtos.Knowledge;
|
|
using MapsterMapper;
|
|
using MapsterMapper;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
@@ -22,6 +24,8 @@ namespace Hotline.Api.Controllers
|
|
private readonly IRepository<KnowledgeStandard> _knowledgeStandardRepository;
|
|
private readonly IRepository<KnowledgeStandard> _knowledgeStandardRepository;
|
|
private readonly IMapper _mapper;
|
|
private readonly IMapper _mapper;
|
|
private readonly ISessionContext _sessionContext;
|
|
private readonly ISessionContext _sessionContext;
|
|
|
|
+ private readonly ISystemOrganizeRepository _systemOrganizeRepository;
|
|
|
|
+ private readonly IRepository<Hotspot> _hotspotTypeRepository;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
///
|
|
///
|
|
@@ -32,14 +36,15 @@ namespace Hotline.Api.Controllers
|
|
/// <param name="mapper"></param>
|
|
/// <param name="mapper"></param>
|
|
public KnowledgeCommonController(IRepository<KnowledgeType> knowledgeTypeRepository, IKnowledgeTypeDomainService knowledgeTypeDomainService,
|
|
public KnowledgeCommonController(IRepository<KnowledgeType> knowledgeTypeRepository, IKnowledgeTypeDomainService knowledgeTypeDomainService,
|
|
IRepository<KnowledgeStandard> knowledgeStandardRepository, ISessionContext sessionContext,
|
|
IRepository<KnowledgeStandard> knowledgeStandardRepository, ISessionContext sessionContext,
|
|
- IMapper mapper)
|
|
|
|
|
|
+ IMapper mapper, ISystemOrganizeRepository systemOrganizeRepository, IRepository<Hotspot> hotspotTypeRepository)
|
|
{
|
|
{
|
|
_knowledgeTypeRepository = knowledgeTypeRepository;
|
|
_knowledgeTypeRepository = knowledgeTypeRepository;
|
|
_knowledgeTypeDomainService = knowledgeTypeDomainService;
|
|
_knowledgeTypeDomainService = knowledgeTypeDomainService;
|
|
_knowledgeStandardRepository = knowledgeStandardRepository;
|
|
_knowledgeStandardRepository = knowledgeStandardRepository;
|
|
_mapper = mapper;
|
|
_mapper = mapper;
|
|
_sessionContext = sessionContext;
|
|
_sessionContext = sessionContext;
|
|
-
|
|
|
|
|
|
+ _systemOrganizeRepository = systemOrganizeRepository;
|
|
|
|
+ _hotspotTypeRepository = hotspotTypeRepository;
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
@@ -138,7 +143,7 @@ namespace Hotline.Api.Controllers
|
|
/// <param name="IsEnable">不传查询所有</param>
|
|
/// <param name="IsEnable">不传查询所有</param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpGet("treelist")]
|
|
[HttpGet("treelist")]
|
|
- public async Task<List<KnowledgeTypeDto>> GetTreeList(bool? IsEnable)
|
|
|
|
|
|
+ public async Task<List<KnowledgeTypeDto>> GetTreeList(bool? IsEnable,string? Attribution)
|
|
{
|
|
{
|
|
return await _knowledgeTypeRepository.Queryable().WhereIF(IsEnable.HasValue, x =>x.IsEnable == IsEnable)
|
|
return await _knowledgeTypeRepository.Queryable().WhereIF(IsEnable.HasValue, x =>x.IsEnable == IsEnable)
|
|
//.Where(x => x.KnowledgeTypeOrgs.Any(to => to.OrgId == _sessionContext.RequiredOrgId) || x.KnowledgeTypeOrgs.Any() == false)
|
|
//.Where(x => x.KnowledgeTypeOrgs.Any(to => to.OrgId == _sessionContext.RequiredOrgId) || x.KnowledgeTypeOrgs.Any() == false)
|
|
@@ -146,19 +151,98 @@ namespace Hotline.Api.Controllers
|
|
.Select(x=> new KnowledgeTypeDto()
|
|
.Select(x=> new KnowledgeTypeDto()
|
|
{
|
|
{
|
|
Id = x.Id.SelectAll(),
|
|
Id = x.Id.SelectAll(),
|
|
- KnowledgeNum = SqlFunc.Subqueryable<KnowledgeRelationType>().Where(kr=>kr.KnowledgeTypeId == x.Id).DistinctCount(kr=>kr.KnowledgeId)
|
|
|
|
|
|
+ KnowledgeNum = SqlFunc.Subqueryable<KnowledgeRelationType>().LeftJoin<Knowledge>((kr,k)=> kr.KnowledgeId == k.Id)
|
|
|
|
+ .Where((kr, k)=>kr.KnowledgeTypeSpliceName.StartsWith(x.SpliceName))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(Attribution),(kr,k)=>k.Attribution == Attribution).DistinctCount(kr=>kr.KnowledgeId)
|
|
|
|
|
|
})
|
|
})
|
|
.OrderBy(x => x.Sort).ToTreeAsync(it => it.children, it => it.ParentId, null,it=> it.Id);
|
|
.OrderBy(x => x.Sort).ToTreeAsync(it => it.children, it => it.ParentId, null,it=> it.Id);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 知识分类- 只获取一级
|
|
|
|
|
|
+ /// 知识部门
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// <param name="ParentId">不传默认查询第一级</param>
|
|
|
|
- /// <param name="IsEnable">不传查询所有,包含已经禁用的</param>
|
|
|
|
|
|
+ /// <param name="IsEnable">不传查询所有</param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- [HttpGet("typelist")]
|
|
|
|
|
|
+ [HttpGet("treelist/org")]
|
|
|
|
+ public async Task<List<KnowledgeOrgDto>> GetTreeList(string? Attribution)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ //await Db.Queryable<SystemOrganize>()
|
|
|
|
+ // .Where(it => it.Id.StartsWith(orgCode))
|
|
|
|
+ // .OrderBy(d => d.Id)
|
|
|
|
+ // .ToTreeAsync(it => it.Children, it => it.ParentId, orgCode.Length > 6 ? orgCode.Substring(0, orgCode.Length - 3) : null);
|
|
|
|
+ var orgCode = _sessionContext.RequiredOrgId;
|
|
|
|
+ var query= _systemOrganizeRepository.Queryable().WhereIF(!_sessionContext.OrgIsCenter, it => it.Id.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
|
+ .Select(it=> new KnowledgeOrgDto()
|
|
|
|
+ {
|
|
|
|
+ Id = it.Id.SelectAll(),
|
|
|
|
+ KnowledgeNum = SqlFunc.Subqueryable<Knowledge>()
|
|
|
|
+ .Where(k => k.CreatorOrgId.StartsWith(it.Id))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(Attribution), k => k.Attribution == Attribution).DistinctCount(k => k.Id)
|
|
|
|
+
|
|
|
|
+ }).OrderBy(d => d.Id);
|
|
|
|
+
|
|
|
|
+ if (_sessionContext.OrgIsCenter)
|
|
|
|
+ {
|
|
|
|
+ return await query.ToTreeAsync(x => x.Children, it => it.ParentId, null);
|
|
|
|
+ }
|
|
|
|
+ return await query.ToTreeAsync(it => it.Children, it => it.ParentId, orgCode.Length > 6 ? orgCode.Substring(0, orgCode.Length - 3) : null);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查询子项
|
|
|
|
+ /// </summary>
|
|
|
|
+ [HttpGet("treelist/hotspot")]
|
|
|
|
+ public async Task<IReadOnlyList<KnowledgeHotSpotDto>> GetChildren([FromQuery] string? id, string? Attribution)
|
|
|
|
+ {
|
|
|
|
+ var list = await _hotspotTypeRepository.Queryable()
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(id), x => x.ParentId == id)
|
|
|
|
+ .WhereIF(string.IsNullOrEmpty(id), x => x.ParentId == null || x.ParentId == "")
|
|
|
|
+ .OrderBy(d => d.HotSpotName)
|
|
|
|
+ .Select(x => new KnowledgeHotSpotDto
|
|
|
|
+ {
|
|
|
|
+ Id = x.Id.SelectAll(),
|
|
|
|
+ HasChild = SqlFunc.Subqueryable<Hotspot>().Where(d => d.ParentId == x.Id).NotAny(),
|
|
|
|
+ KnowledgeNum = SqlFunc.Subqueryable<Knowledge>().LeftJoin<Hotspot>((k,h)=>k.HotspotId == h.Id)
|
|
|
|
+ .Where((k,h) =>h.HotSpotFullName.StartsWith(x.HotSpotFullName))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(Attribution), (k,h) => k.Attribution == Attribution).DistinctCount(k => k.Id)
|
|
|
|
+ }).ToListAsync();
|
|
|
|
+
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 名称检索热点树形
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="name"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpGet("treelist/children-hasname")]
|
|
|
|
+ public async Task<IReadOnlyList<KnowledgeHotSpotDto>> GetChildrenHasName([FromQuery] string Name, string? Attribution)
|
|
|
|
+ {
|
|
|
|
+ var arr = _hotspotTypeRepository.Queryable()
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(Name), x => x.HotSpotFullName.Contains(Name)).Select(x => x.Id).ToList().Cast<object>().ToArray();
|
|
|
|
+ //.ToTreeAsync(x => x.Children, it => it.ParentId, null);
|
|
|
|
+ return await _hotspotTypeRepository.Queryable().Select(x => new KnowledgeHotSpotDto
|
|
|
|
+ {
|
|
|
|
+ Id = x.Id.SelectAll(),
|
|
|
|
+ HasChild = SqlFunc.Subqueryable<Hotspot>().Where(d => d.ParentId == x.Id).NotAny(),
|
|
|
|
+ KnowledgeNum = SqlFunc.Subqueryable<Knowledge>().LeftJoin<Hotspot>((k, h) => k.HotspotId == h.Id)
|
|
|
|
+ .Where((k, h) => h.HotSpotFullName.StartsWith(x.HotSpotFullName))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(Attribution), (k, h) => k.Attribution == Attribution).DistinctCount(k => k.Id)
|
|
|
|
+ }).ToTreeAsync(x => x.Children, it => it.ParentId, "", arr);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 知识分类- 只获取一级
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="ParentId">不传默认查询第一级</param>
|
|
|
|
+ /// <param name="IsEnable">不传查询所有,包含已经禁用的</param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpGet("typelist")]
|
|
public async Task<List<KnowledgeType>> GetTypeList(string? ParentId, bool? IsEnable)
|
|
public async Task<List<KnowledgeType>> GetTypeList(string? ParentId, bool? IsEnable)
|
|
{
|
|
{
|
|
return await _knowledgeTypeRepository
|
|
return await _knowledgeTypeRepository
|