mirror of https://github.com/Xhofe/alist
feat: get storage by id api
parent
e08810a12f
commit
184b9d1e6c
|
@ -69,3 +69,18 @@ func DeleteStorage(c *gin.Context) {
|
||||||
}
|
}
|
||||||
common.SuccessResp(c)
|
common.SuccessResp(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStorage(c *gin.Context) {
|
||||||
|
idStr := c.Query("id")
|
||||||
|
id, err := strconv.Atoi(idStr)
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
storage, err := db.GetStorageById(uint(id))
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 500, true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
common.SuccessResp(c, storage)
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ func Init(r *gin.Engine) {
|
||||||
|
|
||||||
storage := admin.Group("/storage")
|
storage := admin.Group("/storage")
|
||||||
storage.GET("/list", handles.ListStorages)
|
storage.GET("/list", handles.ListStorages)
|
||||||
|
storage.GET("/get", handles.GetStorage)
|
||||||
storage.POST("/create", handles.CreateStorage)
|
storage.POST("/create", handles.CreateStorage)
|
||||||
storage.POST("/update", handles.UpdateStorage)
|
storage.POST("/update", handles.UpdateStorage)
|
||||||
storage.POST("/delete", handles.DeleteStorage)
|
storage.POST("/delete", handles.DeleteStorage)
|
||||||
|
|
Loading…
Reference in New Issue