|
@@ -12,6 +12,10 @@ using Hotline.Share.Tools;
|
|
|
using Hotline.Share.Enums.Caselibrary;
|
|
|
using Hotline.Application.ExportWord;
|
|
|
using Hotline.Application.Tools;
|
|
|
+using Hotline.Share.Dtos.Planlibrary;
|
|
|
+using Hotline.Share.Enums.Planlibrary;
|
|
|
+using Hotline.Share.Enums.Article;
|
|
|
+using XF.Utility.EnumExtensions;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
@@ -25,10 +29,10 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
- private readonly ICaseApplication _CaseApplication;
|
|
|
- private readonly IRepository<CaseType> _CaseTypeRepository;
|
|
|
- private readonly IRepository<CaseList> _CaseListRepository;
|
|
|
- private readonly IRepository<CaseCollect> _CaseCollectRepository;
|
|
|
+ private readonly ICaseApplication _caseApplication;
|
|
|
+ private readonly IRepository<CaseType> _caseTypeRepository;
|
|
|
+ private readonly IRepository<CaseList> _caseListRepository;
|
|
|
+ private readonly IRepository<CaseCollect> _caseCollectRepository;
|
|
|
private readonly IWordHelperService _wordHelperService;
|
|
|
|
|
|
|
|
@@ -43,10 +47,10 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_sessionContext = sessionContext;
|
|
|
- _CaseApplication = CaseApplication;
|
|
|
- _CaseTypeRepository = CaseTypeRepository;
|
|
|
- _CaseListRepository = CaseListRepository;
|
|
|
- _CaseCollectRepository = CaseCollectRepository;
|
|
|
+ _caseApplication = CaseApplication;
|
|
|
+ _caseTypeRepository = CaseTypeRepository;
|
|
|
+ _caseListRepository = CaseListRepository;
|
|
|
+ _caseCollectRepository = CaseCollectRepository;
|
|
|
_wordHelperService = wordHelperService;
|
|
|
}
|
|
|
|
|
@@ -62,7 +66,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("type/treelist")]
|
|
|
public async Task<List<CaseTypeDto>> QueryAllTreeList(bool? IsEnable)
|
|
|
{
|
|
|
- return await _CaseTypeRepository.Queryable()
|
|
|
+ return await _caseTypeRepository.Queryable()
|
|
|
.WhereIF(IsEnable.HasValue, x => x.IsEnable == IsEnable)
|
|
|
.Where(x => SqlFunc.Subqueryable<CaseTypeOrg>().Where(to => to.TypeId == x.Id).Any() ||
|
|
|
SqlFunc.Subqueryable<CaseTypeOrg>().Where(to => to.TypeId == x.Id).NotAny()
|
|
@@ -83,7 +87,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("type/add")]
|
|
|
public async Task<string> AddType([FromBody] AddCaseTypeDto dto)
|
|
|
{
|
|
|
- return await _CaseApplication.AddTypeAsync(dto, HttpContext.RequestAborted);
|
|
|
+ return await _caseApplication.AddTypeAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -94,7 +98,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPut("type/update")]
|
|
|
public async Task UpdateType([FromBody] UpdateCaseTypeDto dto)
|
|
|
{
|
|
|
- await _CaseApplication.UpdateTypeAsync(dto, HttpContext.RequestAborted);
|
|
|
+ await _caseApplication.UpdateTypeAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -105,7 +109,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("type/info/{Id}")]
|
|
|
public async Task<CaseType> GetType(string Id)
|
|
|
{
|
|
|
- var types = await _CaseTypeRepository.Queryable()
|
|
|
+ var types = await _caseTypeRepository.Queryable()
|
|
|
.Includes(x => x.CaseTypeOrgs) // 填充子对象
|
|
|
.Where(x => x.Id == Id)
|
|
|
.FirstAsync(HttpContext.RequestAborted);
|
|
@@ -122,7 +126,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpDelete("type/remove/{Id}")]
|
|
|
public async Task RemoveType(string Id)
|
|
|
{
|
|
|
- await _CaseApplication.RemoveTypeAsync(Id, HttpContext.RequestAborted);
|
|
|
+ await _caseApplication.RemoveTypeAsync(Id, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -137,7 +141,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("list/treelist")]
|
|
|
public async Task<List<CaseTypeDto>> QueryAllCaseTypeTreeList(bool? IsEnable)
|
|
|
{
|
|
|
- return await _CaseTypeRepository.Queryable()
|
|
|
+ return await _caseTypeRepository.Queryable()
|
|
|
.WhereIF(IsEnable.HasValue, x => x.IsEnable == IsEnable)
|
|
|
.Where(x => SqlFunc.Subqueryable<CaseTypeOrg>().Where(to => to.TypeId == x.Id).Any() ||
|
|
|
SqlFunc.Subqueryable<CaseTypeOrg>().Where(to => to.TypeId == x.Id).NotAny()
|
|
@@ -161,7 +165,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("list")]
|
|
|
public async Task<PagedDto<CaseDataDto>> QueryAllCaseList([FromQuery] CaseListDto pagedDto)
|
|
|
{
|
|
|
- return (await _CaseApplication.QueryAllCaseListAsync(pagedDto, HttpContext.RequestAborted)).ToPaged();
|
|
|
+ return (await _caseApplication.QueryAllCaseListAsync(pagedDto, HttpContext.RequestAborted)).ToPaged();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -173,7 +177,7 @@ namespace Hotline.Api.Controllers
|
|
|
public async Task<string> CaseDraft([FromBody] AddCaseListDto dto)
|
|
|
{
|
|
|
dto.Status = ECaseStatus.NewDrafts;
|
|
|
- return await _CaseApplication.AddCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ return await _caseApplication.AddCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -185,7 +189,7 @@ namespace Hotline.Api.Controllers
|
|
|
public async Task UpdateCaseDraft([FromBody] UpdateCaseListDto dto)
|
|
|
{
|
|
|
dto.Status = ECaseStatus.NewDrafts;
|
|
|
- await _CaseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ await _caseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -198,7 +202,34 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
dto.ApplyStatus = ECaseApplyStatus.Add;
|
|
|
dto.Status = ECaseStatus.Auditing;
|
|
|
- await _CaseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ await _caseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 案例库草稿删除
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("list/draftremove")]
|
|
|
+ public async Task RemovePlanDraft([FromBody] UpdateCaseListDto dto)
|
|
|
+ {
|
|
|
+ dto.ApplyStatus = ECaseApplyStatus.Delete;
|
|
|
+ dto.Status = ECaseStatus.Auditing;
|
|
|
+ dto.IsDeleted = true;
|
|
|
+ await _caseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 案例库删除
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("list/remove")]
|
|
|
+ public async Task RemovePlan([FromBody] UpdateCaseListDto dto)
|
|
|
+ {
|
|
|
+ dto.ApplyStatus = ECaseApplyStatus.Delete;
|
|
|
+ dto.Status = ECaseStatus.Auditing;
|
|
|
+ await _caseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -211,7 +242,7 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
dto.ApplyStatus = ECaseApplyStatus.Add;
|
|
|
dto.Status = ECaseStatus.Auditing;
|
|
|
- return await _CaseApplication.AddCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ return await _caseApplication.AddCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -224,7 +255,7 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
dto.ApplyStatus = ECaseApplyStatus.Update;
|
|
|
dto.Status = ECaseStatus.Auditing;
|
|
|
- await _CaseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ await _caseApplication.UpdateCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -240,7 +271,7 @@ namespace Hotline.Api.Controllers
|
|
|
dto.ApplyStatus = ECaseApplyStatus.Offshelf;
|
|
|
dto.Status = ECaseStatus.Auditing;
|
|
|
|
|
|
- await _CaseApplication.AuditCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
+ await _caseApplication.AuditCaseAsync(dto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -251,7 +282,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPut("list/examin")]
|
|
|
public async Task ExaminCase([FromBody] AuditCaseListDto dto)
|
|
|
{
|
|
|
- var Case = await _CaseListRepository.GetAsync(dto.Id);
|
|
|
+ var Case = await _caseListRepository.GetAsync(dto.Id);
|
|
|
if (Case == null)
|
|
|
throw UserFriendlyException.SameMessage("案例库查询失败");
|
|
|
|
|
@@ -282,7 +313,7 @@ namespace Hotline.Api.Controllers
|
|
|
CaseDto.ExaminManId = _sessionContext.UserId;
|
|
|
CaseDto.ExaminOrganizeId = _sessionContext.OrgId;
|
|
|
|
|
|
- await _CaseApplication.AuditCaseAsync(CaseDto, HttpContext.RequestAborted);
|
|
|
+ await _caseApplication.AuditCaseAsync(CaseDto, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -293,7 +324,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("list/info")]
|
|
|
public async Task<CaseInfoDto> GetCase([FromBody] PvCaseListDto dto)
|
|
|
{
|
|
|
- return await _CaseApplication.GetCaseAsync(dto.Id, dto.IsAddPv, HttpContext.RequestAborted);
|
|
|
+ return await _caseApplication.GetCaseAsync(dto.Id, dto.IsAddPv, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -304,33 +335,33 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPut("list/score")]
|
|
|
public async Task ScoreCase([FromBody] PvCaseListDto dto)
|
|
|
{
|
|
|
- var collect = await _CaseCollectRepository.GetAsync(x => x.CaseId == dto.Id && x.CreatorId == _sessionContext.UserId);
|
|
|
+ var collect = await _caseCollectRepository.GetAsync(x => x.CaseId == dto.Id && x.CreatorId == _sessionContext.UserId);
|
|
|
if (collect != null)
|
|
|
{
|
|
|
if (collect.Score > 0)
|
|
|
throw UserFriendlyException.SameMessage("当前知识已经评分");
|
|
|
|
|
|
collect.Score = dto.Score;
|
|
|
- await _CaseCollectRepository.UpdateAsync(collect, HttpContext.RequestAborted);
|
|
|
+ await _caseCollectRepository.UpdateAsync(collect, HttpContext.RequestAborted);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
collect = new CaseCollect();
|
|
|
collect.CaseId = dto.Id;
|
|
|
collect.Score = dto.Score;
|
|
|
- await _CaseCollectRepository.AddAsync(collect, HttpContext.RequestAborted);
|
|
|
+ await _caseCollectRepository.AddAsync(collect, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
//计算总分
|
|
|
- var sugar = _CaseCollectRepository.Queryable().Where(x => x.CaseId == dto.Id);
|
|
|
+ var sugar = _caseCollectRepository.Queryable().Where(x => x.CaseId == dto.Id);
|
|
|
var count = await sugar.CountAsync();
|
|
|
var collects = await sugar.SumAsync(x => x.Score);
|
|
|
var scoreTemp = collects / count;
|
|
|
- var Case = await _CaseListRepository.GetAsync(x => x.Id == dto.Id);
|
|
|
+ var Case = await _caseListRepository.GetAsync(x => x.Id == dto.Id);
|
|
|
if (Case != null)
|
|
|
{
|
|
|
Case.Score = decimal.Round(scoreTemp.Value, 1);
|
|
|
- await _CaseListRepository.UpdateAsync(Case, HttpContext.RequestAborted);
|
|
|
+ await _caseListRepository.UpdateAsync(Case, HttpContext.RequestAborted);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -342,7 +373,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("list/exist")]
|
|
|
public async Task<bool> ExistCase([FromBody] CaseExistDto dto)
|
|
|
{
|
|
|
- var any = await _CaseListRepository.Queryable()
|
|
|
+ var any = await _caseListRepository.Queryable()
|
|
|
.Where(x => x.Status == ECaseStatus.Auditing || x.Status >= ECaseStatus.OnShelf)
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Title), x => x.Title.Equals(dto.Title))
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Abstract), x => x.Abstract.Equals(dto.Abstract))
|
|
@@ -364,27 +395,87 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
if (dto.Ids.Length > 1)
|
|
|
{
|
|
|
- var streams = await _CaseApplication.CaseInfoListExportAsync(dto, HttpContext.RequestAborted);
|
|
|
+ var streams = await _caseApplication.CaseInfoListExportAsync(dto, HttpContext.RequestAborted);
|
|
|
byte[] fileBytes = _wordHelperService.ConvertZipStream(streams);
|
|
|
var name = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
return File(fileBytes, "application/octet-stream", $"{name}.zip");
|
|
|
}
|
|
|
- var info = await _CaseListRepository.GetAsync(dto.Ids[0]) ?? throw UserFriendlyException.SameMessage("案例不存在");
|
|
|
+ var info = await _caseListRepository.GetAsync(dto.Ids[0]) ?? throw UserFriendlyException.SameMessage("案例不存在");
|
|
|
return info.Result.HtmlToStream(dto.FileType).GetFileStreamResult(dto.FileType, info.Title, false);
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 案例库检索
|
|
|
-
|
|
|
/// <summary>
|
|
|
- /// 案例库列表前10
|
|
|
+ /// 案例库列表页面枚举值
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- [HttpGet("list/top10")]
|
|
|
+ [HttpGet("list/status-data")]
|
|
|
+ public Dictionary<string, dynamic> PlanStatus()
|
|
|
+ {
|
|
|
+ var tabStatusName = new List<KeyValuePair<int, string>>
|
|
|
+ {
|
|
|
+ new KeyValuePair<int, string>(3, "已上架"),
|
|
|
+ new KeyValuePair<int, string>(4, "已下架"),
|
|
|
+ new KeyValuePair<int, string>(1, "审核中"),
|
|
|
+ new KeyValuePair<int, string>(7, "草稿"),
|
|
|
+ new KeyValuePair<int, string>(-1, "全部")
|
|
|
+ };
|
|
|
+
|
|
|
+ var tabExamineName = new List<KeyValuePair<int, string>>
|
|
|
+ {
|
|
|
+ new KeyValuePair<int, string>(-1, "全部"),
|
|
|
+ new KeyValuePair<int, string>(0, "新增审核"),
|
|
|
+ new KeyValuePair<int, string>(1, "修改审核"),
|
|
|
+ new KeyValuePair<int, string>(2, "删除审核")
|
|
|
+ };
|
|
|
+
|
|
|
+ var StatusName = new List<KeyValuePair<int, string>>
|
|
|
+ {
|
|
|
+ new KeyValuePair<int, string>(-1, "全部"),
|
|
|
+ new KeyValuePair<int, string>(0, "待提交"),
|
|
|
+ new KeyValuePair<int, string>(1, "审核中"),
|
|
|
+ new KeyValuePair<int, string>(3, "已上架"),
|
|
|
+ new KeyValuePair<int, string>(4, "已下架"),
|
|
|
+ new KeyValuePair<int, string>(5, "审核不通过"),
|
|
|
+ new KeyValuePair<int, string>(6, "已过期"),
|
|
|
+ new KeyValuePair<int, string>(7, "草稿")
|
|
|
+ };
|
|
|
+
|
|
|
+ var ApplyStatusName = new List<KeyValuePair<int, string>>
|
|
|
+ {
|
|
|
+ new KeyValuePair<int, string>(-1, "全部"),
|
|
|
+ new KeyValuePair<int, string>(0, "新增审核"),
|
|
|
+ new KeyValuePair<int, string>(1, "修改审核"),
|
|
|
+ new KeyValuePair<int, string>(2, "删除审核")
|
|
|
+ };
|
|
|
+
|
|
|
+ var ignoreFileType = EFileType.excel | EFileType.pdf;
|
|
|
+ var items = EnumExts.GetDescriptions<EFileType>();
|
|
|
+ var filteredDictionary = items
|
|
|
+ .Where(kvp => (ignoreFileType & (EFileType)kvp.Key) == 0)
|
|
|
+ .ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ return new Dictionary<string, dynamic>
|
|
|
+ {
|
|
|
+ { "fileType", filteredDictionary},
|
|
|
+ { "tabStatusName", tabStatusName },
|
|
|
+ { "tabExamineName", tabExamineName },
|
|
|
+ { "StatusName", StatusName },
|
|
|
+ { "ApplyStatusName", ApplyStatusName }
|
|
|
+ };
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 案例库检索
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 案例库列表前10
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("list/top10")]
|
|
|
public async Task<List<CasePageViewDto>> QueryTop10CaseList()
|
|
|
{
|
|
|
- return await _CaseListRepository.Queryable()
|
|
|
+ return await _caseListRepository.Queryable()
|
|
|
.Take(10)
|
|
|
.Where(x => x.Status == ECaseStatus.OnShelf)
|
|
|
.Select(x => new CasePageViewDto
|