/// <summary> /// 获得笔记和内容 /// </summary> /// <param name="noteId"></param> /// <param name="userId"></param> /// <param name="isTrach">是否垃圾</param> /// <param name="isDelete">是否删除</param> /// <param name="IsHistory">是否历史记录</param> /// <returns></returns> public static NoteAndContent GetNoteAndContent(long noteId, long userId, bool isTrach, bool isDelete, bool IsHistory) { Note note = GetNote(noteId, userId, isTrach, isDelete); NoteContent noteContent = NoteContentService.GetNoteContent(noteId, userId, IsHistory); return(new NoteAndContent() { note = note, noteContent = noteContent }); }
public BlogItem[] notes2BlogItems(Note[] notes) { var noteIds = (from note in notes select note.NoteId).ToArray(); var noteContents = NoteContentService.DictionaryNoteContentByNoteIds(noteIds); var blogs = new List <BlogItem>(); foreach (var note in notes) { var blogItem = new BlogItem() { Note = note, Abstract = noteContents[note.NoteId]?.Abstract, Content = noteContents[note.NoteId]?.Content, HasMore = true }; blogs.Add(blogItem); } return(blogs.ToArray()); }
public BlogItem GetBlogItem(Note note) { if (note == null || !note.IsBlog) { return(new BlogItem()); } //内容 var noteContent = NoteContentService.GetNoteContent(note.NoteId, note.UserId); // 组装成blogItem User user = UserService.GetUserByUserId(note.UserId); var blog = new BlogItem() { Note = note, Abstract = noteContent.Abstract, Content = noteContent.Content, HasMore = false, User = user }; return(blog); }
public static Note AddNoteAndContent(Note note, NoteContent noteContent, long myUserId) { if (note.NoteId == 0) { note.NoteId = SnowFlake_Net.GenerateSnowFlakeID(); } noteContent.NoteContentId = SnowFlake_Net.GenerateSnowFlakeID(); noteContent.NoteId = note.NoteId; if (note.UserId != 0 && note.UserId != myUserId) { note = AddSharedNote(note, myUserId); } else { note = AddNote(note, false); } if (note.NoteId != 0) { NoteContentService.AddNoteContent(noteContent); } return(note); }
//todo 删除废纸篓 public static bool DeleteTrashApi(long noteId, long userId, int usn, out string msg, out int afterUsn) { Note note = NoteService.GetNote(noteId, userId); if (note == null) { msg = "notExists"; afterUsn = 0; //todo: 存疑 return(false); } if (note.Usn != usn) { msg = "conflict"; afterUsn = 0; return(false); } // 设置删除位 //afterUsn = UserService.IncrUsn(userId); // delete note's attachs var result = NoteService.SetDeleteStatus(noteId, userId, out afterUsn); if (!result) { msg = "设置删除位错误"; afterUsn = 0; return(false); } AttachService.DeleteAllAttachs(noteId, userId); // 删除content history NoteContentService.DeleteByIdAndUserId(noteId, userId, true); NotebookService.ReCountNotebookNumberNotes(note.NotebookId); msg = ""; return(true); }