|
@@ -100,7 +100,7 @@ namespace GxPress.Service.Implement.Note
|
|
item.File = StringUtils.RemoveDomain(item.File);
|
|
item.File = StringUtils.RemoveDomain(item.File);
|
|
//添加笔记
|
|
//添加笔记
|
|
var note = new Entity.Note.Note
|
|
var note = new Entity.Note.Note
|
|
- { Title = request.Title, Content = JsonConvert.SerializeObject(noteContent), HtmlContent = request.HtmlContent, UserId = request.UserId, IsDelete = false, IsTopic = request.IsTopic, FolderId = request.FolderId, MediaId = request.MediaId, MediaType = request.MediaType, CatalogId = request.CatalogId, ChapterId = request.ChapterId};
|
|
|
|
|
|
+ { Title = request.Title, Content = JsonConvert.SerializeObject(noteContent), HtmlContent = request.HtmlContent, UserId = request.UserId, IsDelete = false, IsTopic = request.IsTopic, FolderId = request.FolderId, MediaId = request.MediaId, MediaType = request.MediaType, CatalogId = request.CatalogId, ChapterId = request.ChapterId };
|
|
var noteId = await _noteRepository.InsertAsync(note);
|
|
var noteId = await _noteRepository.InsertAsync(note);
|
|
//添加中间件
|
|
//添加中间件
|
|
var middleInsertTypes = new MiddleInsertTypeRequest
|
|
var middleInsertTypes = new MiddleInsertTypeRequest
|
|
@@ -562,6 +562,76 @@ namespace GxPress.Service.Implement.Note
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 笔记没有文件夹分页
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public async Task<PagedList<NoteNotFolderPageResult>> GetNoteNotFolderPageResult(NoteSearchPageListRequest request)
|
|
|
|
+ {
|
|
|
|
+ var result = await _noteRepository.GetNoteNotFolderPageResult(request);
|
|
|
|
+ foreach (var item in result.Items)
|
|
|
|
+ {
|
|
|
|
+ //是否摘录
|
|
|
|
+ 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 == OldTextEditorTypeConst.Text.GetHashCode() && forCount == 1)
|
|
|
|
+ //文本
|
|
|
|
+ firstContent = jsonData.Text;
|
|
|
|
+ else if (jsonData.TypeValue == OldTextEditorTypeConst.Text.GetHashCode() && forCount > 1)
|
|
|
|
+ //文本
|
|
|
|
+ continue;
|
|
|
|
+ //图片
|
|
|
|
+ else if (jsonData.TypeValue == OldTextEditorTypeConst.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> { OldTextEditorTypeConst.Text.GetHashCode(), OldTextEditorTypeConst.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;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|