예제 #1
0
 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;
 }
예제 #2
0
        //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()));
            }
        }
예제 #3
0
        //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()));
            }
        }
예제 #4
0
        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:\";
            }
        }
예제 #5
0
        //修改笔记
        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()));
                }
            }
        }
예제 #6
0
        public void GenerateTokenTest()
        {
            long id = SnowFlake_Net.GenerateSnowFlakeID();

            Console.WriteLine(id);
            string token = TokenSerivce.GenerateToken(id, 16);

            Console.WriteLine(token);
        }
예제 #7
0
        public APPController(AttachService attachService
                             , TokenSerivce tokenSerivce
                             , NoteFileService noteFileService
                             , UserService userService
                             , ConfigFileService configFileService

                             , IHttpContextAccessor accessor) :
            base(attachService, tokenSerivce, noteFileService, userService, configFileService, accessor)
        {
        }
예제 #8
0
 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;
 }
예제 #9
0
 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;
 }
예제 #10
0
 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;
 }
예제 #11
0
 public User getUserByToken(string token)
 {
     if (string.IsNullOrEmpty(token))
     {
         return(null);
     }
     else
     {
         User user = TokenSerivce.GetUserByToken(token);
         return(user);
     }
 }
예제 #12
0
 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;
 }
예제 #13
0
 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;
 }
예제 #14
0
 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;
 }
예제 #15
0
 // 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);
     }
 }
예제 #16
0
 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;
 }
예제 #17
0
 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;
 }
예제 #18
0
 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;
 }
예제 #19
0
 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);
 }
예제 #20
0
        //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()));
        }
예제 #21
0
        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);
            }
        }
예제 #22
0
        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;
        }
예제 #23
0
        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;
        }
예제 #24
0
 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;
 }
예제 #25
0
        //添加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()));
                }
            }
        }
예제 #26
0
        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;
        }
예제 #27
0
 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;
 }
예제 #28
0
 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;
 }
예제 #29
0
        //获得同步状态
        //  [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()));
        }
예제 #30
0
 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;
 }