|
@@ -149,6 +149,78 @@ namespace GxPress.Service.Implement.Note
|
|
|
return true;
|
|
|
}
|
|
|
/// <summary>
|
|
|
+ /// 获取笔记/话题草稿分页
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<PagedList<NoteNotFolderPageResult>> NoteTopicDraftPageListAsync(NoteSearchPageListRequest request)
|
|
|
+ {
|
|
|
+ var result = await _noteRepository.NoteTopicDraftPageListAsync(request);
|
|
|
+ foreach (var item in result.Items)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(item.FolderName))
|
|
|
+ item.FolderName = "根目录";
|
|
|
+ // item.MiddleId = item.Id;
|
|
|
+ //是否摘录
|
|
|
+ if (item.MediaId > 0)
|
|
|
+ {
|
|
|
+ item.IsExtract = true;
|
|
|
+ var query = Q.NewQuery();
|
|
|
+ query.Where(nameof(Entity.tede2.Media.Media.Id), item.MediaId);
|
|
|
+ item.MediaNoteResult = await mediaRepository.GetAsync(query);
|
|
|
+ if (item.MediaNoteResult != null)
|
|
|
+ item.MediaNoteResult.ImageUrls = StringUtils.AddDomain(item.MediaNoteResult.ImageUrls);
|
|
|
+ }
|
|
|
+ if (string.IsNullOrWhiteSpace(item.Content))
|
|
|
+ item.Content = "[]";
|
|
|
+ var contentJsonData = JsonConvert.DeserializeObject<List<ContentJsonData>>(item.Content);
|
|
|
+ foreach (var contentJsonDataItem in contentJsonData)
|
|
|
+ contentJsonDataItem.File = StringUtils.AddDomain(contentJsonDataItem.File);
|
|
|
+ if (contentJsonData.Count == 0)
|
|
|
+ item.DataType = 1;
|
|
|
+ item.Content = "";
|
|
|
+ if (contentJsonData.Count > 0)
|
|
|
+ {
|
|
|
+ var imgData = new List<ContentJsonData>();
|
|
|
+ var FileData = new List<ContentJsonData>();
|
|
|
+ var forCount = 1;
|
|
|
+ var firstContent = string.Empty;
|
|
|
+ foreach (var jsonData in contentJsonData)
|
|
|
+ {
|
|
|
+ if (jsonData.TypeValue == AllTypeConst.Text.GetHashCode() && forCount == 1)
|
|
|
+ //文本
|
|
|
+ firstContent = jsonData.Text;
|
|
|
+ else if (jsonData.TypeValue == AllTypeConst.Text.GetHashCode() && forCount > 1)
|
|
|
+ //文本
|
|
|
+ continue;
|
|
|
+ //图片
|
|
|
+ else if (jsonData.TypeValue == AllTypeConst.Image.GetHashCode() && FileData.Count == 0)
|
|
|
+ {
|
|
|
+ if (imgData.Count > 9)
|
|
|
+ break;
|
|
|
+ imgData.Add(jsonData);
|
|
|
+ }
|
|
|
+ //附件
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FileData.Add(jsonData);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ forCount++;
|
|
|
+ }
|
|
|
+ item.Content = string.IsNullOrWhiteSpace(firstContent) ? "" : firstContent;
|
|
|
+ if (imgData.Count > 0) { item.DataType = 2; item.Data = imgData; }
|
|
|
+ else if (FileData.Count > 0) { item.DataType = 3; item.Data = FileData; }
|
|
|
+ else item.DataType = 1;
|
|
|
+ var contType = new List<int> { AllTypeConst.Text.GetHashCode(), AllTypeConst.Image.GetHashCode() };
|
|
|
+ item.FileCount = contentJsonData.Count(n => !contType.Contains(n.Type));
|
|
|
+ }
|
|
|
+ if (item.Data == null || item.Data.Count == 0)
|
|
|
+ item.Data = new List<ContentJsonData>();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
/// 获取笔记分页
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|