🉑 origin优化

This commit is contained in:
微凉
2021-01-11 16:53:48 +08:00
parent dcebf5257f
commit 858291876b
10 changed files with 70 additions and 43 deletions

View File

@@ -11,12 +11,12 @@ import (
func Search(c *gin.Context) {
if !conf.Conf.Server.Search {
c.JSON(200, metaResponse(403,"Not allow search."))
c.JSON(200, MetaResponse(403,"Not allow search."))
return
}
var search alidrive.SearchReq
if err := c.ShouldBindJSON(&search); err != nil {
c.JSON(200, metaResponse(400,"Bad Request"))
c.JSON(200, MetaResponse(400,"Bad Request"))
return
}
log.Debugf("search:%+v",search)
@@ -26,7 +26,7 @@ func Search(c *gin.Context) {
files,exist:=conf.Cache.Get(cacheKey)
if exist {
log.Debugf("使用了缓存:%s",cacheKey)
c.JSON(200, dataResponse(files))
c.JSON(200, DataResponse(files))
return
}
}
@@ -39,11 +39,11 @@ func Search(c *gin.Context) {
//}
files,err:=alidrive.Search(search.Query,search.Limit,search.OrderBy)
if err != nil {
c.JSON(200, metaResponse(500,err.Error()))
c.JSON(200, MetaResponse(500,err.Error()))
return
}
if conf.Conf.Cache.Enable {
conf.Cache.Set(cacheKey,files,cache.DefaultExpiration)
}
c.JSON(200, dataResponse(files))
c.JSON(200, DataResponse(files))
}