mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-05 00:08:49 +01:00
♻️ Refactor recent documents handling
This commit is contained in:
parent
188fa4e669
commit
fe87cf521a
6 changed files with 330 additions and 140 deletions
|
|
@ -80,6 +80,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/storage/getRecentDocs", model.CheckAuth, getRecentDocs)
|
||||
ginServer.Handle("POST", "/api/storage/updateRecentDocViewTime", model.CheckAuth, updateRecentDocViewTime)
|
||||
ginServer.Handle("POST", "/api/storage/updateRecentDocCloseTime", model.CheckAuth, updateRecentDocCloseTime)
|
||||
ginServer.Handle("POST", "/api/storage/batchUpdateRecentDocCloseTime", model.CheckAuth, batchUpdateRecentDocCloseTime)
|
||||
ginServer.Handle("POST", "/api/storage/updateRecentDocOpenTime", model.CheckAuth, updateRecentDocOpenTime)
|
||||
|
||||
ginServer.Handle("POST", "/api/storage/getOutlineStorage", model.CheckAuth, getOutlineStorage)
|
||||
|
|
|
|||
|
|
@ -293,11 +293,11 @@ func updateRecentDocCloseTime(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if nil == arg["rootID"] {
|
||||
rootID, ok := arg["rootID"].(string)
|
||||
if !ok || rootID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
rootID := arg["rootID"].(string)
|
||||
err := model.UpdateRecentDocCloseTime(rootID)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
|
|
@ -305,3 +305,26 @@ func updateRecentDocCloseTime(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
func batchUpdateRecentDocCloseTime(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
rootIDsArg := arg["rootIDs"].([]interface{})
|
||||
var rootIDs []string
|
||||
for _, id := range rootIDsArg {
|
||||
rootIDs = append(rootIDs, id.(string))
|
||||
}
|
||||
|
||||
err := model.BatchUpdateRecentDocCloseTime(rootIDs)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue