public void AddTest() { Notebook notebook1 = new Notebook() { NotebookId = SnowFlake_Net.GenerateSnowFlakeID() }; Notebook notebook2 = new Notebook() { NotebookId = SnowFlake_Net.GenerateSnowFlakeID() }; Notebook notebook3 = new Notebook() { NotebookId = SnowFlake_Net.GenerateSnowFlakeID() }; notebook2.ParentNotebookId = notebook1.NotebookId; notebook3.ParentNotebookId = notebook1.NotebookId; NotebookService.AddNotebook(notebook1); NotebookService.AddNotebook(notebook2); NotebookService.AddNotebook(notebook3); // Assert.Fail(); }
private void InsertALL(Notebook notebook) { NotebookService.AddNotebook(notebook); foreach (Notebook n in notebook.Subs) { InsertALL(n); } }
public IActionResult AddNotebook(string token, string title, string parentNotebookId, int seq) { User user = tokenSerivce.GetUserByToken(token); if (user == null) { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "NOTLOGIN", }; return(Json(apiRe, MyJsonConvert.GetLeanoteOptions())); } else { Notebook notebook = new Notebook() { NotebookId = idGenerator.NextId(), Title = title, Seq = seq, UserId = user.UserId, ParentNotebookId = parentNotebookId.ToLongByHex() }; if (notebookService.AddNotebook(ref notebook)) { ApiNotebook apiNotebook = fixNotebook(notebook); return(Json(apiNotebook, MyJsonConvert.GetLeanoteOptions())); } else { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "AddNotebook is error", }; return(Json(apiRe, MyJsonConvert.GetLeanoteOptions())); } } }
public JsonResult AddNotebook(string notebookId, string title, string parentNotebookId) { Notebook notebook; var result = notebookService.AddNotebook(notebookId.ToLongByHex(), GetUserIdBySession(), parentNotebookId.ToLongByHex(), title, out notebook); if (result) { return(Json(notebook, MyJsonConvert.GetLeanoteOptions())); } else { return(Json(false)); } }
//添加notebook public IActionResult AddNotebook(string token, string title, string parentNotebookId, int seq) { User user = TokenSerivce.GetUserByToken(token); if (user == null) { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "Not logged in", }; return(Json(apiRe, MyJsonConvert.GetOptions())); } else { Notebook notebook = new Notebook() { NotebookId = SnowFlake_Net.GenerateSnowFlakeID(), Title = title, Seq = seq, UserId = user.UserId, ParentNotebookId = MyConvert.HexToLong(parentNotebookId) }; if (NotebookService.AddNotebook(ref notebook)) { ApiNotebook apiNotebook = fixNotebook(notebook); return(Json(apiNotebook, MyJsonConvert.GetOptions())); } else { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "AddNotebook is error", }; return(Json(apiRe, MyJsonConvert.GetOptions())); } } }
public async Task <IActionResult> CreateNoteRepository(string token, string data, string dataSignJson) { var re = new ApiRe() { Ok = false, Data = null }; var verify = false; if (this.config.SecurityConfig.ForceDigitalSignature) { //验证签名 var dataSign = DataSignDTO.FromJSON(dataSignJson); verify = await this.ePassService.VerifyDataSign(dataSign); if (!verify) { return(LeanoteJson(re)); } verify = dataSign.SignData.Operate.Equals("/api/NotesRepository/CreateNoteRepository"); if (!verify) { re.Msg = "Operate is not Equals "; return(LeanoteJson(re)); } //签名存证 this.dataSignService.AddDataSign(dataSign, "CreateNoteRepository"); } var user = tokenSerivce.GetUserByToken(token); var notesRepository = JsonSerializer.Deserialize <NotesRepository>(data, MyJsonConvert.GetLeanoteOptions()); if (notesRepository.RepositoryOwnerType == RepositoryOwnerType.Organization) { var orgId = notesRepository.OwnerId; verify = organizationService.Verify(orgId, user.UserId, OrganizationAuthorityEnum.AddRepository); if (verify == false) { re.Msg = "您没有权限创建这个仓库"; return(LeanoteJson(re)); } } if (notesRepository.RepositoryOwnerType == RepositoryOwnerType.Personal) { if (notesRepository.OwnerId != user.UserId) { re.Msg = "您没有权限创建这个仓库"; return(LeanoteJson(re)); } } //if (!MyStringUtil.IsNumAndEnCh(notesRepository.Name)) //{ // apiRe.Msg = "仓库路径仅允许使用英文大小写、数字,不允许特殊符号"; // return LeanoteJson(apiRe); //} if (noteRepositoryService.ExistNoteRepositoryByName(notesRepository.OwnerId, notesRepository.Name)) { re.Msg = "仓库名称冲突"; return(LeanoteJson(re)); } var result = noteRepositoryService.CreateNoteRepository(notesRepository); var list = new List <string>(4) { "life", "study", "work", "tutorial" }; foreach (var item in list) { // 添加笔记本, 生活, 学习, 工作 var userId = user.UserId; var notebook = new Notebook() { NotebookId = idGenerator.NextId(), NotesRepositoryId = result.Id, Seq = 0, UserId = userId, CreatedTime = DateTime.Now, Title = item, ParentNotebookId = null, }; notebookService.AddNotebook(notebook); } if (result == null) { re.Msg = "数据库创建仓库失败"; return(LeanoteJson(re)); } re.Ok = true; re.Data = result; return(LeanoteJson(re)); }