public NoteAPIController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, NoteService noteService, NoteContentService noteContentService, NotebookService notebookService, NoteRepositoryService noteRepositoryService, TrashService trashService, EPassService ePass, GMService gMService, DataSignService dataSignService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.attachService = attachService; this.noteService = noteService; this.tokenSerivce = tokenSerivce; this.noteContentService = noteContentService; this.trashService = trashService; this.accessor = accessor; this.notebookService = notebookService; this.noteRepositoryService = noteRepositoryService; this.ePassService = ePass; this.dataSignService = dataSignService; this.gMService = gMService; }
//todo:得到note和内容 public IActionResult GetNoteAndContent(string token, string noteId) { User tokenUser = TokenSerivce.GetUserByToken(token); if (tokenUser == null) { return(Json(new ApiRe() { Ok = false, Msg = "" }, MyJsonConvert.GetOptions())); } NoteAndContent noteAndContent = NoteService.GetNoteAndContent(MyConvert.HexToLong(noteId), tokenUser.UserId, false, false, false); ApiNote[] apiNotes = NoteService.ToApiNotes(new Note[] { noteAndContent.note }); ApiNote apiNote = apiNotes[0]; apiNote.Content = NoteService.FixContent(noteAndContent.noteContent.Content, noteAndContent.note.IsMarkdown); apiNote.Desc = noteAndContent.note.Desc; apiNote.Abstract = noteAndContent.noteContent.Abstract; if (noteAndContent == null) { return(Json(new ApiRe() { Ok = false, Msg = "" }, MyJsonConvert.GetOptions())); } else { return(Json(apiNote, MyJsonConvert.GetOptions())); } }
//todo:删除笔记本 public IActionResult DeleteNotebook(string token, string notebookId, int usn) { User user = TokenSerivce.GetUserByToken(token); if (user == null) { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "Not logged in", }; return(Json(apiRe, MyJsonConvert.GetOptions())); } if (NotebookService.DeleteNotebookForce(user.UserId, MyConvert.HexToLong(notebookId), usn)) { ApiRe apiRe = new ApiRe() { Ok = true, Msg = "success", }; return(Json(apiRe, MyJsonConvert.GetOptions())); } else { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "conflict", }; return(Json(apiRe, MyJsonConvert.GetOptions())); } }
public RemoteFileController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor , AccessService accessService , ConfigService configService , TagService tagService , NoteService noteService , NotebookService notebookService , IWebHostEnvironment webHostEnvironment , ISevenZipCompressor sevenZipCompressor , BlogService blogService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.accessService = accessService; this.blogService = blogService; this.configService = configService; this.tagService = tagService; this.notebookService = notebookService; this.noteService = noteService; this.HostEnvironment = webHostEnvironment; this.SevenZipCompressor = sevenZipCompressor; if (RuntimeEnvironment.IsWindows) { PathRoot = @"C:\"; } }
//修改笔记 public IActionResult UpdateNotebook(string token, string notebookId, string title, string parentNotebookId, int seq, int usn) { 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; if (NotebookService.UpdateNotebookApi(user.UserId, MyConvert.HexToLong(notebookId), title, MyConvert.HexToLong(parentNotebookId), seq, usn, out notebook)) { ApiNotebook apiNotebook = fixNotebook(notebook); return(Json(apiNotebook, MyJsonConvert.GetOptions())); } else { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "UpdateNotebook is error", }; return(Json(apiRe, MyJsonConvert.GetOptions())); } } }
public void GenerateTokenTest() { long id = SnowFlake_Net.GenerateSnowFlakeID(); Console.WriteLine(id); string token = TokenSerivce.GenerateToken(id, 16); Console.WriteLine(token); }
public APPController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { }
public MemberIndexController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, NoteService noteService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.noteService = noteService; }
public JoplinTestingController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor , AuthService authService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.AuthService = authService; }
public SpamController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, SpamService spamService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.spamService = spamService; }
public User getUserByToken(string token) { if (string.IsNullOrEmpty(token)) { return(null); } else { User user = TokenSerivce.GetUserByToken(token); return(user); } }
public TagAPIController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, TagService tagService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.tokenSerivce = tokenSerivce; this.tagService = tagService; }
public FileAPIController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, NoteService noteService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.noteService = noteService; this.webSiteConfig = configFileService.WebConfig; }
public VditorController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, AuthService authService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.authService = authService; this.userService = userService; this.tokenSerivce = tokenSerivce; }
// todo:得到用户信息 public long getUserIdByToken(string token) { if (string.IsNullOrEmpty(token)) { return(0); } else { User user = TokenSerivce.GetUserByToken(token); long userid = (user == null ? 0 : user.UserId); return(userid); } }
public OrganizationController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, NotebookService notebookService, OrganizationService organizationService, NoteRepositoryService noteRepositoryService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.organizationService = organizationService; }
public USBKeyController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor , AuthService authService , EPassService ePassService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.authService = authService; this.ePass = ePassService; }
public FIDO2Controller(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor , AuthService authService , FIDO2Service fIDO2Service ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.authService = authService; this.fido2Service = fIDO2Service; }
public PayJSController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor , DataContext dataContext ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.dataContext = dataContext; this.configFileService = configFileService; webSiteConfig = configFileService.WebConfig; pay = new Payjs(webSiteConfig.Payjs.PayJS_MCHID, webSiteConfig.Payjs.PayJS_Key); }
//todo:获取同步的标签 public JsonResult GetSyncTags(string token, int afterUsn, int maxEntry) { User user = TokenSerivce.GetUserByToken(token); if (user == null) { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "Not logged in", }; return(Json(apiRe, MyJsonConvert.GetOptions())); } NoteTag[] noteTags = TagService.GeSyncTags(user.UserId, afterUsn, maxEntry); return(Json(noteTags, MyJsonConvert.GetOptions())); }
public long getUserIdByToken() { string token = GetToken(); if (string.IsNullOrEmpty(token)) { string userid_hex = _accessor.HttpContext.Session.GetString("userId"); long userid_number = MyConvert.HexToLong(userid_hex); return(userid_number); } else { User user = TokenSerivce.GetUserByToken(token); long userid = (user == null ? 0 : user.UserId); return(userid); } }
public AuthController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IDistributedCache distributedCache , IHttpContextAccessor accessor, AuthService authService, ConfigService configService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.distributedCache = distributedCache; this.authService = authService; this.configService = configService; this.config = configService.config; }
public BaseController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor ) { this.attachService = attachService; this.tokenSerivce = tokenSerivce; this.noteFileService = noteFileService; this.configFileService = configFileService; this.userService = userService; this._accessor = accessor; config = configFileService.WebConfig; }
public NotesRepositoryController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, NotebookService notebookService, NoteRepositoryService noteRepositoryService, OrganizationService organizationService, EPassService ePassService, DataSignService dataSignService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.notebookService = notebookService; this.noteRepositoryService = noteRepositoryService; this.ePassService = ePassService; this.dataSignService = dataSignService; }
//添加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 APIController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, AccessService accessService, DataContext dataContext ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.AccessService = accessService; this.dataContext = dataContext; this.configFileService = configFileService; webcConfig = configFileService.WebConfig; _randomImageFuseSize = webcConfig.PublicAPI.RandomImageFuseSize; }
public UserAPIController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , GMService gMService , RealNameService realNameService , IHttpContextAccessor accessor, AuthService authService , EPassService ePass , DataSignService dataSignService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.authService = authService; this.userService = userService; this.tokenSerivce = tokenSerivce; this.realNameService = realNameService; this.ePassService = ePass; this.gMService = gMService; this.dataSignService = dataSignService; }
public CommonController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ConfigFileService configFileService , IHttpContextAccessor accessor, NoteService noteService, NoteContentService noteContentService, NotebookService notebookService, NoteRepositoryService noteRepositoryService, TrashService trashService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.attachService = attachService; this.noteService = noteService; this.tokenSerivce = tokenSerivce; this.noteContentService = noteContentService; this.trashService = trashService; this.accessor = accessor; this.notebookService = notebookService; this.noteRepositoryService = noteRepositoryService; }
//获得同步状态 // [HttpPost] public JsonResult GetSyncState(string token) { User user = TokenSerivce.GetUserByToken(token); if (user == null) { ApiRe apiRe = new ApiRe() { Ok = false, Msg = "Not logged in", }; string json = JsonSerializer.Serialize(apiRe, MyJsonConvert.GetSimpleOptions()); return(Json(apiRe, MyJsonConvert.GetOptions())); } ApiGetSyncState apiGetSyncState = new ApiGetSyncState() { LastSyncUsn = user.Usn, LastSyncTime = UnixTimeHelper.GetTimeStampInLong(DateTime.Now) }; return(Json(apiGetSyncState, MyJsonConvert.GetSimpleOptions())); }
public NoteController(AttachService attachService , TokenSerivce tokenSerivce , NoteFileService noteFileService , UserService userService , ShareService shareService , ConfigFileService configFileService , IWebHostEnvironment env , TagService tagService , TrashService trashService , IHttpContextAccessor accessor , NotebookService notebookService , NoteService noteService , NoteContentService noteContentService ) : base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor) { this.notebookService = notebookService; this.noteService = noteService; this.noteContentService = noteContentService; this.env = env; this.tagService = tagService; this.trashService = trashService; }